Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for Playlist Extraction Issue with YouTube Shorts #63

Open
ndyanx opened this issue May 8, 2024 · 0 comments
Open

Fix for Playlist Extraction Issue with YouTube Shorts #63

ndyanx opened this issue May 8, 2024 · 0 comments

Comments

@ndyanx
Copy link

ndyanx commented May 8, 2024

Issue Description

When attempting to extract videos from a YouTube playlist that contains only Shorts(example: https://www.youtube.com/playlist?list=PLxPmekEwS6-bF6AWu3prP2iRltY6Oslrw) using the get_videos function with the playlistVideoRenderer parameter, the function fails to capture any videos. This issue does not occur with playlists containing regular videos or a mix of videos and Shorts.

Steps to Reproduce

  1. Call the get_videos function with a playlist URL that contains only YouTube Shorts.
  2. Use playlistVideoRenderer as the renderer parameter.
  3. Iterate over the generator to yield videos.

Expected Behavior

The function should capture and yield videos from the playlist, regardless of whether they are Shorts or regular videos.

Actual Behavior

No videos are captured or yielded when the playlist consists solely of Shorts.

Solution

A conditional check was implemented to solve this issue. If no videos are captured with playlistVideoRenderer, the function will attempt to use reelItemRenderer instead. Here is the updated code snippet that addresses the problem:

videos = get_videos(url, api_endpoint, "playlistVideoRenderer", limit, sleep)
if not any(videos):  # Check if the generator is empty
    videos = get_videos(url, api_endpoint, "reelItemRenderer", limit, sleep)
for video in videos:
    yield video
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

No branches or pull requests

1 participant