Skip to content

Commit

Permalink
Merge pull request #549 from meisnate12/develop
Browse files Browse the repository at this point in the history
v1.14.1
  • Loading branch information
meisnate12 authored Dec 29, 2021
2 parents 0de6e2f + 2b9405a commit 6788fa8
Show file tree
Hide file tree
Showing 11 changed files with 38 additions and 37 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.14.0
1.14.1
1 change: 1 addition & 0 deletions config/config.yml.template
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ settings: # Can be individually specified
tvdb_language: eng
ignore_ids:
ignore_imdb_ids:
playlist_sync_to_user: all
webhooks: # Can be individually specified per library as well
error:
run_start:
Expand Down
4 changes: 1 addition & 3 deletions modules/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,6 @@
"country", "country.not",
"director", "director.not",
"duration.gt", "duration.gte", "duration.lt", "duration.lte",
"original_language", "original_language.not",
"subtitle_language", "subtitle_language.not",
"resolution", "resolution.not",
"writer", "writer.not"
Expand Down Expand Up @@ -738,8 +737,7 @@ def _item_details(self, method_name, method_data, method_mod, method_final, meth
elif method_name in plex.item_advance_keys:
key, options = plex.item_advance_keys[method_name]
if method_name in advance_new_agent and self.library.agent not in plex.new_plex_agents:
logger.error(
f"Metadata Error: {method_name} attribute only works for with the New Plex Movie Agent and New Plex TV Agent")
logger.error(f"Metadata Error: {method_name} attribute only works for with the New Plex Movie Agent and New Plex TV Agent")
elif method_name in advance_show and not self.library.is_show:
logger.error(f"Metadata Error: {method_name} attribute only works for show libraries")
elif str(method_data).lower() not in options:
Expand Down
9 changes: 6 additions & 3 deletions modules/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,10 +202,13 @@ def _query_map(self, map_name, _id, from_id, to_id, media_type=None, return_type
if row and row[to_id]:
datetime_object = datetime.strptime(row["expiration_date"], "%Y-%m-%d")
time_between_insertion = datetime.now() - datetime_object
try:
id_to_return = int(row[to_id])
except ValueError:
if "_" in row[to_id]:
id_to_return = row[to_id]
else:
try:
id_to_return = int(row[to_id])
except ValueError:
id_to_return = row[to_id]
expired = time_between_insertion.days > self.expiration
out_type = row["media_type"] if return_type else None
if return_type:
Expand Down
4 changes: 2 additions & 2 deletions modules/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ def hooks(attr):
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")
if not read_only:
if not self.read_only:
yaml.round_trip_dump(new_config, open(self.config_path, "w", encoding="utf-8"), indent=None, block_seq_indent=2)
self.data = new_config
except yaml.scanner.ScannerError as e:
Expand Down Expand Up @@ -247,7 +247,7 @@ def check_for_attribute(data, attribute, parent=None, test_list=None, default=No
"tvdb_language": check_for_attribute(self.data, "tvdb_language", parent="settings", default="default"),
"ignore_ids": check_for_attribute(self.data, "ignore_ids", parent="settings", var_type="int_list", default_is_none=True),
"ignore_imdb_ids": check_for_attribute(self.data, "ignore_imdb_ids", parent="settings", var_type="list", default_is_none=True),
"playlist_sync_to_user": check_for_attribute(self.data, "playlist_sync_to_user", parent="settings", default="all"),
"playlist_sync_to_user": check_for_attribute(self.data, "playlist_sync_to_user", parent="settings", default="all", default_is_none=True),
"assets_for_all": check_for_attribute(self.data, "assets_for_all", parent="settings", var_type="bool", default=False, save=False, do_print=False)
}
self.webhooks = {
Expand Down
2 changes: 1 addition & 1 deletion modules/mal.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def _refresh(self):

def _save(self, authorization):
if authorization is not None and "access_token" in authorization and authorization["access_token"] and self._check(authorization):
if self.authorization != authorization and self.config.read_only:
if self.authorization != authorization and not self.config.read_only:
yaml.YAML().allow_duplicate_keys = True
config, ind, bsi = yaml.util.load_yaml_guess_indent(open(self.config_path))
config["mal"]["authorization"] = {
Expand Down
10 changes: 5 additions & 5 deletions modules/radarr.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def add_tmdb(self, tmdb_ids, **options):
arr_ids = {}
for movie in self.api.all_movies():
if movie.path:
arr_paths[movie.path[:-1] if movie.path.endswith(("/", "\\")) else movie.path] = movie.tmdbId
arr_paths[movie.path[:-1].lower() if movie.path.endswith(("/", "\\")) else movie.path.lower()] = movie.tmdbId
arr_ids[movie.tmdbId] = movie
if self.config.trace_mode:
logger.debug(arr_paths)
Expand All @@ -85,11 +85,11 @@ def add_tmdb(self, tmdb_ids, **options):
if tmdb_id in arr_ids:
exists.append(arr_ids[tmdb_id])
continue
if path in arr_paths:
if path and path.lower() in arr_paths:
mismatched[path] = tmdb_id
continue
movie = self.api.get_movie(tmdb_id=tmdb_id)
if f"{folder}/{movie.folder}" in arr_paths:
if f"{folder}/{movie.folder}".lower() in arr_paths:
path_in_use[f"{folder}/{movie.folder}"] = tmdb_id
continue
if path:
Expand Down Expand Up @@ -134,14 +134,14 @@ def add_tmdb(self, tmdb_ids, **options):
logger.info("")
logger.info("Items in Plex that have already been added to Radarr but under a different TMDb ID then in Plex")
for path, tmdb_id in mismatched.items():
logger.info(f"Plex TMDb ID: {tmdb_id:<7} | Radarr TMDb ID: {arr_paths[path]:<7} | Path: {path}")
logger.info(f"Plex TMDb ID: {tmdb_id:<7} | Radarr TMDb ID: {arr_paths[path.lower()]:<7} | Path: {path}")
logger.info(f"{len(mismatched)} Movie{'s' if len(mismatched) > 1 else ''} with mismatched TMDb IDs")

if len(path_in_use) > 0:
logger.info("")
logger.info("TMDb IDs that cannot be added to Radarr because the path they will use is already in use by a different TMDb ID")
for path, tmdb_id in path_in_use.items():
logger.info(f"TMDb ID: {tmdb_id:<7} | Radarr TMDb ID: {arr_paths[path]:<7} | Path: {path}")
logger.info(f"TMDb ID: {tmdb_id:<7} | Radarr TMDb ID: {arr_paths[path.lower()]:<7} | Path: {path}")
logger.info(f"{len(path_in_use)} Movie{'s' if len(path_in_use) > 1 else ''} with paths already in use by other TMDb IDs")

if len(invalid) > 0:
Expand Down
12 changes: 6 additions & 6 deletions modules/sonarr.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ def add_tvdb(self, tvdb_ids, **options):
arr_ids = {}
for series in self.api.all_series():
if series.path:
arr_paths[series.path[:-1] if series.path.endswith(("/", "\\")) else series.path] = series.tvdbId
arr_paths[series.tvdbId] = series
arr_paths[series.path[:-1].lower() if series.path.endswith(("/", "\\")) else series.path.lower()] = series.tvdbId
arr_ids[series.tvdbId] = series
if self.config.trace_mode:
logger.debug(arr_paths)
logger.debug(arr_ids)
Expand All @@ -111,11 +111,11 @@ def add_tvdb(self, tvdb_ids, **options):
if tvdb_id in arr_ids:
exists.append(arr_ids[tvdb_id])
continue
if path in arr_paths:
if path and path.lower() in arr_paths:
mismatched[path] = tvdb_id
continue
show = self.api.get_series(tvdb_id=tvdb_id)
if f"{folder}/{show.folder}" in arr_paths:
if f"{folder}/{show.folder}".lower() in arr_paths:
path_in_use[f"{folder}/{show.folder}"] = tvdb_id
continue
if path:
Expand Down Expand Up @@ -160,14 +160,14 @@ def add_tvdb(self, tvdb_ids, **options):
logger.info("")
logger.info("Items in Plex that have already been added to Sonarr but under a different TVDb ID then in Plex")
for path, tmdb_id in mismatched.items():
logger.info(f"Plex TVDb ID: {tmdb_id:<7} | Sonarr TVDb ID: {arr_paths[path]:<7} | Path: {path}")
logger.info(f"Plex TVDb ID: {tmdb_id:<7} | Sonarr TVDb ID: {arr_paths[path.lower()]:<7} | Path: {path}")
logger.info(f"{len(mismatched)} Series with mismatched TVDb IDs")

if len(path_in_use) > 0:
logger.info("")
logger.info("TVDb IDs that cannot be added to Sonarr because the path they will use is already in use by a different TVDb ID")
for path, tvdb_id in path_in_use.items():
logger.info(f"TVDb ID: {tvdb_id:<7} | Sonarr TVDb ID: {arr_paths[path]:<7} | Path: {path}")
logger.info(f"TVDb ID: {tvdb_id:<7} | Sonarr TVDb ID: {arr_paths[path.lower()]:<7} | Path: {path}")
logger.info(f"{len(path_in_use)} Series with paths already in use by other TVDb IDs")

if len(invalid) > 0:
Expand Down
2 changes: 1 addition & 1 deletion modules/trakt.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def _refresh(self):

def _save(self, authorization):
if authorization and self._check(authorization):
if self.authorization != authorization and self.config.read_only:
if self.authorization != authorization and not self.config.read_only:
yaml.YAML().allow_duplicate_keys = True
config, ind, bsi = yaml.util.load_yaml_guess_indent(open(self.config_path))
config["trakt"]["authorization"] = {
Expand Down
27 changes: 13 additions & 14 deletions plex_meta_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,7 @@ def library_operations(config, library):
template[k] = v[int(_i)]
for suffix in library.tmdb_collections["remove_suffix"]:
if _n.endswith(suffix):
_n = _n[:-len(_n)]
_n = _n[:-len(suffix)]
new_collections[_n.strip()] = {"template": template}
metadata = MetadataFile(config, library, "Data", {
"collections": new_collections,
Expand Down Expand Up @@ -853,23 +853,22 @@ def run_playlists(config):
server_check = pl_library.PlexServer.machineIdentifier

sync_to_users = config.general["playlist_sync_to_user"]
if "sync_to_users" not in playlist_attrs:
logger.warning(f"Playlist Error: sync_to_users attribute not found defaulting to playlist_sync_to_user: {sync_to_users}")
elif not playlist_attrs["sync_to_users"]:
logger.warning(f"Playlist Error: sync_to_users attribute is blank defaulting to playlist_sync_to_user: {sync_to_users}")
else:
if "sync_to_users" in playlist_attrs:
sync_to_users = playlist_attrs["sync_to_users"]
else:
logger.warning(f"Playlist Error: sync_to_users attribute not found defaulting to playlist_sync_to_user: {sync_to_users}")

valid_users = []
plex_users = pl_libraries[0].users
if str(sync_to_users) == "all":
valid_users = plex_users
else:
for user in util.get_list(sync_to_users):
if user in plex_users:
valid_users.append(user)
else:
raise Failed(f"Playlist Error: User: {user} not found in plex\nOptions: {plex_users}")
if sync_to_users:
if str(sync_to_users) == "all":
valid_users = plex_users
else:
for user in util.get_list(sync_to_users):
if user in plex_users:
valid_users.append(user)
else:
raise Failed(f"Playlist Error: User: {user} not found in plex\nOptions: {plex_users}")

util.separator(f"Validating {mapping_name} Attributes", space=False, border=False)

Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ tmdbv3api==1.7.6
arrapi==1.3.0
lxml==4.7.1
requests==2.26.0
ruamel.yaml==0.17.17
ruamel.yaml==0.17.19
schedule==1.1.0
retrying==1.3.3
pathvalidate==2.5.0
Expand Down

0 comments on commit 6788fa8

Please sign in to comment.