Fix Top Songs: accumulate play counts per scrape, deduplicate only stat card
song_counts tallies how many times each song appears across all runs (powers the Top Songs ranking). total_scraped uses the unique seen set separately so the stat card stays deduplicated. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
1 parent
8f28d9c9ce
commit
389376e43e
1 file changed
+5
-6
@@ -68,12 +68,11 @@ def load_recent_stats(db_path=None):
|
|||||||
sname = song.get("source", "Unknown")
|
sname = song.get("source", "Unknown")
|
||||||
title = song.get("title", "?")
|
title = song.get("title", "?")
|
||||||
artist = song.get("artist", "?")
|
artist = song.get("artist", "?")
|
||||||
k = (artist, title)
|
scraped_seen.add((artist, title))
|
||||||
if k not in scraped_seen:
|
# accumulate play count every scrape (powers Top Songs ranking)
|
||||||
scraped_seen.add(k)
|
stats["song_counts"].setdefault(sname, {})
|
||||||
stats["song_counts"].setdefault(sname, {})
|
dk = f"{artist} - {title}"
|
||||||
dk = f"{artist} - {title}"
|
stats["song_counts"][sname][dk] = stats["song_counts"][sname].get(dk, 0) + 1
|
||||||
stats["song_counts"][sname][dk] = stats["song_counts"][sname].get(dk, 0) + 1
|
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
try:
|
try:
|
||||||
|
|||||||
Reference in new issue
Block a user