Skip to content

Commit

Permalink
#317 added stevenlu_popular
Browse files Browse the repository at this point in the history
  • Loading branch information
meisnate12 committed Aug 2, 2021
1 parent ede0325 commit 9d89d36
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 4 deletions.
11 changes: 8 additions & 3 deletions modules/builder.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -58,10 +58,10 @@
}
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"
]
Expand Down Expand Up @@ -506,6 +506,7 @@ def cant_interact(attr1, attr2, fail=False):
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)
Expand Down Expand Up @@ -826,6 +827,9 @@ def _plex(self, method_name, method_data):
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, {
Expand Down Expand Up @@ -1032,6 +1036,7 @@ def check_map(input_ids):
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")
Expand Down
2 changes: 2 additions & 0 deletions modules/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
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
Expand Down Expand Up @@ -274,6 +275,7 @@ def check_for_attribute(data, attribute, parent=None, test_list=None, default=No
self.AniList = AniList(self)
self.Letterboxd = Letterboxd(self)
self.ICheckMovies = ICheckMovies(self)
self.StevenLu = StevenLu(self)

util.separator()

Expand Down
32 changes: 32 additions & 0 deletions modules/stevenlu.py
Original file line number Diff line number Diff line change
@@ -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, []
2 changes: 1 addition & 1 deletion modules/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def retry_if_not_plex(exception):
"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",
Expand Down

0 comments on commit 9d89d36

Please sign in to comment.