Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Add ignore_ids support #1874

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions plextraktsync/config.default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ logging:
# - name: requests_cache.policy.actions
# - name: requests_cache.session

# Plex Ids to ignore
# This is to workaround of broken sync if some items have unrecoverable errors
ignore_ids:
# - 123

# settings for 'sync' command
sync:
# Setting for whether ratings from one platform should have priority.
Expand Down
6 changes: 6 additions & 0 deletions plextraktsync/config/Config.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,12 @@ def http_cache(self):

return HttpCacheConfig(**cache)

@property
def ignore_ids(self):
values = self["ignore_ids"] if "ignore_ids" in self and self["ignore_ids"] else None

return set(values or [])

def initialize(self):
"""
Config load order:
Expand Down
15 changes: 14 additions & 1 deletion plextraktsync/media/MediaFactory.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
from __future__ import annotations

from functools import cached_property
from typing import TYPE_CHECKING

from plexapi.exceptions import PlexApiException
from requests import RequestException
from trakt.errors import TraktException

from plextraktsync.factory import logging
from plextraktsync.factory import factory, logging
from plextraktsync.media.Media import Media

if TYPE_CHECKING:
Expand All @@ -28,7 +29,19 @@ def __init__(self, plex: PlexApi, trakt: TraktApi):
self.plex = plex
self.trakt = trakt

@property
def config(self):
return factory.config

@cached_property
def ignore_ids(self):
return self.config.ignore_ids

def resolve_any(self, pm: PlexLibraryItem, show: Media = None) -> Media | None:
if pm.key in self.ignore_ids:
self.logger.error(f"Skipping {pm} because listed in ignore_ids")
return None

try:
guids = pm.guids
except (PlexApiException, RequestException) as e:
Expand Down
Loading