blob: 6ef5ef8c0344038031218756bd2150bc53e3683c (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
#!/bin/sh
MUSIC_DIR="${HOME}/music"
MUSIC_LIST=
MUSIC_FILE=
MUSIC_YT_OPTIONS=
log() {
echo "[${0} ] ${@}"
}
main() {
# arguments
while getopts "c:" arg; do
case "${arg}" in
c)
MUSIC_FILE="${OPTARG}"
;;
h)
exit 0
;;
esac
done
# ensure parameters are correct
[ ! -f "${MUSIC_FILE}" ] && exit 1
while read -r line; do
# skip comments
line=$(echo ${line} | grep -v -e "^$" -e "^#")
[ -z "${line}" ] && continue
# retrieve playlist params
url=$(echo "${line}" | cut -d " " -f 1)
dir=$(echo "${line}" | cut -d " " -f 2)
dir="${MUSIC_DIR}/${dir}"
[ -d "${dir}" ] &&
log "${dir}: directory already exists" &&
continue
mkdir "${dir}"
log "${dir} ${url}: download"
yt-dlp --rm-cache-dir >/dev/null
yt-dlp \
--extract-audio \
--audio-format mp3 \
--prefer-ffmpeg \
--audio-quality 0 \
--embed-thumbnail \
--metadata-from-title "%(artist)s - %(title)s" \
--no-warnings \
--ignore-errors \
--no-overwrites \
--continue \
--add-metadata \
--user-agent "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)" \
--output "${dir}/'%(title)s.%(ext)s'" \
"${url}"
done < "${MUSIC_FILE}"
}
main ${@}
|