fix(youtube): "this playlist no longer exists" only where the user picked that list
playlistNotFound was mapped to "gone" everywhere: exploring a channel without uploads (its uploads list answers not found) and a list deleted mid bulk pull both said a playlist no longer exists. The reason is now "gone" only on single-playlist routes; explore reads it as an empty back-catalogue, and the bulk pull skips that list and syncs the rest.
This commit is contained in:
@@ -117,17 +117,28 @@ _DEAD_GRANT = "invalid_grant"
|
||||
YouTubeRefusal = Literal["quota", "reconnect", "unavailable", "gone"]
|
||||
|
||||
|
||||
def refusal_reason(exc: YouTubeError) -> YouTubeRefusal:
|
||||
def is_playlist_gone(exc: YouTubeError) -> bool:
|
||||
"""Whether YouTube answered that the playlist read or written does not exist. Only the caller
|
||||
knows which playlist that was: a user's list deleted on YouTube, or a channel's uploads list,
|
||||
which YouTube also answers so for a channel with no uploads at all."""
|
||||
return "playlistNotFound" in exc.reason.split(",")
|
||||
|
||||
|
||||
def refusal_reason(exc: YouTubeError, *, playlist: bool = False) -> YouTubeRefusal:
|
||||
"""Sort a failure by what the user can do about it. A dead grant (Google refused the refresh
|
||||
with `invalid_grant`, which also drops the grant — see `_drop_dead_grant`) or no usable token at
|
||||
all (raised before any endpoint answered, so with no path and no transport reason) means the
|
||||
account must be reconnected; retrying cannot help. Any other token-endpoint failure — a 5xx, a
|
||||
429, a misconfigured client — leaves the grant as it was: reconnecting would not fix it, and
|
||||
the account would still read as connected, with no connect button to press."""
|
||||
the account would still read as connected, with no connect button to press.
|
||||
|
||||
`playlist`: the action was on ONE playlist the user picked, so a missing playlist is that list,
|
||||
gone (deleted on YouTube) — neither a retry nor a reconnect helps. Anywhere else the playlist
|
||||
is one the user never named (a channel's uploads, one list of a bulk pull), and "this playlist
|
||||
no longer exists" would describe nothing on their screen (E32 review round 2)."""
|
||||
if is_quota_refusal(exc):
|
||||
return "quota"
|
||||
if exc.reason == "playlistNotFound":
|
||||
# The list itself is gone (deleted on YouTube): neither a retry nor a reconnect helps.
|
||||
if playlist and is_playlist_gone(exc):
|
||||
return "gone"
|
||||
if exc.path == "oauth2/token":
|
||||
return "reconnect" if exc.reason == _DEAD_GRANT else "unavailable"
|
||||
|
||||
Reference in New Issue
Block a user