mirror of
https://github.com/meisnate12/Plex-Meta-Manager
synced 2024-11-10 06:54:21 +00:00
#495 added imdb_chart builder
This commit is contained in:
parent
c1e878bf33
commit
ae682e4299
2 changed files with 46 additions and 1 deletions
|
@ -974,6 +974,14 @@ class CollectionBuilder:
|
||||||
elif method_name == "imdb_list":
|
elif method_name == "imdb_list":
|
||||||
for imdb_dict in self.config.IMDb.validate_imdb_lists(method_data, self.language):
|
for imdb_dict in self.config.IMDb.validate_imdb_lists(method_data, self.language):
|
||||||
self.builders.append((method_name, imdb_dict))
|
self.builders.append((method_name, imdb_dict))
|
||||||
|
elif method_name == "imdb_chart":
|
||||||
|
for value in util.get_list(method_data):
|
||||||
|
if value in imdb.movie_charts and not self.library.is_movie:
|
||||||
|
raise Failed(f"Collection Error: chart: {value} does not work with show libraries")
|
||||||
|
elif value in imdb.show_charts and self.library.is_movie:
|
||||||
|
raise Failed(f"Collection Error: chart: {value} does not work with movie libraries")
|
||||||
|
elif value in imdb.charts:
|
||||||
|
self.builders.append((method_name, value))
|
||||||
|
|
||||||
def _letterboxd(self, method_name, method_data):
|
def _letterboxd(self, method_name, method_data):
|
||||||
if method_name.startswith("letterboxd_list"):
|
if method_name.startswith("letterboxd_list"):
|
||||||
|
|
|
@ -5,7 +5,20 @@ from urllib.parse import urlparse, parse_qs
|
||||||
|
|
||||||
logger = logging.getLogger("Plex Meta Manager")
|
logger = logging.getLogger("Plex Meta Manager")
|
||||||
|
|
||||||
builders = ["imdb_list", "imdb_id"]
|
builders = ["imdb_list", "imdb_id", "imdb_chart"]
|
||||||
|
movie_charts = ["box_office", "popular_movies", "top_movies", "top_english", "top_indian", "lowest_rated"]
|
||||||
|
show_charts = ["popular_shows", "top_shows"]
|
||||||
|
charts = {
|
||||||
|
"box_office": "Box Office",
|
||||||
|
"popular_movies": "Most Popular Movies",
|
||||||
|
"popular_shows": "Most Popular TV Shows",
|
||||||
|
"top_movies": "Top 250 Movies",
|
||||||
|
"top_shows": "Top 250 TV Shows",
|
||||||
|
"top_english": "Top Rated English Movies",
|
||||||
|
"top_indian": "Top Rated Indian Movies",
|
||||||
|
"lowest_rated": "Lowest Rated Movies"
|
||||||
|
}
|
||||||
|
|
||||||
base_url = "https://www.imdb.com"
|
base_url = "https://www.imdb.com"
|
||||||
urls = {
|
urls = {
|
||||||
"lists": f"{base_url}/list/ls",
|
"lists": f"{base_url}/list/ls",
|
||||||
|
@ -96,6 +109,27 @@ class IMDb:
|
||||||
return imdb_ids
|
return imdb_ids
|
||||||
raise Failed(f"IMDb Error: No IMDb IDs Found at {imdb_url}")
|
raise Failed(f"IMDb Error: No IMDb IDs Found at {imdb_url}")
|
||||||
|
|
||||||
|
def _ids_from_chart(self, chart):
|
||||||
|
if chart == "box_office":
|
||||||
|
url = "chart/boxoffice"
|
||||||
|
elif chart == "popular_movies":
|
||||||
|
url = "chart/moviemeter"
|
||||||
|
elif chart == "popular_shows":
|
||||||
|
url = "chart/tvmeter"
|
||||||
|
elif chart == "top_movies":
|
||||||
|
url = "chart/top"
|
||||||
|
elif chart == "top_shows":
|
||||||
|
url = "chart/toptv"
|
||||||
|
elif chart == "top_english":
|
||||||
|
url = "chart/top-english-movies"
|
||||||
|
elif chart == "top_indian":
|
||||||
|
url = "india/top-rated-indian-movies"
|
||||||
|
elif chart == "lowest_rated":
|
||||||
|
url = "chart/bottom"
|
||||||
|
else:
|
||||||
|
raise Failed(f"IMDb Error: chart: {chart} not ")
|
||||||
|
return self.config.get_html(f"https://www.imdb.com/{url}").xpath("//div[@class='wlb_ribbon']/@data-tconst")
|
||||||
|
|
||||||
def get_imdb_ids(self, method, data, language):
|
def get_imdb_ids(self, method, data, language):
|
||||||
if method == "imdb_id":
|
if method == "imdb_id":
|
||||||
logger.info(f"Processing IMDb ID: {data}")
|
logger.info(f"Processing IMDb ID: {data}")
|
||||||
|
@ -104,5 +138,8 @@ class IMDb:
|
||||||
status = f"{data['limit']} Items at " if data['limit'] > 0 else ''
|
status = f"{data['limit']} Items at " if data['limit'] > 0 else ''
|
||||||
logger.info(f"Processing IMDb List: {status}{data['url']}")
|
logger.info(f"Processing IMDb List: {status}{data['url']}")
|
||||||
return [(i, "imdb") for i in self._ids_from_url(data["url"], language, data["limit"])]
|
return [(i, "imdb") for i in self._ids_from_url(data["url"], language, data["limit"])]
|
||||||
|
elif method == "imdb_chart":
|
||||||
|
logger.info(f"Processing IMDb Chart: {charts[data]}")
|
||||||
|
return [(_i, "imdb") for _i in self._ids_from_chart(data)]
|
||||||
else:
|
else:
|
||||||
raise Failed(f"IMDb Error: Method {method} not supported")
|
raise Failed(f"IMDb Error: Method {method} not supported")
|
||||||
|
|
Loading…
Reference in a new issue