You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Plex-Meta-Manager/modules/icheckmovies.py

43 lines
1.8 KiB

from modules import util
from modules.util import Failed
logger = util.logger
builders = ["icheckmovies_list", "icheckmovies_list_details"]
base_url = "https://www.icheckmovies.com/lists/"
class ICheckMovies:
def __init__(self, config):
self.config = config
def _request(self, url, language, xpath):
logger.trace(f"URL: {url}")
return self.config.get_html(url, headers=util.header(language)).xpath(xpath)
def _parse_list(self, list_url, language):
imdb_urls = self._request(list_url, language, "//a[@class='optionIcon optionIMDB external']/@href")
3 years ago
return [(t[t.find("/tt") + 1:-1], "imdb") for t in imdb_urls]
def get_list_description(self, list_url, language):
descriptions = self._request(list_url, language, "//div[@class='span-19 last']/p/em/text()")
return descriptions[0] if len(descriptions) > 0 and len(descriptions[0]) > 0 else None
3 years ago
def validate_icheckmovies_lists(self, icheckmovies_lists, language):
valid_lists = []
for icheckmovies_list in util.get_list(icheckmovies_lists, split=False):
list_url = icheckmovies_list.strip()
if not list_url.startswith(base_url):
raise Failed(f"ICheckMovies Error: {list_url} must begin with: {base_url}")
elif len(self._parse_list(list_url, language)) > 0:
3 years ago
valid_lists.append(list_url)
else:
raise Failed(f"ICheckMovies Error: {list_url} failed to parse")
3 years ago
return valid_lists
def get_imdb_ids(self, method, data, language):
if method == "icheckmovies_list":
3 years ago
logger.info(f"Processing ICheckMovies List: {data}")
3 years ago
return self._parse_list(data, language)
else:
raise Failed(f"ICheckMovies Error: Method {method} not supported")