Skip to content

[Bug]: Playlist videos keep stale view counts and often show no thumbnail #424

Open

Description

@Toastienergy

What happened?

Videos in a playlist show stale or missing metadata: the view counts never update, and the thumbnails often don't load at all (empty/grey tile). Playlist rows are a stored snapshot from the moment the video was added, and nothing keeps them current afterwards.

Expected: view counts follow the video, and a thumbnail that is missing or broken is repaired or replaced by a fallback instead of staying empty.

Steps to reproduce

  1. Add several videos to a playlist (or import one), some of them a while ago.
  2. Open the playlist (/playlists/{id}) after days or weeks.
  3. Compare view counts with the video pages: the playlist keeps the numbers from the time of adding.
  4. Look at the thumbnails: a share of the tiles stays empty and does not recover on reload.

Area

Backend (API / extraction) + Frontend (web app). Which client the reporter used when it was seen is not recorded here; the cause below is in the server, so it affects every client that reads /playlists/{id}.

Anything else?

Static code reading (server main @ 8868a7d, frontend main @ f624a39); not reproduced against a running instance.

Views never refresh (server)

  • PlaylistVideosTable stores thumbnail, viewCount, publishedAt etc. per row, written once in PlaylistService.addVideo (server-services/.../PlaylistService.kt:89-110).
  • The only refresh path is UserVideoMetadataRepairService, scheduled from GET /playlists/{id} (server-http/.../PlaylistRoutes.kt:38). Its candidate query, playlistNeedsRepair(), selects only rows with a fallback title (YouTube video %), empty thumbnail, duration <= 0, empty channel name or channel URL. viewCount is not part of it, so a row that has a title, thumbnail and duration is never refreshed again — its view count stays frozen forever. (VideoMetadataResolver.shouldEnrich has the same five conditions.)

Thumbnails often missing

  1. Repair is throttled hard: at most 8 videos per batch × 3 batches per run (MAX_REPAIR_PER_REQUEST = 8, MAX_BATCHES_PER_RUN = 3), then a 5-minute per-user cooldown (REPAIR_COOLDOWN_MS, schedule()), shared across all playlists, watch later and favourites of that user. A playlist with more than ~24 incomplete rows needs several visits spaced by five minutes. The run is also in the background, so the response that triggers it already carries the old data.
  2. The web client stops waiting too early: usePlaylist polls every 4 s but only up to 12 updates (hooks/use-playlist.ts:23), i.e. ~48 s. A repair that starts after the cooldown, or batch two/three of a long list, finishes after the client has stopped polling; the next time the user sees fresh data is the next manual reload.
  3. The poll condition does not match the server: needsMetadata also checks channelAvatar === "", which the server never repairs (playlistNeedsRepair() has no avatar condition). A playlist with an empty avatar keeps the client polling for the full 12 rounds for nothing, and no refresh can ever clear it.
  4. No fallback for a broken image: PlaylistVideoRow (components/playlist-video-row.tsx) renders <img src=...> with no onError handling, so a thumbnail URL that 404s or times out leaves an empty tile. PlaylistCard has the fallback (failedThumbnail + onError); the row component doesn't.
  5. Failed resolves are silent: VideoMetadataResolver.resolve marks an extraction failure as retryable, but the repair gives up after one retry (3 s) and moves on; there is no log line or counter that says how many rows were left incomplete.
  6. Not verified: whether the stored thumbnail URLs themselves expire or are blocked at the image proxy for some providers (BiliBili / NicoNico use different hosts). A repro with the browser's network tab on a failing tile would settle it; I did not have access to one.

Suggested fix

  • Add a freshness policy to the repair: refresh a row when viewCount <= 0 or the row is older than N days (e.g. track a metadata_refreshed_at), not only when fields are empty.
  • Let repair run per requested playlist instead of per user (the 5-minute cooldown is the bottleneck), keep the batch limit but report remaining work (e.g. a header or field metadataPending: n) so the client can keep polling exactly while there is work.
  • Align needsMetadata (frontend) with playlistNeedsRepair() (server), or add channelAvatar to the server side.
  • Add onError fallback (proxied thumbnail from the video id, or the placeholder) to PlaylistVideoRow.
  • Log repair outcomes (attempted / updated / failed) at info level.

AI disclosure: This issue was prepared with assistance from an AI system. The observations and proposed fixes are based on static code reading and should be reviewed and validated by the maintainers.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions