Skip to content

Instantly share code, notes, and snippets.

@luckylittle
Created August 28, 2022 10:58
Show Gist options
  • Save luckylittle/c367ca59844b178ef97cb4b8555662e2 to your computer and use it in GitHub Desktop.
Save luckylittle/c367ca59844b178ef97cb4b8555662e2 to your computer and use it in GitHub Desktop.
Python script to unmonitor already grabbed movies from Radarr v4.1.0.6175
#!/usr/bin/env python3
#-*- coding: utf-8 -*-
import json
import requests
import sys
import datetime
APIKEY=''
URL='http://localhost:7878/api/v3'
def unmonitor_movie(id):
movie_url = '{}/movie/{}?APIKEY={}'.format(URL, m['id'], APIKEY)
headers = {"Content-Type": "application/json; charset=utf-8"}
try:
data = requests.get(movie_url)
except Exception as e:
print('Something went wrong: {}'.format(str(e)))
sys.exit(1)
if data.status_code == 200:
movie = data.json()
movie['monitored'] = False
else:
print('Failed. Response: {}'.format(str(data.json())))
sys.exit(1)
r = requests.put(movie_url, headers=headers, data=json.dumps(movie))
if r.status_code != 202:
print('Failed. Response: {}'.format(str(r.json())))
sys.exit(1)
print('Attempting to fetch data from the API: {}'.format(URL))
try:
data = requests.get('{}/movie/?APIKEY={}'.format(URL, APIKEY))
except Exception as e:
print('Something went wrong: {}'.format(str(e)))
sys.exit(1)
if data.status_code != 200:
print('Failed. Response: {}'.format(mdatajson()))
sys.exit(1)
else:
movies = data.json()
for m in movies:
try:
history = requests.get('{}/history/movie?movieId={}&eventType=grabbed&apikey={}'.format(URL, m['id'], APIKEY))
except Exception as e:
print('Something went wrong: {}'.format(str(e)))
sys.exit(1)
if history.status_code != 200:
print('Failed. Response: {}'.format(mdatajson()))
sys.exit(1)
else:
h = history.json()
if h:
for id in h:
unmonitor_movie(id['id'])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment