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

Fix: Do not retry conflict errors in scrobble #1882

Merged
merged 2 commits into from
Mar 30, 2024
Merged
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
26 changes: 10 additions & 16 deletions plextraktsync/queue/TraktScrobbleWorker.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

from typing import TYPE_CHECKING

from trakt.errors import ConflictException

from plextraktsync.decorators.rate_limit import rate_limit
from plextraktsync.decorators.retry import retry
from plextraktsync.decorators.time_limit import time_limit
Expand Down Expand Up @@ -31,10 +33,10 @@ def __call__(self, queues):
queues[name].clear()

def submit(self, name, items):
method = getattr(self, name)
name = name.replace("scrobble_", "")
results = []
for scrobbler, progress in self.normalize(items).items():
res = method(scrobbler, progress)
res = self.scrobble(scrobbler, name, progress)
results.append(res)

if results:
Expand All @@ -43,20 +45,12 @@ def submit(self, name, items):
@rate_limit()
@time_limit()
@retry()
def scrobble_update(self, scrobbler: Scrobbler, progress: float):
return scrobbler.update(progress)

@rate_limit()
@time_limit()
@retry()
def scrobble_pause(self, scrobbler: Scrobbler, progress: float):
return scrobbler.pause(progress)

@rate_limit()
@time_limit()
@retry()
def scrobble_stop(self, scrobbler: Scrobbler, progress: float):
return scrobbler.stop(progress)
def scrobble(self, scrobbler: Scrobbler, name: str, progress: float):
method = getattr(scrobbler, name)
try:
return method(progress)
except ConflictException:
return

@staticmethod
def normalize(items: list[TraktPlayable]):
Expand Down
Loading