Skip to content

Commit

Permalink
[youtube] Fix youtube mix playlist extraction (closes #26509, closes …
Browse files Browse the repository at this point in the history
…#26390, closes #25465)
  • Loading branch information
glumia committed Sep 6, 2020
1 parent d51e23d commit 1b7ae78
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
4 changes: 2 additions & 2 deletions test/test_youtube_lists.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ def test_youtube_mix(self):
result = ie.extract('https://www.youtube.com/watch?v=W01L70IGBgE&index=2&list=RDOQpdSVF_k_w')
entries = result['entries']
self.assertTrue(len(entries) >= 50)
original_video = entries[0]
self.assertEqual(original_video['id'], 'OQpdSVF_k_w')
original_video_id = 'OQpdSVF_k_w'
self.assertTrue(original_video_id in {entry['id'] for entry in entries})

def test_youtube_toptracks(self):
print('Skipping: The playlist page gives error 500')
Expand Down
3 changes: 1 addition & 2 deletions youtube_dl/extractor/youtube.py
Original file line number Diff line number Diff line change
Expand Up @@ -2781,8 +2781,7 @@ def _extract_mix(self, playlist_id):
webpage = self._download_webpage(
url, playlist_id, 'Downloading page {0} of Youtube mix'.format(n))
new_ids = orderedSet(re.findall(
r'''(?xs)data-video-username=".*?".*?
href="/watch\?v=([0-9A-Za-z_-]{11})&[^"]*?list=%s''' % re.escape(playlist_id),
r'[\'"]/watch\?v=([0-9A-Za-z_-]{11})(?:&|\\u0026)[^"]*?list=%s' % re.escape(playlist_id),
webpage))
# Fetch new pages until all the videos are repeated, it seems that
# there are always 51 unique videos.
Expand Down

2 comments on commit 1b7ae78

@bvdeenen
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am using your patch and it works fine. Did you open a PR on the upstream?

@glumia
Copy link
Owner Author

@glumia glumia commented on 1b7ae78 Oct 10, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @bvdeenen, yes here it is: ytdl-org/youtube-dl#26534

Please sign in to comment.