Created
May 27, 2021 09:59
-
-
Save marcus-crane/ccf5c5966ae69f4b7a7efed274ff2963 to your computer and use it in GitHub Desktop.
A hacky script for tagging films in Radarr that can be streamed on Netflix
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
from justwatch import JustWatch | |
from pyarr import RadarrAPIv3 | |
client = JustWatch(country='NZ') # change to your country code | |
BASE_URL = 'http://192.168.1.100:7878' | |
API_KEY = '<api_key_here>' | |
FILMS_ON_NETFLIX = {} | |
radarr = RadarrAPIv3(BASE_URL, API_KEY) | |
HEADERS = { | |
'accept': 'application/json', | |
'content-type': 'application/json', | |
'user-agent': 'netflix tagger', | |
} | |
def check_netflix_availability(title, release_year): | |
results = client.search_for_item(query=title, content_types=['movie'])['items'] | |
if len(results): | |
film = results[0] | |
if film.get('original_release_year') != release_year: | |
print(f"Wanted {title} [{release_year}]. Found {title} [{film.get('original_release_year')}]") | |
return False | |
if not film.get('offers'): | |
print(f"No way to stream {title}") | |
return False | |
for provider in film['offers']: | |
if provider['provider_id'] == 8: | |
return True | |
return False | |
for film in radarr.get_movie(): | |
tmdb = film.get('tmdbId') | |
title = film.get('title') | |
release_year = film.get('year') | |
if check_netflix_availability(title, release_year): | |
movie = radarr.get_movie(tmdb)[0] | |
movie['monitored'] = False | |
movie['tags'] = [3] # TODO: Retain tags previously existing | |
radarr.update_movie(movie) | |
print(f"{title} is on Netflix. Tagged and unmonitored.") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment