commit fe6c5389079b82a72344f10bd062cbe8af123958 Author: Zdeněk Borovec <46405012+Zeftax@users.noreply.github.com> Date: Sun Dec 12 13:43:07 2021 +0100 initial commit diff --git a/PKGBUILD b/PKGBUILD new file mode 100644 index 0000000..e48371f --- /dev/null +++ b/PKGBUILD @@ -0,0 +1,14 @@ +pkgname="album-dl" +pkgver="1.0.0" +pkgrel="1" +pkgdesc="Downloads a playlist using youtube-dl as mp3s and sets some metadata tags for the whole album" +arch=("x86_64") +depends=("youtube-dl" "ffmpeg") +license=("GPLv2") +source=("album-dl.sh") +sha512sums=("SKIP") +package() { + mkdir -p "${pkgdir}/usr/bin" + cp "${srcdir}/album-dl.sh" "${pkgdir}/usr/bin/album-dl" + chmod +x "${pkgdir}/usr/bin/album-dl" +} diff --git a/album-dl.sh b/album-dl.sh new file mode 100644 index 0000000..62ffeb5 --- /dev/null +++ b/album-dl.sh @@ -0,0 +1,43 @@ +#!/bin/sh + +#request the url of the playlist +echo -n 'playlist url: ' +read url + +#request the name of the artist +echo -n 'artist name: ' +read artist + +#request the name of the album +echo -n 'album name: ' +read album + +mkdir "${album}" +cd "${album}" + +#stack overflow said this would fix a 403 error that youtube-dl sometimes throws at me +youtube-dl --rm-cache-dir + +#download the files using youtube-dl +youtube-dl -o "%(playlist_index)sඞ%(title)s.%(ext)s" --extract-audio --audio-format mp3 "$url" + +#loop through all files +for file in * +do + #split the filename by the sussy symbol. take the 0th element and store it as the track number for mp3. then concatenate the rest back together and rename the file + IFS='ඞ' + read -a arrfile <<< $file + track="${arrfile[0]}" + arrfile=("${arrfile[@]:1}") + newfilename='' + for namepart in "${arrfile[@]}"; + do + newfilename+="$namepart" + done + mv "$file" "$newfilename" + file="$newfilename" + + #use ffmpeg to set the title, artist, track number, and album name to a new file, then rewrite the old file with the new file + ffmpeg -i "$file" -metadata title="$file" -metadata artist="$artist" -metadata album="$album" -metadata track="$track" "${file}_changed.mp3" + mv "${file}_changed.mp3" "$file" +done