]> gitweb.fluxo.info Git - scripts.git/commitdiff
Feats: enhance urlinfo and creates urlsave
authorSilvio Rhatto <rhatto@riseup.net>
Fri, 19 Feb 2021 19:05:56 +0000 (16:05 -0300)
committerSilvio Rhatto <rhatto@riseup.net>
Fri, 19 Feb 2021 19:05:56 +0000 (16:05 -0300)
urlinfo
urlsave [new file with mode: 0755]

diff --git a/urlinfo b/urlinfo
index 7a4cd49f79b0bf7a433d1ab1df280b29cadbe40f..cde32fa34a6fbd9d271e9d06cae8edd06a2c4448 100755 (executable)
--- a/urlinfo
+++ b/urlinfo
@@ -1,12 +1,39 @@
 #!/bin/bash
 #
-# Retrieve basic URL info.
+# Retrieve and set basic URL info.
 #
 
 # Parameters
 BASENAME="`basename $0`"
 URL="$1"
+shift
+TAGS="$*"
+
+# Check
+if [ -z "$URL" ]; then
+  echo "usage: $BASENAME <url> [tag1] ... [tagN]"
+  exit 1
+fi
 
 # Dispatch
 DESC="`torify curl --max-redirs 10 -L -s $URL | grep -i "<title>" | sed -n 's/.*<title>\(.*\)<\/title>.*/\1/ip;T;q' 2> /dev/null`"
-echo "Title: $DESC"
+
+# YouTube:
+#DESC="`torify curl youtube-dl -e $URL`"
+
+# Verify
+if [ -z "$DESC" ]; then
+  DESC="$URL"
+fi
+
+# Tag
+if [ ! -z "$TAGS" ]; then
+  IDENTIFIER="$URL $TAGS"
+else
+  IDENTIFIER="$URL"
+fi
+
+# Display
+echo "- title: \"$DESC\""
+echo "  identifier:"
+echo "    - $IDENTIFIER"
diff --git a/urlsave b/urlsave
new file mode 100755 (executable)
index 0000000..afef452
--- /dev/null
+++ b/urlsave
@@ -0,0 +1,20 @@
+#!/bin/bash
+#
+# Save URL info in a file as a simple bookmarking service.
+#
+
+# Parameters
+CONFIG="$HOME/.custom/urlsave"
+
+# Load config
+if [ -e "$CONFIG" ]; then
+  source $CONFIG
+fi
+
+# Check
+if [ -z "$URLFILE" ] || [ ! -e "$URLFILE" ]; then
+  URLFILE="/dev/stdout"
+fi
+
+# Dispatch
+urlinfo $* >> $URLFILE