Skip to content

Commit

Permalink
Merge pull request #52 from meisnate12/develop
Browse files Browse the repository at this point in the history
v1.2.1
  • Loading branch information
meisnate12 authored Feb 22, 2021
2 parents 7902cff + 80d39ed commit ea0c1cc
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 15 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Plex Meta Manager
#### Version 1.2.0
#### Version 1.2.1

The original concept for Plex Meta Manager is [Plex Auto Collections](https://github.com/mza921/Plex-Auto-Collections), but this is rewritten from the ground up to be able to include a scheduler, metadata edits, multiple libraries, and logging. Plex Meta Manager is a Python 3 script that can be continuously run using YAML configuration files to update on a schedule the metadata of the movies, shows, and collections in your libraries as well as automatically build collections based on various methods all detailed in the wiki. Some collection examples that the script can automatically build and update daily include Plex Based Searches like actor, genre, or studio collections or Collections based on TMDb, IMDb, Trakt, TVDb, AniDB, or MyAnimeList lists and various other services.

Expand Down
1 change: 1 addition & 0 deletions config/config.yml.template
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ settings: # Can be individually specified
plex: # Can be individually specified per library as well
url: http://192.168.1.12:32400
token: ####################
timeout: 60
tmdb:
apikey: ################################
language: en
Expand Down
23 changes: 13 additions & 10 deletions modules/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,15 @@ def replace_attr(all_data, attr, par):
replace_attr(new_config["libraries"][library], "show_filtered", "plex")
replace_attr(new_config["libraries"][library], "show_missing", "plex")
replace_attr(new_config["libraries"][library], "save_missing", "plex")
new_config["libraries"] = new_config.pop("libraries")
new_config["settings"] = new_config.pop("settings")
new_config["plex"] = new_config.pop("plex")
new_config["tmdb"] = new_config.pop("tmdb")
new_config["tautulli"] = new_config.pop("tautulli")
new_config["radarr"] = new_config.pop("radarr")
new_config["sonarr"] = new_config.pop("sonarr")
new_config["trakt"] = new_config.pop("trakt")
new_config["mal"] = new_config.pop("mal")
if "libraries" in new_config: new_config["libraries"] = new_config.pop("libraries")
if "settings" in new_config: new_config["settings"] = new_config.pop("settings")
if "plex" in new_config: new_config["plex"] = new_config.pop("plex")
if "tmdb" in new_config: new_config["tmdb"] = new_config.pop("tmdb")
if "tautulli" in new_config: new_config["tautulli"] = new_config.pop("tautulli")
if "radarr" in new_config: new_config["radarr"] = new_config.pop("radarr")
if "sonarr" in new_config: new_config["sonarr"] = new_config.pop("sonarr")
if "trakt" in new_config: new_config["trakt"] = new_config.pop("trakt")
if "mal" in new_config: new_config["mal"] = new_config.pop("mal")
yaml.round_trip_dump(new_config, open(self.config_path, "w"), indent=ind, block_seq_indent=bsi)
self.data = new_config
except yaml.scanner.ScannerError as e:
Expand All @@ -91,7 +91,7 @@ def check_for_attribute(data, attribute, parent=None, test_list=None, options=""
message = "{} not found".format(text)
if parent and save is True:
new_config, ind, bsi = yaml.util.load_yaml_guess_indent(open(self.config_path))
endline = "\n| {} sub-attribute {} added to config".format(parent, attribute)
endline = "\n{} sub-attribute {} added to config".format(parent, attribute)
if parent not in new_config: new_config = {parent: {attribute: default}}
elif not new_config[parent]: new_config[parent] = {attribute: default}
elif attribute not in new_config[parent]: new_config[parent][attribute] = default
Expand Down Expand Up @@ -214,6 +214,7 @@ def check_for_attribute(data, attribute, parent=None, test_list=None, options=""
self.general["plex"] = {}
self.general["plex"]["url"] = check_for_attribute(self.data, "url", parent="plex", default_is_none=True)
self.general["plex"]["token"] = check_for_attribute(self.data, "token", parent="plex", default_is_none=True)
self.general["plex"]["timeout"] = check_for_attribute(self.data, "timeout", parent="plex", var_type="int", default=60)

self.general["radarr"] = {}
self.general["radarr"]["url"] = check_for_attribute(self.data, "url", parent="radarr", default_is_none=True)
Expand Down Expand Up @@ -269,6 +270,7 @@ def check_for_attribute(data, attribute, parent=None, test_list=None, options=""
params["plex"] = {}
params["plex"]["url"] = check_for_attribute(libs[lib], "url", parent="plex", default=self.general["plex"]["url"], req_default=True, save=False)
params["plex"]["token"] = check_for_attribute(libs[lib], "token", parent="plex", default=self.general["plex"]["token"], req_default=True, save=False)
params["plex"]["timeout"] = check_for_attribute(libs[lib], "timeout", parent="plex", var_type="int", default=self.general["plex"]["timeout"], save=False)
library = PlexAPI(params, self.TMDb, self.TVDb)
logger.info("{} Library Connection Successful".format(params["name"]))
except Failed as e:
Expand Down Expand Up @@ -334,6 +336,7 @@ def check_for_attribute(data, attribute, parent=None, test_list=None, options=""

def update_libraries(self, test, requested_collections):
for library in self.libraries:
os.environ["PLEXAPI_PLEXAPI_TIMEOUT"] = str(library.timeout)
logger.info("")
util.seperator("{} Library".format(library.name))
try: library.update_metadata(self.TMDb, test)
Expand Down
5 changes: 2 additions & 3 deletions modules/plex.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

class PlexAPI:
def __init__(self, params, TMDb, TVDb):
try: self.PlexServer = PlexServer(params["plex"]["url"], params["plex"]["token"], timeout=600)
try: self.PlexServer = PlexServer(params["plex"]["url"], params["plex"]["token"], timeout=params["plex"]["timeout"])
except Unauthorized: raise Failed("Plex Error: Plex token is invalid")
except ValueError as e: raise Failed("Plex Error: {}".format(e))
except requests.exceptions.ConnectionError as e:
Expand Down Expand Up @@ -60,6 +60,7 @@ def get_dict(attribute):
self.show_missing = params["show_missing"]
self.save_missing = params["save_missing"]
self.plex = params["plex"]
self.timeout = params["plex"]["timeout"]
self.missing = {}

def add_Radarr(self, Radarr):
Expand All @@ -71,8 +72,6 @@ def add_Sonarr(self, Sonarr):
def add_Tautulli(self, Tautulli):
self.Tautulli = Tautulli



@retry(stop_max_attempt_number=6, wait_fixed=10000)
def search(self, title, libtype=None, year=None):
if libtype is not None and year is not None: return self.Plex.search(title=title, year=year, libtype=libtype)
Expand Down
2 changes: 1 addition & 1 deletion plex_meta_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def fmt_filter(record):
logger.info(util.get_centered_text("| __/| | __/> < | | | | __/ || (_| | | | | | (_| | | | | (_| | (_| | __/ | "))
logger.info(util.get_centered_text("|_| |_|\___/_/\_\ |_| |_|\___|\__\__,_| |_| |_|\__,_|_| |_|\__,_|\__, |\___|_| "))
logger.info(util.get_centered_text(" |___/ "))
logger.info(util.get_centered_text(" Version: 1.2.0 "))
logger.info(util.get_centered_text(" Version: 1.2.1 "))
util.seperator()

if args.tests:
Expand Down

0 comments on commit ea0c1cc

Please sign in to comment.