Skip to content

Commit

Permalink
feat!: add snapdiff, custom dist path
Browse files Browse the repository at this point in the history
  • Loading branch information
danztran committed Dec 21, 2020
1 parent 713e351 commit 90abba2
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ sources.txt

.DS_Store
*.log
.tmp
.vscode
26 changes: 23 additions & 3 deletions metube
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit 90abba2

Please sign in to comment.