commit fdb4fc86c608bf26538e7bdd9959f24871c6acce
parent bcdd51f749edde09ded928358851b985c3528f12
Author: Anders Damsgaard <anders@adamsgaard.dk>
Date: Fri, 22 Feb 2019 12:17:12 +0100
Attempt to automatically read album and artist info
Diffstat:
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/links/bin/youtube-dl-music.sh b/links/bin/youtube-dl-music.sh
@@ -15,13 +15,13 @@ outputdir="$(mktemp -d)"
mkdir -p "$outputdir"
cd "$outputdir"
-$prefix youtube-dl \
+album="$($prefix youtube-dl \
--format bestaudio \
--extract-audio \
--audio-quality 0 \
--audio-format mp3 \
--output "%(playlist_index)s - %(title)s.%(ext)s" \
- "$1"
+ "$1" | tee /dev/tty | grep 'Finished downloading' | sed 's/.*: //')"
read -p "add metadata? [Y/n] " -n 1 -r
echo
@@ -32,7 +32,7 @@ if [[ $REPLY =~ ^[Nn]$ ]]; then
else
artist="Unknown Artist"
- album="Unknown Album"
+ album="${album:-Unknown Album}"
track=1
# Loop over files with spaces
@@ -42,13 +42,14 @@ else
echo -e "\033[0;31m$f\033[0m"
- song=$(echo "$f" | sed 's/.*-//' | sed 's/^ //' | sed 's/\.mp3//')
+ song=$(echo "$f" | sed 's/.* - //' | sed 's/^ //' | sed 's/\.mp3//')
read -r -p "song [$song]: " input
song="${input:-$song}"
read -r -p "track [$track]: " input
track="${input:-$track}"
+ artist=$(echo "$f" | sed 's/^[0-9]\+ - //' | sed 's/ - .*//' | sed 's/^ //')
read -r -p "album [$album]: " input
album="${input:-$album}"