plugin.video.youtube
plugin.video.youtube copied to clipboard
Manage history and other playlists that hit 5000 items
What Problem Does This Solve?
When playlists reach 5000 items, the API returns a playlistContainsMaximumNumberOfVideos error, per:
info <general>: [plugin.video.youtube] Running: YouTube (7.0.5+beta.1+matrix.1) on Nexus (Kodi-20.3) with Python 3.9.2
Path: /special/new_uploaded_videos_tv/
Params: {'category_label': 'My Subscriptions'}
error <general>: [plugin.video.youtube] API error: playlistContainsMaximumNumberOfVideos
exc: |"error" in response JSON data|
message: |Playlist contains maximum number of items.|
Request response:
{'error': {'code': 403, 'message': 'Playlist contains maximum number of items.', 'errors': [{'message': 'Playlist contains maximum number of items.', 'domain': 'youtube.playlistItem', 'reason': 'playlistContainsMaximumNumberOfVideos'}]}}
The offending playlist here is the custom History playlist, despite the call being to get "My Subscriptions".
Suggest a Solution (optional)
The offending playlist appears to still update on a FIFO basis.
Consider suppressing the error. Such a solution retains the content without producing an event for every API touch. This is notably useful for History playlists.
Alternative solutions might include the following (or similar) maintenance task(s) - perhaps by context menu under Playlists:
- Delete the oldest 200 videos (200 due to reports that YT rate limits mass deletions);
- Delete the playlist and recreate an empty one. For History and Watch Later, also update the custom playlist IDs.
I can't see how the playlistItems.insert
method can be reached by accessing My Subscriptions.
Did you just finish playback and just happen to navigate back to the directory listing at the same time by any chance? Thats really the only way it can happen, if you have the custom history playlist set, then it will update in the background as part of the player monitor thread.
Going to revisit this when the migration away from the data api is done, and see what limitations arise when using the innertube api instead, but if the playlist did still update then the only feasible solution would be to surpress the error as you can't delete multiple items from a playlist using the data api, and each mutation uses up 50 quota units. Creating a new history playlist by time period or item count is an interesting option, but managing it from different devices becomes tricky, and it may not be necessary when using the innertube api.
I can't see how the
playlistItems.insert
method can be reached by accessing My Subscriptions.Did you just finish playback and just happen to navigate back to the directory listing at the same time by any chance? Thats really the only way it can happen, if you have the custom history playlist set, then it will update in the background as part of the player monitor thread.
Yes, that makes sense. It occurs when playback finishes and the history playlist is updated. As such, in the example above, it must be coincidental that the My Subscriptions listing is being displayed at the time the notification pops.
If using the innertube API, does YT's builtin history work anyway?
My bad, time stamps probably would have helped.
All good.
If using the innertube API, does YT's builtin history work anyway?
If you are logged in and enable Settings > Advanced > History - Update playback history on Youtube
then the history already works and you can see your history get updated on an official client when logged in.
What doesn't currently work is displaying that history in this plugin. Using the V1 InnerTube API will allow that to work.
The way to manage this issue is to manually maintain playlists below the YT limit of 5000 items.
The issue relating to viewing YT's server side history aside, I'll close this one as not planned.