Merge remote-tracking branch 'origin/master' into develop

pull/652/head
meisnate12 3 years ago
commit 077169594d

@ -1,6 +1,6 @@
import logging, os, re, time import logging, os, re, time
from datetime import datetime, timedelta from datetime import datetime, timedelta
from modules import anidb, anilist, flixpatrol, icheckmovies, imdb, letterboxd, mal, plex, radarr, sonarr, stevenlu, tautulli, tmdb, trakt, tvdb, util from modules import anidb, anilist, flixpatrol, icheckmovies, imdb, letterboxd, mal, plex, radarr, sonarr, stevenlu, tautulli, tmdb, trakt, tvdb, mdblist, util
from modules.util import Failed, ImageData, NotScheduled, NotScheduledRange from modules.util import Failed, ImageData, NotScheduled, NotScheduledRange
from PIL import Image from PIL import Image
from plexapi.audio import Artist, Album, Track from plexapi.audio import Artist, Album, Track
@ -72,7 +72,7 @@ filter_translation = {
modifier_alias = {".greater": ".gt", ".less": ".lt"} modifier_alias = {".greater": ".gt", ".less": ".lt"}
all_builders = anidb.builders + anilist.builders + flixpatrol.builders + icheckmovies.builders + imdb.builders + \ all_builders = anidb.builders + anilist.builders + flixpatrol.builders + icheckmovies.builders + imdb.builders + \
letterboxd.builders + mal.builders + plex.builders + stevenlu.builders + tautulli.builders + \ letterboxd.builders + mal.builders + plex.builders + stevenlu.builders + tautulli.builders + \
tmdb.builders + trakt.builders + tvdb.builders tmdb.builders + trakt.builders + tvdb.builders + mdblist.builders
show_only_builders = ["tmdb_network", "tmdb_show", "tmdb_show_details", "tvdb_show", "tvdb_show_details", "collection_level", "item_tmdb_season_titles"] show_only_builders = ["tmdb_network", "tmdb_show", "tmdb_show_details", "tvdb_show", "tvdb_show_details", "collection_level", "item_tmdb_season_titles"]
movie_only_builders = [ movie_only_builders = [
"letterboxd_list", "letterboxd_list_details", "icheckmovies_list", "icheckmovies_list_details", "stevenlu_popular", "letterboxd_list", "letterboxd_list_details", "icheckmovies_list", "icheckmovies_list_details", "stevenlu_popular",
@ -553,6 +553,8 @@ class CollectionBuilder:
self._trakt(method_name, method_data) self._trakt(method_name, method_data)
elif method_name in tvdb.builders: elif method_name in tvdb.builders:
self._tvdb(method_name, method_data) self._tvdb(method_name, method_data)
elif method_name in mdblist.builders:
self._mdblist(method_name, method_data)
elif method_name == "filters": elif method_name == "filters":
self._filters(method_name, method_data) self._filters(method_name, method_data)
else: else:
@ -1078,6 +1080,10 @@ class CollectionBuilder:
def _stevenlu(self, method_name, method_data): def _stevenlu(self, method_name, method_data):
self.builders.append((method_name, self._parse(method_name, method_data, "bool"))) self.builders.append((method_name, self._parse(method_name, method_data, "bool")))
def _mdblist(self, method_name, method_data):
for mdb_dict in self.config.Mdblist.validate_mdb_lists(method_data, self.language):
self.builders.append((method_name, mdb_dict))
def _tautulli(self, method_name, method_data): def _tautulli(self, method_name, method_data):
for dict_data, dict_methods in self._parse(method_name, method_data, datatype="dictlist"): for dict_data, dict_methods in self._parse(method_name, method_data, datatype="dictlist"):
self.builders.append((method_name, { self.builders.append((method_name, {
@ -1262,6 +1268,8 @@ class CollectionBuilder:
return self.config.Letterboxd.get_tmdb_ids(method, value, self.language) return self.config.Letterboxd.get_tmdb_ids(method, value, self.language)
elif "stevenlu" in method: elif "stevenlu" in method:
return self.config.StevenLu.get_stevenlu_ids(method) return self.config.StevenLu.get_stevenlu_ids(method)
elif "mdblist" in method:
return self.config.Mdblist.get_mdblist_ids(method, value)
elif "tmdb" in method: elif "tmdb" in method:
return self.config.TMDb.get_tmdb_ids(method, value, self.library.is_movie) return self.config.TMDb.get_tmdb_ids(method, value, self.library.is_movie)
elif "trakt" in method: elif "trakt" in method:

@ -18,6 +18,7 @@ from modules.plex import Plex
from modules.radarr import Radarr from modules.radarr import Radarr
from modules.sonarr import Sonarr from modules.sonarr import Sonarr
from modules.stevenlu import StevenLu from modules.stevenlu import StevenLu
from modules.mdblist import Mdblist
from modules.tautulli import Tautulli from modules.tautulli import Tautulli
from modules.tmdb import TMDb from modules.tmdb import TMDb
from modules.trakt import Trakt from modules.trakt import Trakt
@ -483,6 +484,7 @@ class ConfigFile:
self.ICheckMovies = ICheckMovies(self) self.ICheckMovies = ICheckMovies(self)
self.Letterboxd = Letterboxd(self) self.Letterboxd = Letterboxd(self)
self.StevenLu = StevenLu(self) self.StevenLu = StevenLu(self)
self.Mdblist = Mdblist(self)
util.separator() util.separator()

@ -0,0 +1,55 @@
import logging
from modules import util
from modules.util import Failed
logger = logging.getLogger("Plex Meta Manager")
builders = ["mdblist_list"]
base_url = "https://mdblist.com/lists"
headers = { 'User-Agent': 'Plex-Meta-Manager' }
class Mdblist:
def __init__(self, config):
self.config = config
def validate_mdb_lists(self, mdb_lists, language):
valid_lists = []
for mdb_dict in util.get_list(mdb_lists, split=False):
if not isinstance(mdb_dict, dict):
mdb_dict = {"url": mdb_dict}
dict_methods = {dm.lower(): dm for dm in mdb_dict}
if "url" not in dict_methods:
raise Failed(f"Collection Error: mdb_list url attribute not found")
elif mdb_dict[dict_methods["url"]] is None:
raise Failed(f"Collection Error: mdb_list url attribute is blank")
else:
mdb_url = mdb_dict[dict_methods["url"]].strip()
if not mdb_url.startswith(base_url):
raise Failed(f"Mdblist Error: {mdb_url} must begin with: {base_url}")
list_count = None
if "limit" in dict_methods:
if mdb_dict[dict_methods["limit"]] is None:
logger.warning(f"Collection Warning: mdb_list limit attribute is blank using 0 as default")
else:
try:
value = int(str(mdb_dict[dict_methods["limit"]]))
if 0 <= value:
list_count = value
except ValueError:
pass
if list_count is None:
logger.warning(f"Collection Warning: mdb_list limit attribute must be an integer 0 or greater using 0 as default")
if list_count is None:
list_count = 0
valid_lists.append({"url": mdb_url, "limit": list_count})
return valid_lists
def get_mdblist_ids(self, method, data):
if method == "mdblist_list":
limit_status = f" Limit at: {data['limit']} items" if data['limit'] > 0 else ''
logger.info(f"Processing Mdblist.com List: {data['url']}{limit_status}")
url = f"{data['url']}?limit={data['limit']}"
return [(i["imdb_id"], "imdb") for i in self.config.get_json(url,headers=headers)]
else:
raise Failed(f"Mdblist Error: Method {method} not supported")
Loading…
Cancel
Save