I buy a lot of digital albums for which I don't know the majority of the tracks - I simply throw all of these into the server and play. Inevitably, I find many tracks that are not my taste and want to remove them from the server's library.
The server provides means to "mark" a track for attention, whether that's to delete, reencode, review etc and this is achieved via the REST call "http://server:3689/api/library/tracks/{id}?usermark=1" - it is not currently available via the official web ui but can be added the queue list or now playing modal via a simply patch below.
With the tracks marked, I have a cronjob that periodically removes files older than 30days - these tracks are reviewable by the SMARTpl
.
Accompanying the cronjob is a smartpl
that allows us to easily see the tracks that have been marked for review (and subsequent delete).
The following assume that the library's music directory is /export/music
- crontab script
#!/bin/bash
readarray -t DIRT < <(curl -s "http://localhost:3689/api/search?type=tracks&expression=usermark+>+0" | jq -r ".tracks.items[] | select(.time_modified | fromdateiso8601 < $(date +%s --date="30days ago")) | .path" )
N=${#DIRT[@]}
if [ $N -eq 0 ]; then
echo "no data"
exit 0
fi
for ((i=0; i<${N}; i++)); do
FILE=${DIRT[$i]}
[ ! -f "$FILE" ] && continue
sudo rm "${FILE}"
done
- smartpl
"_Delete / Review Tracks" {
usermark = 1
order by time_modified desc
}
- webui patch (see PR https://github.com/owntone/owntone-server/pull/1315)