commit 4d528c1cd6afce9042ef723b2421d248efd021ab
parent 6ba30e5bc63d82f3ec52bf2b80174586bc87e441
Author: lostd <lostd@2f30.org>
Date: Thu, 9 Jan 2014 14:26:47 +0200
Enable simplistic artist - title tagging
Diffstat:
1 file changed, 15 insertions(+), 4 deletions(-)
diff --git a/ytfetch b/ytfetch
@@ -9,32 +9,43 @@ if test -z "$1"; then
exit 1
fi
+# newline separated
+IFS='
+'
+
for URL in "$@"; do
echo "see $URL"
# each --get comes on a line by its own in a predefined order
# command line order does not matter
- LIST=$(youtube-dl --restrict-filenames --get-url --get-filename \
+ LIST=$(youtube-dl --restrict-filenames \
+ --get-url --get-filename --get-title \
-o "%(title)s.%(ext)s" "$URL")
I=0 # keep state
for L in $LIST; do
case $I in
0)
- DIRECT="$L"
+ ARTIST=${L%% - *}
+ TITLE=${L#* - }
;;
1)
+ DIRECT="$L"
+ ;;
+ 2)
F="${L%.*}.mp3"
if test -f "$F"; then # already have this?
echo "hav $F"
else
echo "get $L"
wget "$DIRECT" -O "$L" 2> /dev/null
- ffmpeg -i "$L" "$F" 2> /dev/null
+ ffmpeg -i "$L" \
+ -metadata artist="$ARTIST" -metadata title="$TITLE" \
+ "$F" 2> /dev/null
rm "$L"
fi
;;
esac
# incr and mod with the number of --get used above
I=$(expr $I + 1)
- I=$(expr $I % 2)
+ I=$(expr $I % 3)
done
done