#317 added stevenlu_popular

This commit is contained in:
meisnate12 2021-07-31 21:23:17 -04:00
parent ede0325224
commit 9d89d36c2c
4 changed files with 43 additions and 4 deletions

View file

@ -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")

View file

@ -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()

32
modules/stevenlu.py Normal file
View file

@ -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, []

View file

@ -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",