-
-
Save memesalot/e6636cfbdcafc0a58665bc669631c9d9 to your computer and use it in GitHub Desktop.
search wanted on radarr / sonarr
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| RADARR_API_URL="http://radarr.com/api" | |
| RADARR_API_KEY="PUT_YOUR_API_KEY_HERE" | |
| history=$(curl -s ${RADARR_API_URL}/history?page=1\&pageSize=20\&sortKey=date\&sortDir=desc -H "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7" -X GET -H 'X-Api-Key: '$RADARR_API_KEY'' -k) | |
| history=$(echo $history | tr -d '\n' | tr -d '\r' | tr -d '\b') | |
| grabbed=$(echo $history | jq '.records | .[] | select(.movie.monitored) | select(.movie.downloaded | not) | select(.eventType=="grabbed") | .movieId') | |
| grabbed=$(echo $grabbed | sed 's/ /, /g') | |
| grabbed="[${grabbed}]" | |
| movies=$(curl -s ${RADARR_API_URL}/movie -X GET -H 'X-Api-Key: '$RADARR_API_KEY'') | |
| movies=$(echo $movies | tr -d '\n' | tr -d '\r' | tr -d '\b') | |
| wanted=$(echo $movies | jq --argjson blacklist "$grabbed" '.[] | select(.monitored) | select(.downloaded | not) | select(.status!="announced") | select( .id as $in | $blacklist | index($in) | not) | .id') | |
| wanted=$(echo $wanted | sed 's/ /, /g') | |
| curl -s -H "Content-Type: application/json" -s -H 'X-Api-Key: '$RADARR_API_KEY'' -X POST -d "{\"name\": \"MoviesSearch\", \"movieIds\" : [$wanted]}" ${RADARR_API_URL}/command -k > /dev/null |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| SONARR_API_URL="http://sonarr.com/api" | |
| SONARR_API_KEY="PUT_YOUR_API_KEY_HERE" | |
| series=$(curl -s ${SONARR_API_URL}/wanted/missing?pageSize=100\&sortKey=series.title -X GET -H 'X-Api-Key: '$SONARR_API_KEY'' -k) | |
| wanted=$(echo $series | jq '.records | .[] | select(.monitored) .id') | |
| wanted=$(echo $wanted | sed 's/ /, /g') | |
| curl -s -H "Content-Type: application/json" -H 'X-Api-Key: '$SONARR_API_KEY'' -X POST -d "{\"name\": \"EpisodeSearch\", \"episodeIds\" : [$wanted]}" ${SONARR_API_URL}/command -k > /dev/null |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| RADARR_API_URL="http://radarr.com/api" | |
| RADARR_API_KEY="PUT_YOUR_API_KEY_HERE" | |
| movies=$(curl -s ${RADARR_API_URL}/movie -X GET -H 'X-Api-Key: '$RADARR_API_KEY'') | |
| movies=$(echo $movies | tr -d '\n' | tr -d '\r' | tr -d '\b') | |
| ids=$(echo $movies | jq '.[] | select(.monitored) | select(.downloaded) | .id') | |
| for id in $ids; do | |
| movie=$(echo $movies | jq --compact-output '.[] | select(.id=='$id') | .monitored = false') | |
| curl -s -H "Content-Type: application/json" -s -H 'X-Api-Key: '$RADARR_API_KEY'' -X PUT -d "$movie" ${RADARR_API_URL}/movie/$id > /dev/null | |
| done |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| SONARR_API_URL="http://sonarr.com/api" | |
| SONARR_API_KEY="PUT_YOUR_API_KEY_HERE" | |
| showsHistory=$(curl ${SONARR_API_URL}/history?page=1\&pageSize=1000\&sortKey=date\&sortDir=desc -X GET -H 'X-Api-Key: '$SONARR_API_KEY'' -k -s) | |
| showsHistory=$(echo $showsHistory | tr -d '\n' | tr -d '\r' | tr -d '\b') | |
| episodeIds=$(echo $showsHistory | jq '[.records[] | select(.series.monitored) | select(.episode.monitored) | select(.episode.hasFile) | .episode.id] | unique | .[]') | |
| for episodeId in $episodeIds; do | |
| episode=$(echo $showsHistory | jq --compact-output '[.records[] | select(.episodeId=='$episodeId') | .episode | select(.id=='$episodeId') | .monitored = false][0]') | |
| curl -s -H "Content-Type: application/json" -s -H 'X-Api-Key: '$SONARR_API_KEY'' -X PUT -d "$episode" ${SONARR_API_URL}/episode > /dev/null | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment