Skip to content

fix: drop duplicate videos when paging the uploads playlist (#58) - #59

Open
jdwit wants to merge 1 commit into
mainfrom
fix/videos-list-duplicates
Open

jdwit wants to merge 1 commit into
mainfrom
fix/videos-list-duplicates

Conversation

@jdwit

@jdwit jdwit commented Nov 19, 2026

Copy link
Copy Markdown
Owner

Fixes #58

Problem

videos list already reads the uploads playlist with playlistItems.list and pageToken. The API itself can return the same video on more than one page of that playlist (also reported on Stack Overflow for UU... playlists). The CLI printed every copy, so --limit 500 showed some videos two or three times.

Change

  • videos list: keep the first copy of each video id, in API order. --limit counts unique videos. videos.list is called only for new ids.
  • videos search-replace and playlists add --from-search: same dedupe on video id, so a video is never updated or added twice.
  • Playlist item listing: dedupe on playlist item id, not video id, because a playlist can hold the same video twice on purpose.

Tests

Regression tests use a fake offset-paged uploads playlist with repeated entries across pages (JSON, CSV, --limit), plus overlapping search and playlist item pages. They fail on main and pass here.

Limit

Dedupe removes the repeats. If the API also leaves some videos out of the uploads playlist pages, the CLI cannot show those; the reporter's count (164 unique out of 230 rows) is worth checking against the channel's real video count.

playlistItems.list on the uploads playlist can return the same video on
more than one page. videos list printed every copy. Keep the first copy
per video id, keep the API order, and count only unique videos toward
--limit.

The same guard goes on the other paged reads: search-replace and
playlists add --from-search (dedupe on video id, so no video is updated
or added twice) and playlist item listing (dedupe on playlist item id,
because a playlist can hold the same video twice on purpose).
@codecov

codecov Bot commented Nov 19, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 88.23529% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 85.66%. Comparing base (242ee3a) to head (86ac8c9).

Files with missing lines Patch % Lines
src/ytstudio/commands/videos.py 84.00% 1 Missing and 3 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #59      +/-   ##
==========================================
+ Coverage   85.03%   85.66%   +0.62%     
==========================================
  Files          15       15              
  Lines        2660     2686      +26     
  Branches      393      401       +8     
==========================================
+ Hits         2262     2301      +39     
+ Misses        264      258       -6     
+ Partials      134      127       -7     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ytstudio videos list can return some duplicate rows

1 participant