TraktBatch: Add cleanup param
MODIFY
plextraktsync/factory.py
plextraktsync/factory.py
@@ -244,6 +244,7 @@ def trakt_batch(self):
TraktBatch,
trakt=self.trakt_api,
timer=self.batch_delay_timer,
+ cleanup=self.cleanup,
)

MODIFY
plextraktsync/trakt_api.py
plextraktsync/trakt_api.py
from plextraktsync.path import pytrakt_file
from plextraktsync.plex.PlexGuid import PlexGuid
from plextraktsync.plex_api import PlexLibraryItem
+from plextraktsync.util.Cleanup import Cleanup
class ScrobblerProxy:
@@ -387,7 +388,7 @@ def trakt_batch(*args, **kwargs) -> TraktBatch:
class TraktBatch:
- def __init__(self, name: str, add: bool, trakt: TraktApi, timer=None):
+ def __init__(self, name: str, add: bool, trakt: TraktApi, timer=None, cleanup: Cleanup = None):
if name not in ["collection", "watchlist"]:
raise ValueError(f"TraktBatch name not allowed: {name}")
self.name = name
@@ -395,6 +396,8 @@ def __init__(self, name: str, add: bool, trakt: TraktApi, timer=None):
self.trakt = trakt
self.items = defaultdict(list)
self.timer = timer
+ if cleanup:
+ cleanup.add(self.flush)
@nocache
@rate_limit()

TraktBatch: Add cleanup param