From 9d89d36c2c4438c1da4482e833029ee2ef47192c Mon Sep 17 00:00:00 2001 From: meisnate12 Date: Sat, 31 Jul 2021 21:23:17 -0400 Subject: [PATCH] #317 added stevenlu_popular --- modules/builder.py | 11 ++++++++--- modules/config.py | 2 ++ modules/stevenlu.py | 32 ++++++++++++++++++++++++++++++++ modules/util.py | 2 +- 4 files changed, 43 insertions(+), 4 deletions(-) create mode 100644 modules/stevenlu.py diff --git a/modules/builder.py b/modules/builder.py index 31bb0a3e..43cc4931 100644 --- a/modules/builder.py +++ b/modules/builder.py @@ -1,6 +1,6 @@ import logging, os, re from datetime import datetime, timedelta -from modules import anidb, anilist, icheckmovies, imdb, letterboxd, mal, plex, radarr, sonarr, tautulli, tmdb, trakt, tvdb, util +from modules import anidb, anilist, icheckmovies, imdb, letterboxd, mal, plex, radarr, sonarr, stevenlu, tautulli, tmdb, trakt, tvdb, util from modules.util import Failed, ImageData from PIL import Image from plexapi.exceptions import BadRequest, NotFound @@ -58,10 +58,10 @@ filter_translation = { } modifier_alias = {".greater": ".gt", ".less": ".lt"} all_builders = anidb.builders + anilist.builders + icheckmovies.builders + imdb.builders + letterboxd.builders + \ - mal.builders + plex.builders + tautulli.builders + tmdb.builders + trakt.builders + tvdb.builders + mal.builders + plex.builders + stevenlu.builders + tautulli.builders + tmdb.builders + trakt.builders + tvdb.builders show_only_builders = ["tmdb_network", "tmdb_show", "tmdb_show_details", "tvdb_show", "tvdb_show_details"] movie_only_builders = [ - "letterboxd_list", "letterboxd_list_details", "icheckmovies_list", "icheckmovies_list_details", + "letterboxd_list", "letterboxd_list_details", "icheckmovies_list", "icheckmovies_list_details", "stevenlu_popular", "tmdb_collection", "tmdb_collection_details", "tmdb_movie", "tmdb_movie_details", "tmdb_now_playing", "tvdb_movie", "tvdb_movie_details" ] @@ -506,6 +506,7 @@ class CollectionBuilder: elif method_name in imdb.builders: self._imdb(method_name, method_data) elif method_name in mal.builders: self._mal(method_name, method_data) elif method_name in plex.builders or method_final in plex.searches: self._plex(method_name, method_data) + elif method_name in stevenlu.builders: self._stevenlu(method_name, method_data) elif method_name in tautulli.builders: self._tautulli(method_name, method_data) elif method_name in tmdb.builders: self._tmdb(method_name, method_data) elif method_name in trakt.builders: self._trakt(method_name, method_data) @@ -826,6 +827,9 @@ class CollectionBuilder: else: self.builders.append(("plex_search", self.build_filter("plex_search", {"any": {method_name: method_data}}))) + def _stevenlu(self, method_name, method_data): + self.builders.append((method_name, util.parse(method_name, method_data, "bool"))) + def _tautulli(self, method_name, method_data): for dict_data, dict_methods in util.parse(method_name, method_data, datatype="dictlist"): self.builders.append((method_name, { @@ -1032,6 +1036,7 @@ class CollectionBuilder: elif "imdb" in method: check_map(self.config.IMDb.get_items(method, value, self.language, self.library.is_movie)) elif "icheckmovies" in method: check_map(self.config.ICheckMovies.get_items(method, value, self.language)) elif "letterboxd" in method: check_map(self.config.Letterboxd.get_items(method, value, self.language)) + elif "stevenlu" in method: check_map(self.config.StevenLu.get_items(method)) elif "tmdb" in method: check_map(self.config.TMDb.get_items(method, value, self.library.is_movie)) elif "trakt" in method: check_map(self.config.Trakt.get_items(method, value, self.library.is_movie)) else: logger.error(f"Collection Error: {method} method not supported") diff --git a/modules/config.py b/modules/config.py index e9232222..c055c88d 100644 --- a/modules/config.py +++ b/modules/config.py @@ -14,6 +14,7 @@ from modules.omdb import OMDb from modules.plex import Plex from modules.radarr import Radarr from modules.sonarr import Sonarr +from modules.stevenlu import StevenLu from modules.tautulli import Tautulli from modules.tmdb import TMDb from modules.trakt import Trakt @@ -274,6 +275,7 @@ class Config: self.AniList = AniList(self) self.Letterboxd = Letterboxd(self) self.ICheckMovies = ICheckMovies(self) + self.StevenLu = StevenLu(self) util.separator() diff --git a/modules/stevenlu.py b/modules/stevenlu.py new file mode 100644 index 00000000..85404b5f --- /dev/null +++ b/modules/stevenlu.py @@ -0,0 +1,32 @@ +import logging +from modules import util +from modules.util import Failed + +logger = logging.getLogger("Plex Meta Manager") + +builders = ["stevenlu_popular"] +base_url = "https://s3.amazonaws.com/popular-movies/movies.json" + +class StevenLu: + def __init__(self, config): + self.config = config + + def get_items(self, method): + pretty = util.pretty_names[method] if method in util.pretty_names else method + movie_ids = [] + fail_ids = [] + if method == "stevenlu_popular": + logger.info(f"Processing {pretty} Movies") + for i in self.config.get_json(base_url): + tmdb_id = self.config.Convert.imdb_to_tmdb(i["imdb_id"]) + if tmdb_id: + movie_ids.append(tmdb_id) + else: + logger.error(f"Convert Error: No TMDb ID found for IMDb: {i['imdb_id']}") + fail_ids.append(i["imdb_id"]) + else: + raise Failed(f"StevenLu Error: Method {method} not supported") + logger.debug("") + logger.debug(f"{len(fail_ids)} IMDb IDs Failed to Convert: {fail_ids}") + logger.debug(f"{len(movie_ids)} TMDb IDs Found: {movie_ids}") + return movie_ids, [] diff --git a/modules/util.py b/modules/util.py index bb06df7d..19fd322b 100644 --- a/modules/util.py +++ b/modules/util.py @@ -67,7 +67,7 @@ pretty_names = { "mal_favorite": "MyAnimeList Favorite", "mal_season": "MyAnimeList Season", "mal_suggested": "MyAnimeList Suggested", "mal_userlist": "MyAnimeList Userlist", "plex_all": "Plex All", "plex_collection": "Plex Collection", "plex_search": "Plex Search", - "tautulli_popular": "Tautulli Popular", "tautulli_watched": "Tautulli Watched", + "stevenlu_popular": "Steven Lu Popular", "tautulli_popular": "Tautulli Popular", "tautulli_watched": "Tautulli Watched", "tmdb_actor": "TMDb Actor", "tmdb_actor_details": "TMDb Actor", "tmdb_collection": "TMDb Collection", "tmdb_collection_details": "TMDb Collection", "tmdb_company": "TMDb Company", "tmdb_crew": "TMDb Crew", "tmdb_crew_details": "TMDb Crew",