From c43f410e789e5c2b4aa826dd490adb5decc12a7d Mon Sep 17 00:00:00 2001 From: meisnate12 Date: Sat, 12 Nov 2022 11:42:53 -0500 Subject: [PATCH] [15] catch move failures --- VERSION | 2 +- docs/home/kb.md | 44 ++++++++++++++++++-------------------------- modules/builder.py | 14 ++++++++------ modules/overlays.py | 8 +++++++- modules/plex.py | 6 +++++- modules/util.py | 2 +- plex_meta_manager.py | 4 +++- 7 files changed, 43 insertions(+), 37 deletions(-) diff --git a/VERSION b/VERSION index fd46a54e..bd35fdca 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.18.0-develop14 +1.18.0-develop15 diff --git a/docs/home/kb.md b/docs/home/kb.md index 09a7c35f..f5e8f17c 100644 --- a/docs/home/kb.md +++ b/docs/home/kb.md @@ -8,12 +8,12 @@ This sections aims to answer the most commonly asked questions that users have. ### "How do I update to the latest version of Plex Meta Manager?" -[type this into your terminal] - ````{tab} OS X/Linux
+[type this into your terminal] + ``` cd /Users/mroche/Plex-Meta-Manager git pull @@ -21,13 +21,13 @@ source pmm-venv/bin/activate python -m pip install -r requirements.txt ``` -
- ```` ````{tab} Windows
+[type this into your terminal] + ``` cd C:\Users\mroche\Plex-Meta-Manager git pull @@ -35,29 +35,27 @@ git pull python -m pip install -r requirements.txt ``` -
- ```` ````{tab} Docker
+[type this into your terminal] + ``` docker pull meisnate12/plex-meta-manager ``` -
- ```` ### "How do I switch to the develop branch?" -[type this into your terminal] - ````{tab} OS X/Linux
+[type this into your terminal] + ``` cd /Users/mroche/Plex-Meta-Manager git checkout develop @@ -66,13 +64,13 @@ source pmm-venv/bin/activate python -m pip install -r requirements.txt ``` -
- ```` ````{tab} Windows
+[type this into your terminal] + ``` cd C:\Users\mroche\Plex-Meta-Manager git checkout develop @@ -81,18 +79,16 @@ git pull python -m pip install -r requirements.txt ``` -
- ```` ### "How do I switch to the nightly branch" -[type this into your terminal] - ````{tab} OS X/Linux
+[type this into your terminal] + ``` cd /Users/mroche/Plex-Meta-Manager git checkout nightly @@ -101,13 +97,13 @@ source pmm-venv/bin/activate python -m pip install -r requirements.txt ``` -
- ```` ````{tab} Windows
+[type this into your terminal] + ``` cd C:\Users\mroche\Plex-Meta-Manager git checkout nightly @@ -116,18 +112,16 @@ git pull python -m pip install -r requirements.txt ``` -
- ```` ### "How do I switch back to the master branch?" -[type this into your terminal] - ````{tab} OS X/Linux
+[type this into your terminal] + ``` cd /Users/mroche/Plex-Meta-Manager git checkout master @@ -136,13 +130,13 @@ source pmm-venv/bin/activate python -m pip install -r requirements.txt ``` -
- ```` ````{tab} Windows
+[type this into your terminal] + ``` cd C:\Users\mroche\Plex-Meta-Manager git checkout master @@ -151,8 +145,6 @@ git pull python -m pip install -r requirements.txt ``` -
- ```` ## Knowledgebase diff --git a/modules/builder.py b/modules/builder.py index fcc49599..90f335f6 100644 --- a/modules/builder.py +++ b/modules/builder.py @@ -452,7 +452,6 @@ class CollectionBuilder: else: raise Failed(str(e)) - if "delete_not_scheduled" in methods and not self.overlay: logger.debug("") logger.debug("Validating Method: delete_not_scheduled") @@ -2732,11 +2731,14 @@ class CollectionBuilder: items = self.library.get_filter_items(search_data[2]) previous = None for i, item in enumerate(items, 0): - if len(self.items) <= i or item.ratingKey != self.items[i].ratingKey: - text = f"after {util.item_title(previous)}" if previous else "to the beginning" - logger.info(f"Moving {util.item_title(item)} {text}") - self.library.moveItem(self.obj, item, previous) - previous = item + try: + if len(self.items) <= i or item.ratingKey != self.items[i].ratingKey: + text = f"after {util.item_title(previous)}" if previous else "to the beginning" + self.library.moveItem(self.obj, item, previous) + logger.info(f"Moving {util.item_title(item)} {text}") + previous = item + except Failed: + logger.error(f"Moving {util.item_title(item)} Failed") def sync_trakt_list(self): logger.info("") diff --git a/modules/overlays.py b/modules/overlays.py index 2e9fafdc..d782182e 100644 --- a/modules/overlays.py +++ b/modules/overlays.py @@ -2,7 +2,7 @@ import os, re, time from datetime import datetime from modules import plex, util, overlay from modules.builder import CollectionBuilder -from modules.util import Failed, NonExisting, NotScheduled +from modules.util import Failed, FilterFailed, NonExisting, NotScheduled from num2words import num2words from plexapi.exceptions import BadRequest from plexapi.video import Movie, Show, Season, Episode @@ -413,10 +413,16 @@ class Overlays: logger.info("") except NotScheduled as e: logger.info(e) + except FilterFailed: + pass except Failed as e: logger.stacktrace() logger.error(e) logger.info("") + except Exception as e: + logger.stacktrace() + logger.error(f"Unknown Error: {e}") + logger.info("") logger.separator(f"Overlay Operation for the {self.library.name} Library") logger.debug("") diff --git a/modules/plex.py b/modules/plex.py index 86ecf786..13481527 100644 --- a/modules/plex.py +++ b/modules/plex.py @@ -545,7 +545,11 @@ class Plex(Library): @retry(stop_max_attempt_number=6, wait_fixed=10000, retry_on_exception=util.retry_if_not_plex) def moveItem(self, obj, item, after): - obj.moveItem(item, after=after) + try: + obj.moveItem(item, after=after) + except (BadRequest, NotFound, Unauthorized) as e: + logger.error(e) + raise Failed("Move Failed") @retry(stop_max_attempt_number=6, wait_fixed=10000, retry_on_exception=util.retry_if_not_plex) def query(self, method): diff --git a/modules/util.py b/modules/util.py index ef6fb7b0..bf7012b6 100644 --- a/modules/util.py +++ b/modules/util.py @@ -56,7 +56,7 @@ def retry_if_not_failed(exception): return not isinstance(exception, Failed) def retry_if_not_plex(exception): - return not isinstance(exception, (BadRequest, NotFound, Unauthorized)) + return not isinstance(exception, (BadRequest, NotFound, Unauthorized, Failed)) days_alias = { "monday": 0, "mon": 0, "m": 0, diff --git a/plex_meta_manager.py b/plex_meta_manager.py index 4809848f..4e135575 100644 --- a/plex_meta_manager.py +++ b/plex_meta_manager.py @@ -123,7 +123,7 @@ from modules import util util.logger = logger from modules.builder import CollectionBuilder from modules.config import ConfigFile -from modules.util import Failed, NonExisting, NotScheduled, Deleted +from modules.util import Failed, FilterFailed, NonExisting, NotScheduled, Deleted def my_except_hook(exctype, value, tb): if issubclass(exctype, KeyboardInterrupt): @@ -719,6 +719,8 @@ def run_collection(config, library, metadata, requested_collections): library.status[str(mapping_name)]["status"] = "Skipped Invalid Library Type" else: library.status[str(mapping_name)]["status"] = "Not Scheduled" + except FilterFailed: + pass except Failed as e: library.notify(e, collection=mapping_name) logger.stacktrace()