Skip to content

Commit

Permalink
Let youtube IE handle IDs starting with PL (Closes #572)
Browse files Browse the repository at this point in the history
  • Loading branch information
phihag committed Dec 4, 2012
1 parent 4083bf8 commit e387eb5
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
2 changes: 2 additions & 0 deletions test/test_utils.py
@@ -1,3 +1,5 @@
#!/usr/bin/env python

# Various small unit tests

import sys
Expand Down
22 changes: 22 additions & 0 deletions test/test_youtube_playlist_ids.py
@@ -0,0 +1,22 @@
#!/usr/bin/env python

import sys
import unittest

# Allow direct execution
import os
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))

from youtube_dl.InfoExtractors import YoutubeIE, YoutubePlaylistIE

class TestYoutubePlaylistMatching(unittest.TestCase):
def test_playlist_matching(self):
assert YoutubePlaylistIE().suitable(u'ECUl4u3cNGP61MdtwGTqZA0MreSaDybji8')
assert YoutubePlaylistIE().suitable(u'PL63F0C78739B09958')
assert not YoutubePlaylistIE().suitable(u'PLtS2H6bU1M')

def test_youtube_matching(self):
assert YoutubeIE().suitable(u'PLtS2H6bU1M')

if __name__ == '__main__':
unittest.main()
2 changes: 1 addition & 1 deletion youtube_dl/InfoExtractors.py
Expand Up @@ -1671,7 +1671,7 @@ def _download_n_results(self, query, n):
class YoutubePlaylistIE(InfoExtractor):
"""Information Extractor for YouTube playlists."""

_VALID_URL = r'(?:(?:https?://)?(?:\w+\.)?youtube\.com/(?:(?:course|view_play_list|my_playlists|artist|playlist)\?.*?(p|a|list)=|user/.*?/user/|p/|user/.*?#[pg]/c/)(?:PL|EC)?|PL|EC)([0-9A-Za-z-_]+)(?:/.*?/([0-9A-Za-z_-]+))?.*'
_VALID_URL = r'(?:(?:https?://)?(?:\w+\.)?youtube\.com/(?:(?:course|view_play_list|my_playlists|artist|playlist)\?.*?(p|a|list)=|user/.*?/user/|p/|user/.*?#[pg]/c/)(?:PL|EC)?|PL|EC)([0-9A-Za-z-_]{10,})(?:/.*?/([0-9A-Za-z_-]+))?.*'
_TEMPLATE_URL = 'http://www.youtube.com/%s?%s=%s&page=%s&gl=US&hl=en'
_VIDEO_INDICATOR_TEMPLATE = r'/watch\?v=(.+?)&([^&"]+&)*list=.*?%s'
_MORE_PAGES_INDICATOR = r'yt-uix-pager-next'
Expand Down

0 comments on commit e387eb5

Please sign in to comment.