Skip to content

Commit

Permalink
Merge pull request #1882 from glensc/scrobble-conflict
Browse files Browse the repository at this point in the history
Fix: Do not retry conflict errors in scrobble
  • Loading branch information
glensc authored Mar 30, 2024
2 parents 5b0997d + 2f8968b commit 5c30979
Showing 1 changed file with 10 additions and 16 deletions.
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

0 comments on commit 5c30979

Please sign in to comment.