initial commit
This commit is contained in:
commit
fe6c538907
2 changed files with 57 additions and 0 deletions
14
PKGBUILD
Normal file
14
PKGBUILD
Normal file
|
@ -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"
|
||||
}
|
43
album-dl.sh
Normal file
43
album-dl.sh
Normal file
|
@ -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
|
Loading…
Reference in a new issue