From 9a3b64e6fbf5dc7d65a25ce878e5e3d7984db07f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20La=C3=ADn?= Date: Sat, 21 Oct 2023 22:57:05 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat(systemd):=20new=20services=20f?= =?UTF-8?q?or=20downloading=20my=20spotify=20playlists=20with=20spotdl?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .config/systemd/user/spotdl_sync.service | 10 ++++++++++ .config/systemd/user/spotdl_sync.timer | 10 ++++++++++ .local/bin/downloadMusic | 23 +++++++++++++++++++++++ .local/bin/spotdlSync | 14 ++++++++++++++ 4 files changed, 57 insertions(+) create mode 100644 .config/systemd/user/spotdl_sync.service create mode 100644 .config/systemd/user/spotdl_sync.timer create mode 100755 .local/bin/downloadMusic create mode 100755 .local/bin/spotdlSync diff --git a/.config/systemd/user/spotdl_sync.service b/.config/systemd/user/spotdl_sync.service new file mode 100644 index 00000000..3500ab43 --- /dev/null +++ b/.config/systemd/user/spotdl_sync.service @@ -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 diff --git a/.config/systemd/user/spotdl_sync.timer b/.config/systemd/user/spotdl_sync.timer new file mode 100644 index 00000000..55592048 --- /dev/null +++ b/.config/systemd/user/spotdl_sync.timer @@ -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 diff --git a/.local/bin/downloadMusic b/.local/bin/downloadMusic new file mode 100755 index 00000000..b4f5e2c5 --- /dev/null +++ b/.local/bin/downloadMusic @@ -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" diff --git a/.local/bin/spotdlSync b/.local/bin/spotdlSync new file mode 100755 index 00000000..75b9f227 --- /dev/null +++ b/.local/bin/spotdlSync @@ -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"