Skip to content

Commit 001fb1a

Browse files
committed
fix: implement tracker pending queue sync on watch and startup
1 parent e532f4b commit 001fb1a

6 files changed

Lines changed: 30 additions & 5 deletions

File tree

weeb_cli/commands/search/watch_flow.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,16 @@ def _update_trackers(details, slug, ep_num=None):
314314
("Kitsu", kitsu_tracker)
315315
]
316316

317+
# First, try to sync any pending updates
318+
for name, tracker in trackers:
319+
if tracker.is_authenticated():
320+
try:
321+
synced_count = tracker.sync_pending()
322+
if synced_count > 0:
323+
console.print(f"[green]✓ {name}: {synced_count} {i18n.t('watchlist.pending_synced', 'pending updates synced')}[/green]")
324+
except Exception as e:
325+
log_error(f"Failed to sync pending updates for {name}: {e}")
326+
317327
updated = []
318328
pending = []
319329

weeb_cli/locales/de.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,8 @@
284284
"tracker_updated": "aktualisiert",
285285
"tracker_syncing": "wird synchronisiert...",
286286
"tracker_pending": "Zu ausstehend hinzugefügt",
287-
"tracker_error": "Tracker-Fehler"
287+
"tracker_error": "Tracker-Fehler",
288+
"pending_synced": "ausstehende Aktualisierung(en) synchronisiert"
288289
},
289290
"errors": {
290291
"generic": "Ein Fehler ist aufgetreten",

weeb_cli/locales/en.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,8 @@
284284
"tracker_updated": "updated",
285285
"tracker_syncing": "syncing...",
286286
"tracker_pending": "Added to pending",
287-
"tracker_error": "Tracker error"
287+
"tracker_error": "Tracker error",
288+
"pending_synced": "pending update(s) synced"
288289
},
289290
"errors": {
290291
"generic": "An error occurred",

weeb_cli/locales/pl.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,8 @@
280280
"tracker_updated": "zaktualizowano",
281281
"tracker_syncing": "synchronizacja...",
282282
"tracker_pending": "Dodano do oczekujących",
283-
"tracker_error": "Błąd trackera"
283+
"tracker_error": "Błąd trackera",
284+
"pending_synced": "zsynchronizowano oczekujące aktualizacje"
284285
},
285286
"errors": {
286287
"generic": "Wystąpił błąd",

weeb_cli/locales/tr.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,8 @@
284284
"tracker_updated": "güncellendi",
285285
"tracker_syncing": "senkronize ediliyor...",
286286
"tracker_pending": "Bekleyenlere eklendi",
287-
"tracker_error": "Tracker hatası"
287+
"tracker_error": "Tracker hatası",
288+
"pending_synced": "bekleyen güncelleme senkronize edildi"
288289
},
289290
"errors": {
290291
"generic": "Bir hata oluştu",

weeb_cli/services/local_library.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,18 @@ def _sync_to_trackers(self, anime_title: str, ep_number: int, total_episodes: in
148148
if not connected_trackers:
149149
return
150150

151-
# Try to sync to all trackers
151+
# First, try to sync any pending updates
152+
for name, tracker in connected_trackers:
153+
try:
154+
synced_count = tracker.sync_pending()
155+
if synced_count > 0:
156+
from weeb_cli.services.logger import info
157+
info(f"{name}: Synced {synced_count} pending updates")
158+
except Exception as e:
159+
from weeb_cli.services.logger import error
160+
error(f"Failed to sync pending updates for {name}: {e}")
161+
162+
# Try to sync current episode to all trackers
152163
for name, tracker in connected_trackers:
153164
tracker.update_progress(anime_title, ep_number, total_episodes)
154165

0 commit comments

Comments
 (0)