From 4d898c9116331ea3b17d0caa3f6a00ec4225bc45 Mon Sep 17 00:00:00 2001 From: Gabriel Arazas Date: Fri, 30 Apr 2021 22:21:11 +0800 Subject: [PATCH] Revise personal scripts again --- bin/convert-newpipe-db | 7 ++++--- bin/split-album | 29 +++++++++++++++-------------- 2 files changed, 19 insertions(+), 17 deletions(-) diff --git a/bin/convert-newpipe-db b/bin/convert-newpipe-db index 088b4ee..af1dfa6 100755 --- a/bin/convert-newpipe-db +++ b/bin/convert-newpipe-db @@ -17,11 +17,11 @@ shopt -s strict:all var FILENAME = $1 # Testing if the given file is a zip file. -file $FILENAME | rg "Zip archive data" --quiet || exit 1 +file --mime $FILENAME | rg "application/zip" --quiet || exit 1 +var channel_id_eggex = / 'https://www.youtube.com/channel/' (word) / var NEWPIPE_DB = "newpipe.db" var TEMP_FOLDER_NAME = "newpipe" -var channel_id_eggex = / 'https://www.youtube.com/channel/' (word) / var NEWPIPE_DB_QUERY = "SELECT name, url, service_id, group_concat(tag, ',') AS tags FROM (SELECT subscriptions.name, subscriptions.url, subscriptions.service_id, '/' || feed_group.name AS tag FROM subscriptions LEFT JOIN feed_group_subscription_join AS subs_join @@ -43,7 +43,7 @@ OPML # Simply prints an `` element formatted approriately for the resulting output. # Don't mind how it is printed right now. :) proc print-outline(title, xml_url, html_url, tags = "") { - printf ' &2 printf "${msg}\\n" @args } -proc errorf(msg, @args) { +proc errorf(msg, @args, exit_code = 1) { >&2 printf "${msg}\\n" @args - exit 1 + exit ${exit_code} } proc prompt(msg, :out, prefix = ">> ") { @@ -192,7 +193,7 @@ case $(file --mime-type --brief $timestamp_file) { # Also cleans up the timestamp file with comments and empty lines. # I just want to improve the timestamp format (a little bit). "text/plain") - cat $timestamp_file | sed --regexp-extended --expression '/^\s*$/d' --expression '/^#/d' | while read --line { + sed --file $timestamp_file --regexp-extended --expression '/^\s*$/d' --expression '/^#/d' | while read --line { var chapter = {} set chapter['title'] = $(write -- $_line | cut -d' ' -f2-) set chapter['timestamp'] = $(write -- $_line | cut -d' ' -f1)