# Syntax
if [ -z "$TAGS" ]; then
- echo "usage: $BASENAME <url> <tags> <description>"
+ echo "usage: $BASENAME <url> <tags> [description]"
exit
fi
# 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
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