Thank you for your donation!


Cloudsmith graciously provides open-source package management and distribution for our project.


Shared playlist on NAS?
#11
Hi @Tim Curtis,

The final working solution is:
1) Exclude the playlists from the backup. This is optional
2) Run the script I made. 

The script removes everything ( when "all" as argument) and creates symlinks to the playlists and playlist covers on the NAS, or just replaces local files with symlinks to the NAS content

Code:
#!/bin/bash
DESTINATION_FOLDER_PLAYLISTS=/var/lib/mpd/playlists
DESTINATION_FOLDER_PLAYLIST_COVERS=/var/local/www/imagesw/playlist-covers

# all as argument removes everything
if [[ "$1" == "all" ]]
then
   echo "Removing all playlists and playlist covers"
   sudo rm $DESTINATION_FOLDER_PLAYLISTS/*.m3u 2>/dev/null
   sudo rm $DESTINATION_FOLDER_PLAYLIST_COVERS/*.jpg 2>/dev/null
fi


# Playlists
echo "Patch playlists"
SOURCE_FOLDER=/mnt/NAS/Music/Playlists/*.m3u
for filepath in $SOURCE_FOLDER; do
       file=$(basename -- "$filepath")
       symlink_file="$DESTINATION_FOLDER_PLAYLISTS/$file"
       sudo rm "$symlink_file" 2>/dev/null
       sudo ln -s "$filepath" "$symlink_file"
done


# Playlist covers
echo "Patch playlist covers"
SOURCE_FOLDER=/mnt/NAS/Music/Playlists/*.jpg
for filepath in $SOURCE_FOLDER; do
       file=$(basename -- "$filepath")
       symlink_file="$DESTINATION_FOLDER_PLAYLIST_COVERS/$file"
       sudo rm "$symlink_file" 2>/dev/null
       sudo ln -s "$filepath" "$symlink_file"
done
Reply
#12
Nice.

Gotta admit my option 2 looks pretty janky in actual use Angry

Regards,
Kent
Reply


Forum Jump: