Skip to content

Instantly share code, notes, and snippets.

@ajkis
Created January 2, 2019 17:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ajkis/cefe059eba6f13ea2c9d924c22069bc7 to your computer and use it in GitHub Desktop.
Save ajkis/cefe059eba6f13ea2c9d924c22069bc7 to your computer and use it in GitHub Desktop.
#!/bin/bash
RadarrDB="/home/plex/.config/Radarr/nzbdrone.db"
Url="http://XXX.XXX.XXX.XXX:7878"
ApiKey="XXXX"
Counter=0
readarray -t MOVIES < <(sqlite3 "$RadarrDB" "SELECT id from Movies WHERE MovieFileId NOT IN (SELECT id FROM MovieFiles)")
echo "Deleting missing Movies where Year is older then X"
for movieid in "${MOVIES[@]}"
do
Counter=$(($Counter +1 ))
echo "Processing: $(sqlite3 "$RadarrDB" "SELECT id, title, Year from Movies WHERE id = '$movieid'")"
curl {$Url}/api/movie/$movieid -X DELETE -H "X-Api-Key: $ApiKey"
done
echo "Processed $Counter movies"
exit
@ajkis
Copy link
Author

ajkis commented Jan 2, 2019

wrong echo
echo "Deleting missing Movies where Year is older then X"

right one
echo "Deleting all wanted & missing movies"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment