feat(systemd): new services for downloading my spotify playlists with spotdl

This commit is contained in:
Sergio Laín 2023-10-21 22:57:05 +02:00
parent f73837a4ff
commit 9a3b64e6fb
No known key found for this signature in database
GPG key ID: 14C9B8080681777B
4 changed files with 57 additions and 0 deletions

View file

@ -0,0 +1,10 @@
[Unit]
Description=Download music using spotdl
After=network.target
[Service]
Type=simple
ExecStart=/home/matt/.local/bin/downloadMusic
[Install]
WantedBy=default.target

View file

@ -0,0 +1,10 @@
[Unit]
Description=Run Spotdl Sync Weekly
[Timer]
OnCalendar=Sun 18:00:00
Persistent=true
Unit=spotdl_sync.service
[Install]
WantedBy=timers.target

23
.local/bin/downloadMusic Executable file
View file

@ -0,0 +1,23 @@
#!/usr/bin/bash
if ! command -v spotdl &>/dev/null; then
notify-send "Spotdl Sync" "Error: spotdl is not installed"
exit 1
fi
FOLDERS=(
"EDM-House"
"Metal-Rock"
"Synth-Chill"
"Lofi-Sleppy"
"Space-Cyberpunk"
"Cyberpunk-Darksynth"
)
notify-send "Spotdl Sync" "Started syncing..."
for folder in "${FOLDERS[@]}"; do
spotdlSync "$folder"
done
notify-send "Spotdl Sync Complete"

14
.local/bin/spotdlSync Executable file
View file

@ -0,0 +1,14 @@
#!/usr/bin/bash
FOLDER=$1
if [ ! -d "$HOME/Musica/Listen-To/$FOLDER" ]; then
notify-send "Spotdl Sync" "The folder $FOLDER doesnt exist"
exit 1
fi
cd "$HOME/Musica/Listen-To/$FOLDER"
spotdl sync "${FOLDER,,}.sync.spotdl"
notify-send "Spotdl Sync" "$FOLDER synced"