From 64ce978a6f4dfee434158e1f3cb9610dc106c195 Mon Sep 17 00:00:00 2001 From: meisnate12 Date: Tue, 1 Aug 2023 13:29:08 -0400 Subject: [PATCH] added no-main argument --- README.md | 2 ++ pmm_overlay_reset.py | 19 ++++++++++--------- requirements.txt | 6 +++--- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 7d3acd3..af447f1 100644 --- a/README.md +++ b/README.md @@ -119,6 +119,7 @@ Each option can be applied in three ways: | Timeout | Timeout can be any number greater then 0. **Default:** `600`
**Shell Command:** `-ti` or `--timeout 1000`
**Environment Variable:** `TIMEOUT=1000` | ❌ | | Dry Run | Run as a Dry Run without making changes in Plex.
**Shell Command:** `-d` or `--dry`
**Environment Variable:** `DRY_RUN=True` | ❌ | | Flat Assets | PMM Asset Folder uses [Flat Assets Image Paths](https://metamanager.wiki/en/latest/home/guides/assets.html#asset-naming).
**Shell Command:** `-f` or `--flat`
**Environment Variable:** `PMM_FLAT=True` | ❌ | +| Reset Main Posters | Do not restore Main Show/Movie posters during run.
**Shell Command:** `-nm` or `--no-main`
**Environment Variable:** `NO_MAIN=True` | ❌ | | Reset Season Posters | Restore Season posters during run.
**Shell Command:** `-s` or `--season`
**Environment Variable:** `SEASON=True` | ❌ | | Reset Episode Posters | Restore Episode posters during run.
**Shell Command:** `-e` or `--episode`
**Environment Variable:** `EPISODE=True` | ❌ | | Ignore Automatic Resume | Ignores the automatic resume.
**Shell Command:** `-ir` or `--ignore-resume`
**Environment Variable:** `IGNORE_RESUME=True` | ❌ | @@ -139,6 +140,7 @@ ITEMS= TIMEOUT=600 DRY_RUN=True PMM_FLAT=False +NO_MAIN=False SEASON=True EPISODE=True IGNORE_RESUME=False diff --git a/pmm_overlay_reset.py b/pmm_overlay_reset.py index 89db503..ed9ae38 100644 --- a/pmm_overlay_reset.py +++ b/pmm_overlay_reset.py @@ -34,6 +34,7 @@ {"arg": "ti", "key": "timeout", "env": "TIMEOUT", "type": "int", "default": 600, "help": "Timeout can be any number greater then 0. (Default: 600)"}, {"arg": "d", "key": "dry", "env": "DRY_RUN", "type": "bool", "default": False, "help": "Run as a Dry Run without making changes in Plex."}, {"arg": "f", "key": "flat", "env": "PMM_FLAT", "type": "bool", "default": False, "help": "PMM Asset Folder uses Flat Assets Image Paths."}, + {"arg": "nm", "key": "no-main", "env": "NO_MAIN", "type": "bool", "default": False, "help": "Do not restore the Main Movie/Show posters during run."}, {"arg": "s", "key": "season", "env": "SEASON", "type": "bool", "default": False, "help": "Restore Season posters during run."}, {"arg": "e", "key": "episode", "env": "EPISODE", "type": "bool", "default": False, "help": "Restore Episode posters during run."}, {"arg": "ir", "key": "ignore-resume", "env": "IGNORE_RESUME", "type": "bool", "default": None, "help": "Ignores the automatic resume."}, @@ -142,15 +143,14 @@ def detect_overlay_in_image(item_title, poster_source, shape, img_path=None, url if 0x04bc in exif_tags and exif_tags[0x04bc] == "overlay": logger.debug(f"Overlay Detected: EXIF Overlay Tag Found ignoring {poster_source}: {out_path}") return True - if (shape == "portrait" and pil_image.size != (1000, 1500)) or \ - (shape == "landscape" and pil_image.size != (1920, 1080)): + if (shape == "portrait" and pil_image.size != (1000, 1500)) or (shape == "landscape" and pil_image.size != (1920, 1080)): logger.debug("No Overlay: Image not standard overlay size") return False except UnidentifiedImageError: logger.error(f"Image Load Error: {poster_source}: {out_path}", group=item_title) return None - target = cv2.imread(img_path, cv2.IMREAD_GRAYSCALE) + target = cv2.imread(img_path, cv2.IMREAD_GRAYSCALE) # noqa if target is None: logger.error(f"Image Load Error: {poster_source}: {out_path}", group=item_title) return None @@ -158,7 +158,7 @@ def detect_overlay_in_image(item_title, poster_source, shape, img_path=None, url logger.info(f"Image Error: {poster_source}: Dimensions {target.shape[0]}x{target.shape[1]} must be greater then 500x500: {out_path}") return False for overlay_image in overlay_images: - overlay = cv2.imread(overlay_image, cv2.IMREAD_GRAYSCALE) + overlay = cv2.imread(overlay_image, cv2.IMREAD_GRAYSCALE) # noqa if overlay is None: logger.error(f"Image Load Error: {overlay_image}", group=item_title) continue @@ -167,7 +167,7 @@ def detect_overlay_in_image(item_title, poster_source, shape, img_path=None, url logger.error(f"Image Error: {overlay_image} is larger than {poster_source}: {out_path}", group=item_title) continue - template_result = cv2.matchTemplate(target, overlay, cv2.TM_CCOEFF_NORMED) # noinspection PyUnresolvedReferences + template_result = cv2.matchTemplate(target, overlay, cv2.TM_CCOEFF_NORMED) # noqa loc = numpy.where(template_result >= 0.95) if len(loc[0]) == 0: @@ -306,7 +306,7 @@ def reload(plex_item): includeFields=False, includeGeolocation=False, includeLoudnessRamps=False, includeMarkers=False, includeOnDeck=False, includePopularLeaves=False, includeRelated=False, includeRelatedCount=0, includeReviews=False, includeStations=False) - plex_item._initpath = plex_item._details_key + plex_item._autoReload = False except (BadRequest, NotFound) as e1: raise Failed(f"Plex Error: {get_title(plex_item)} Failed to Load: {e1}") @@ -399,7 +399,7 @@ def reload(plex_item): tmdb_item = None if tmdbapi: - guid = requests.utils.urlparse(item.guid) + guid = requests.utils.urlparse(item.guid) # noqa item_type = guid.scheme.split(".")[-1] check_id = guid.netloc tmdb_id = None @@ -407,7 +407,7 @@ def reload(plex_item): imdb_id = None if item_type == "plex": for guid_tag in item.guids: - url_parsed = requests.utils.urlparse(guid_tag.id) + url_parsed = requests.utils.urlparse(guid_tag.id) # noqa if url_parsed.scheme == "tvdb": tvdb_id = int(url_parsed.netloc) elif url_parsed.scheme == "imdb": @@ -458,7 +458,8 @@ def reload(plex_item): else: logger.error("Plex Error: TMDb ID Not Found", group=title) - reset_poster(title, item, tmdb_item.poster_url if tmdb_item else None, item_asset_directory, asset_name if pmmargs["flat"] else "poster") + if not pmmargs["no-main"]: + reset_poster(title, item, tmdb_item.poster_url if tmdb_item else None, item_asset_directory, asset_name if pmmargs["flat"] else "poster") logger.info(f"Runtime: {logger.runtime('reset')}") diff --git a/requirements.txt b/requirements.txt index ba7b7f2..5b39dee 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,7 +1,7 @@ -numpy==1.24.2 +numpy==1.24.3 opencv-python==4.7.0.72 pillow==9.5.0 PlexAPI==4.13.4 pmmutils==0.5.0 -requests==2.28.2 -tmdbapis==1.1.0 \ No newline at end of file +requests==2.31.0 +tmdbapis==1.2.0 \ No newline at end of file