You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Plex-Meta-Manager/modules/reciperr.py

40 lines
1.4 KiB

from modules import util
from modules.util import Failed
logger = util.logger
builders = ["reciperr_list", "stevenlu_popular"]
stevenlu_url = "https://s3.amazonaws.com/popular-movies/movies.json"
class Reciperr:
def __init__(self, config):
self.config = config
def _request(self, url, name="Reciperr"):
response = self.config.get(url)
if response.status_code >= 400:
raise Failed(f"{name} Error: JSON not found at {url}")
return response.json()
def validate_list(self, data):
valid_lists = []
for reciperr_list in util.get_list(data, split=False):
if "imdb_id" not in self._request(reciperr_list)[0]:
raise Failed(f"Reciperr Error: imdb_id not found in the JSON at {reciperr_list}")
valid_lists.append(reciperr_list)
return valid_lists
def get_imdb_ids(self, method, data):
name = "StevenLu" if method == "stevenlu_popular" else "Reciperr"
logger.info(f"Processing {name} Movies")
if method == "reciperr_list":
ids = [(i["imdb_id"], "imdb") for i in self._request(data)]
elif method == "stevenlu_popular":
ids = [(i["imdb_id"], "imdb") for i in self._request(stevenlu_url, name="StevenLu")]
else:
raise Failed(f"Config Error: Method {method} not supported")
if not ids:
raise Failed(f"{name} Error: No IDs found.")
return ids