fix(reader): the watched-channels list keeps its channels, its shares and its retries

- A channel someone follows: the videos its exploration brings in (the list's
  dialog, the channel page's explore) come in as the catalog's own, not
  flagged via_explore, which subscribing would never clear and which kept
  their watched marks waiting for good.
- The explore cleanup keeps the row of a channel a Takeout history shows
  watched (it still reclaims the videos), so a looked-at channel no longer
  drops off the list.
- The Shorts job takes up only users whose list still has lengths to ask or
  channels to name, by each user's own follows, blocks and dismissals; a
  naming that failed is tried again, and the list says it is not complete.
- The length lookups have a daily share of their own: a large history no
  longer leaves the export's Watch later file waiting a day.
- Only a channel of the user's own history can be put out of the list.
- The dialog's videos have a query root of their own: the list's
  invalidations no longer re-ask (and re-explore) under an open dialog.
This commit is contained in:
2026-10-24 01:10:29 +02:00
parent b5f9cf14db
commit 33dd9ff054
9 changed files with 233 additions and 47 deletions
+3 -3
View File
@@ -307,9 +307,9 @@ def explore_channel(
"""Open an un-subscribed channel for browsing. Records the exploration (a per-user,
grace-clocked row that gates this user's access to the channel's ephemeral videos and
drives the later cleanup), flags the channel ephemeral unless someone organically follows
it, then ingests one page of its uploads (newest-first) marked via_explore + enriched.
Returns the next page token so the page can "load more". Guarded against the shared
backfill quota reserve."""
it, then ingests one page of its uploads (newest-first), enriched — marked via_explore while
nobody follows it. Returns the next page token so the page can "load more". Guarded against
the shared backfill quota reserve."""
channel = _channel_or_404(db, channel_id)
if queries.is_blocked(db, user, channel_id):
raise refused(403, "channel_blocked")
+10 -6
View File
@@ -427,9 +427,9 @@ def takeout_status(user: User = Depends(current_user), db: Session = Depends(get
def watched_channels(user: User = Depends(current_user), db: Session = Depends(get_db)) -> dict:
"""The channels the user's Takeout history shows them watching often but not following: each
with how many of its videos over five minutes they watched, and when last. `pending` is how many
more channels may join once the import has asked YouTube for their videos' lengths, so a list
still being made does not read as the whole of it; `imported` tells "no history uploaded" from
"nothing to suggest"."""
more channels may join once the import has asked YouTube for their videos' lengths or their
names, so a list still being made does not read as the whole of it; `imported` tells "no history
uploaded" from "nothing to suggest"."""
return {
"imported": queries.has_watch_history(db, user),
"pending": queries.watched_channels_pending(db, user),
@@ -457,7 +457,8 @@ def watched_channel_videos(
"""The videos of a channel that the user's list counts, ready to play, last watched first. The
channel is explored for the user (as its page does), and the videos the catalog lacks come in as
the exploration's: the player needs them in the catalog, the shared Library does not get them,
and the cleanup reclaims them once nobody keeps them. `gone`: how many YouTube no longer has."""
and the cleanup reclaims them once nobody keeps them. Of a channel someone follows they come in
as the catalog's own, as its uploads do. `gone`: how many YouTube no longer has."""
channel = catalog_queries.channel(db, channel_id)
if channel is None:
raise not_found("channel")
@@ -477,7 +478,7 @@ def watched_channel_videos(
quota.attribute(user.id, quota.QuotaAction.CHANNELS_EXPLORE),
YouTubeClient(db, user) as yt,
):
ensure_videos(db, yt, missing, explore=True)
ensure_videos(db, yt, missing, explore=channel.from_explore)
except YouTubeError as exc:
raise youtube_refusal(exc) from exc
items = queries.feed_rows_by_ids(db, user, ids)
@@ -494,7 +495,10 @@ def dismiss_watched_channel(
user: User = Depends(current_user),
db: Session = Depends(get_db),
) -> dict:
"""Put a channel out of the user's list (it stays out until restored)."""
"""Put a channel out of the user's list (it stays out until restored). Only one their own history
shows them watching: a made-up id would only pile up rows every list read then has to skip."""
if not queries.watched_in_history(db, user, channel_id):
raise not_found("channel")
service.dismiss_watched_channel(db, user, channel_id)
db.commit()
return {"ok": True, "channel_id": channel_id}