diff --git a/bin/choose-emoji-menu b/bin/choose-emoji-menu index 644b191..e1cd2bb 100755 --- a/bin/choose-emoji-menu +++ b/bin/choose-emoji-menu @@ -13,9 +13,12 @@ # * xclip - version 0.13 emoji_file="${XDG_DATA_HOME:-$HOME/.local/share}/emoji-list.txt" -if [[ ! -f $emoji_file ]]; then + +# Checks if the emoji file is non-existent or past its modification date of at least 30 days ago (2592000 seconds). +if [[ ! -f $emoji_file ]] || test $(expr $(date "+%s") - $(date --reference="$emoji_file" "+%s")) -gt 2592000; then notify-send "Downloading the emoji data file." - wget --output-document "$emoji_file" https://unicode.org/Public/emoji/13.0/emoji-test.txt + wget --output-document "$emoji_file" https://unicode.org/Public/emoji/latest/emoji-test.txt + touch $emoji_file fi selection=$(awk 'match($0, /([0-9A-F ]+)\s+; fully-qualified\s+# (\S+) E[[:digit:]]+.[[:digit:]]+ (.+)$/, a){print a[2], a[3]}' "$emoji_file" \ diff --git a/bin/convert-newpipe-db b/bin/convert-newpipe-db new file mode 100755 index 0000000..d7a75b9 --- /dev/null +++ b/bin/convert-newpipe-db @@ -0,0 +1,60 @@ +#!/usr/bin/env osh + +# Convert a Newpipe database (assuming it was exported within the app) into OPML. + +# Dependencies: +# * osh (oil shell) v0.8.5 +# * sqlite3 v3.34.0 +# * unzip +# * ripgrep v12.1.1 +# * jq + +# Use the current Oil features in strict mode. +# This also enables usage of the syntax. +shopt -s strict:all oil:all + +var FILENAME = $1 + +# Testing if the given file is a zip file. +file $FILENAME | rg "Zip archive data" --quiet || exit 1 + +var channel_id_eggex = / 'https://www.youtube.com/channel/' (word) / +var NEWPIPE_DB = "newpipe.db" +var TEMP_FOLDER_NAME = "newpipe" + +# Print the beginning of the template. +cat < + + Newpipe subscriptions + $(date "+%F %T %z") + $(whoami) + http://dev.opml.org/spec2.html + + +OPML + +# Print the channels in the OPML body. +# This only occurs if the given file does have a Newpipe database. +if unzip -l $FILENAME | rg --quiet $NEWPIPE_DB { + mkdir $TEMP_FOLDER_NAME && unzip -q -u $FILENAME -d $TEMP_FOLDER_NAME + trap "rm --recursive $TEMP_FOLDER_NAME" EXIT + while read channel { + echo $channel | json read :channel + setvar name = channel['name'] + setvar url = channel['url'] + + # The channel ID should only match YouTube channel URLs. + setvar channel_id = $(echo $url | sed --quiet --regexp-extended "s|$channel_id_eggex|\\1|p") + + if test -z $channel_id { continue } + + echo " " + } <<< $(sqlite3 "$TEMP_FOLDER_NAME/$NEWPIPE_DB" "SELECT name, url FROM subscriptions" --csv --header | dasel select --parser csv --multiple --selector '.[*]' --compact --write json) +} + +# Print the remaining parts of the document. +cat < + +OPML diff --git a/bin/generate-gitignore b/bin/generate-gitignore index 8129a49..cb51995 100755 --- a/bin/generate-gitignore +++ b/bin/generate-gitignore @@ -7,6 +7,7 @@ # * bash # * curl # * fzf +# * jq # * paste # * xargs