mirror of
https://github.com/meisnate12/Plex-Meta-Manager
synced 2024-11-22 20:43:07 +00:00
added icheckmovies_list
This commit is contained in:
parent
7fa141ac99
commit
6d2a34ac65
4 changed files with 60 additions and 0 deletions
|
@ -714,6 +714,11 @@ class CollectionBuilder:
|
|||
list_count = 0
|
||||
new_list.append({"url": imdb_url, "limit": list_count})
|
||||
self.methods.append((method_name, new_list))
|
||||
elif method_name == "icheckmovies_list":
|
||||
valid_lists = []
|
||||
for icheckmovies_list in util.get_list(method_data, split=False):
|
||||
valid_lists.append(config.ICheckMovies.validate_icheckmovies_list(icheckmovies_list, self.library.Plex.language))
|
||||
self.methods.append((method_name, valid_lists))
|
||||
elif method_name == "letterboxd_list":
|
||||
self.methods.append((method_name, util.get_list(method_data, split=False)))
|
||||
elif method_name == "letterboxd_list_details":
|
||||
|
@ -1094,6 +1099,7 @@ class CollectionBuilder:
|
|||
elif "mal" in method: check_map(self.config.MyAnimeList.get_items(method, value))
|
||||
elif "tvdb" in method: check_map(self.config.TVDb.get_items(method, value, self.library.Plex.language))
|
||||
elif "imdb" in method: check_map(self.config.IMDb.get_items(method, value, self.library.Plex.language, self.library.is_movie))
|
||||
elif "icheckmovies" in method: check_map(self.config.ICheckMovies.get_items(method, value, self.library.Plex.language))
|
||||
elif "letterboxd" in method: check_map(self.config.Letterboxd.get_items(method, value, self.library.Plex.language))
|
||||
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))
|
||||
|
|
|
@ -5,6 +5,7 @@ from modules.anidb import AniDB
|
|||
from modules.anilist import AniList
|
||||
from modules.cache import Cache
|
||||
from modules.convert import Convert
|
||||
from modules.icheckmovies import ICheckMovies
|
||||
from modules.imdb import IMDb
|
||||
from modules.letterboxd import Letterboxd
|
||||
from modules.mal import MyAnimeList
|
||||
|
@ -276,6 +277,7 @@ class Config:
|
|||
self.Convert = Convert(self)
|
||||
self.AniList = AniList(self)
|
||||
self.Letterboxd = Letterboxd(self)
|
||||
self.ICheckMovies = ICheckMovies(self)
|
||||
|
||||
util.separator()
|
||||
|
||||
|
|
51
modules/icheckmovies.py
Normal file
51
modules/icheckmovies.py
Normal file
|
@ -0,0 +1,51 @@
|
|||
import logging, requests
|
||||
from lxml import html
|
||||
from modules import util
|
||||
from modules.util import Failed
|
||||
from retrying import retry
|
||||
|
||||
logger = logging.getLogger("Plex Meta Manager")
|
||||
|
||||
builders = ["icheckmovies_list"]
|
||||
|
||||
class ICheckMovies:
|
||||
def __init__(self, config):
|
||||
self.config = config
|
||||
self.list_url = "https://www.icheckmovies.com/lists/"
|
||||
|
||||
@retry(stop_max_attempt_number=6, wait_fixed=10000)
|
||||
def _request(self, url, language):
|
||||
return html.fromstring(requests.get(url, headers={"Accept-Language": language, "User-Agent": "Mozilla/5.0 x64"}).content)
|
||||
|
||||
def _parse_list(self, list_url, language):
|
||||
response = self._request(list_url, language)
|
||||
imdb_urls = response.xpath("//a[@class='optionIcon optionIMDB external']/@href")
|
||||
return [t[t.find("/tt") + 1:-1] for t in imdb_urls]
|
||||
|
||||
def validate_icheckmovies_list(self, list_url, language):
|
||||
list_url = list_url.strip()
|
||||
if not list_url.startswith(self.list_url):
|
||||
raise Failed(f"ICheckMovies Error: {list_url} must begin with: {self.list_url}")
|
||||
if len(self._parse_list(list_url, language)) > 0:
|
||||
return list_url
|
||||
raise Failed(f"ICheckMovies Error: {list_url} failed to parse")
|
||||
|
||||
def get_items(self, method, data, language):
|
||||
pretty = util.pretty_names[method] if method in util.pretty_names else method
|
||||
movie_ids = []
|
||||
if method == "icheckmovies_list":
|
||||
logger.info(f"Processing {pretty}: {data}")
|
||||
imdb_ids = self._parse_list(data, language)
|
||||
total_ids = len(imdb_ids)
|
||||
for i, imdb_id in enumerate(imdb_ids, 1):
|
||||
try:
|
||||
util.print_return(f"Converting IMDb ID {i}/{total_ids}")
|
||||
movie_ids.append(self.config.Convert.imdb_to_tmdb(imdb_id))
|
||||
except Failed as e:
|
||||
logger.error(e)
|
||||
logger.info(util.adjust_space(f"Processed {total_ids} IMDb IDs"))
|
||||
else:
|
||||
raise Failed(f"ICheckMovies Error: Method {method} not supported")
|
||||
logger.debug("")
|
||||
logger.debug(f"TMDb IDs Found: {movie_ids}")
|
||||
return movie_ids, []
|
|
@ -88,6 +88,7 @@ pretty_names = {
|
|||
"anilist_studio": "AniList Studio",
|
||||
"anilist_tag": "AniList Tag",
|
||||
"anilist_top_rated": "AniList Top Rated",
|
||||
"icheckmovies_list": "I Check Movies List",
|
||||
"imdb_list": "IMDb List",
|
||||
"imdb_id": "IMDb ID",
|
||||
"letterboxd_list": "Letterboxd List",
|
||||
|
|
Loading…
Reference in a new issue