]> gitweb.fluxo.info Git - scripts.git/commitdiff
Fix: scuttle improvements
authorSilvio Rhatto <rhatto@riseup.net>
Fri, 12 Feb 2021 12:31:20 +0000 (09:31 -0300)
committerSilvio Rhatto <rhatto@riseup.net>
Fri, 12 Feb 2021 12:31:20 +0000 (09:31 -0300)
scuttle

diff --git a/scuttle b/scuttle
index 9c2d9fac09dfb61643afa81fe8fc19b436e3976f..e065b48c3645fa27464c5388ec1b5da55f84ed3d 100755 (executable)
--- a/scuttle
+++ b/scuttle
@@ -31,7 +31,7 @@ TMP="${TMP:=/tmp}"
 
 # Syntax
 if [ -z "$TAGS" ]; then
-  echo "usage: $BASENAME <url> <tags> <description>"
+  echo "usage: $BASENAME <url> <tags> [description]"
   exit
 fi
 
@@ -51,7 +51,7 @@ TAGS="`echo $TAGS | sed -e 's/%2C/,/g'`"
 # Description
 if [ -z "$DESC" ]; then
   # See http://stackoverflow.com/questions/3195851/ddg#3195895
-  DESC="`torify curl -s $URL | grep -i "<title>" | sed -n 's/.*<title>\(.*\)<\/title>.*/\1/ip;T;q' 2> /dev/null`"
+  DESC="`torify curl -L -s $URL | grep -i "<title>" | sed -n 's/.*<title>\(.*\)<\/title>.*/\1/ip;T;q' 2> /dev/null`"
   echo "Fetched description: $DESC"
 fi
 
@@ -63,6 +63,9 @@ CONF="`mktemp -t scuttle.XXXXXXXXXX -p $TMP`"
 echo "url = $CALL" > $CONF
 echo "user = $SCUTTLE_USER:$SCUTTLE_PASS" >> $CONF
 
+# Remove trailing slash which might lead to urlencode errors by curl (dunny why)
+URL="`echo $URL | sed -e 's|/$||'`"
+
 # Call curl
 # See https://stackoverflow.com/questions/296536/how-to-urlencode-data-for-curl-command#2027690
 #curl -s -K $CONF &> /dev/null