From 90abba2faec5daa91e6249546aa3c943374d0a45 Mon Sep 17 00:00:00 2001 From: danztran Date: Mon, 21 Dec 2020 12:08:44 +0700 Subject: [PATCH] feat!: add snapdiff, custom dist path --- .gitignore | 2 ++ metube | 26 +++++++++++++++++++++++--- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 2737f0b..a52267a 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,5 @@ sources.txt .DS_Store *.log +.tmp +.vscode diff --git a/metube b/metube index af1ac76..3a7091c 100755 --- a/metube +++ b/metube @@ -6,15 +6,35 @@ main() { download() { local src_file="$1" + local dist="$2" + [ -z "$dist" ] && dist="dist" cat $src_file | while read src do local playlist=`echo $src | awk -F , '{print $1}'` local link=`echo $src | awk -F , '{print $2}'` echo \> playlist $playlist - link $link - mkdir -p "./dist" "./dist/$playlist" - youtube-dl -cix --add-metadata --download-archive "./dist/$playlist/.archive" --audio-format mp3 -o "./dist/$playlist/%(title)s.%(ext)s" "$link" - eyed3 -A "$playlist" -G "$playlist" "./dist/$playlist" + mkdir -p "$dist" "$dist/$playlist" + youtube-dl -cix --add-metadata --download-archive "$dist/$playlist/.archive" --audio-format mp3 -o "$dist/$playlist/%(title)s.%(ext)s" "$link" + eyed3 -A "$playlist" -G "$playlist" "$dist/$playlist" done + snapdiff $dist +} + +snapdiff() { + local dist="$1" + local ts=`date '+%F %H:%M:%S'` + local snapshot="$dist/snapshot" + local snapshot_old="$dist/snapshot_old" + echo > $snapshot_old + [ -f "$snapshot" ] && mv -f "$snapshot" "$snapshot_old" + printf "$ts\n---\n" > "$snapshot" + snap "$dist" >> "$snapshot" + git diff --no-index "$snapshot_old" "$snapshot" > "$dist/update" +} + +snap() { + local dist="$1" + find $dist -type f -name '*.mp3' | sed "s|^$dist/||" } install() {