Repository navigation
fix: remove a deleted video's leftover entry from a playlist - #24
Merged
Merged
Conversation
YouTube rejects the playlistItems videoId filter with videoNotFound once a video is deleted, though the playlist keeps its entry. Removing then falls back to reading the whole playlist. Moving still fails fast. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Reading the playlist now stops with an error at YouTube's 5,000-entry cap instead of reporting nothing removed, requests contentDetails rather than the larger snippet, and the help names unknown IDs as costing the same scan. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
eukosh
pushed a commit
that referenced
this pull request
Oct 25, 2026
🤖 I have created a release *beep* *boop* --- ## [0.7.3](v0.7.2...v0.7.3) (2026-10-25) ### Fixed * remove a deleted video's leftover entry from a playlist ([#24](#24)) ([8fad97a](8fad97a)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Once a video is deleted, YouTube rejects
playlistItems.list(videoId=…)with 404videoNotFound, but the playlist keeps a "Deleted video" entry with that ID.ytk playlist removeused that filter, so it couldn't remove the leftover entry.remove_from_playlist(playlist, video) _occurrences(playlist, video, deleted_video=True) list(videoId=video) + on videoNotFound: + read the whole playlist (part=contentDetails, up to 5,000 entries) + past 5,000 entries: error instead of a partial search + keep entries whose contentDetails.videoId == video delete each entrymove_in_playlistuses the same lookup without the fallback, so a deleted video still fails at once with not_found and doesn't spend quota reading the playlist. Any other error, such asplaylistNotFound, raises as before. YouTube answers videoNotFound for unknown IDs too, so a mistyped ID also reads the playlist and removes nothing. The help and MCP description ofremovesay so, and that it costs 1 more unit per 50 entries.Evidence
7A22uuMVA6wfrom a playlist failed with{"error": {"type": "not_found", "message": "Video not found."}}, whileytk playlist itemsstill listed it as "Deleted video". I checked the API live: the videoId filter returns 404videoNotFoundfor deleted IDs and for IDs that never existed alike. The new test failed withNotFound: Video not found.After:
test_remove_from_playlist_finds_a_deleted_video_by_reading_the_playlistpasses: it removes both entries across two pages, skips an entry with no video ID, and pins each page's request (no videoId filter). New tests also cover a video in no entry (removes 0), a scan that hits the cap (error, nothing deleted), other 404s (no scan) andmove(no scan).uv run pytest: 421 passed, 2 live skipped.ruff checkandruff format --checkare clean. Two Fable 5.1 (high) review rounds; their points are applied.Merge Danger
Door: two-way
Blast Radius: small
It only changes
playlist removewhen YouTube answers videoNotFound, which used to be an error. On a long playlist that path reads up to 100 pages (100 units).🤖 Generated with Claude Code