소스 검색

[youtube] Fix detection of feeds urls (fixes #1294)

Urls like https://www.youtube.com/feed/watch_later were being as users (before the last changes to YoutubeUserIE, as videos)
Jaime Marquínez Ferrándiz 12 년 전
부모
커밋
faab1d3836
2개의 변경된 파일8개의 추가작업 그리고 2개의 파일을 삭제
  1. 6 0
      test/test_all_urls.py
  2. 2 2
      youtube_dl/extractor/youtube.py

+ 6 - 0
test/test_all_urls.py

@@ -44,6 +44,12 @@ class TestAllURLsMatching(unittest.TestCase):
     def test_youtube_user_matching(self):
     def test_youtube_user_matching(self):
         self.assertMatch('www.youtube.com/NASAgovVideo/videos', ['youtube:user'])
         self.assertMatch('www.youtube.com/NASAgovVideo/videos', ['youtube:user'])
 
 
+    def test_youtube_feeds(self):
+        self.assertMatch('https://www.youtube.com/feed/watch_later', ['youtube:watch_later'])
+        self.assertMatch('https://www.youtube.com/feed/subscriptions', ['youtube:subscriptions'])
+        self.assertMatch('https://www.youtube.com/feed/recommended', ['youtube:recommended'])
+        self.assertMatch('https://www.youtube.com/my_favorites', ['youtube:favorites'])
+
     def test_justin_tv_channelid_matching(self):
     def test_justin_tv_channelid_matching(self):
         self.assertTrue(JustinTVIE.suitable(u"justin.tv/vanillatv"))
         self.assertTrue(JustinTVIE.suitable(u"justin.tv/vanillatv"))
         self.assertTrue(JustinTVIE.suitable(u"twitch.tv/vanillatv"))
         self.assertTrue(JustinTVIE.suitable(u"twitch.tv/vanillatv"))

+ 2 - 2
youtube_dl/extractor/youtube.py

@@ -1015,14 +1015,14 @@ class YoutubeChannelIE(InfoExtractor):
 
 
 class YoutubeUserIE(InfoExtractor):
 class YoutubeUserIE(InfoExtractor):
     IE_DESC = u'YouTube.com user videos (URL or "ytuser" keyword)'
     IE_DESC = u'YouTube.com user videos (URL or "ytuser" keyword)'
-    _VALID_URL = r'(?:(?:(?:https?://)?(?:\w+\.)?youtube\.com/(?:user/)?)|ytuser:)([A-Za-z0-9_-]+)'
+    _VALID_URL = r'(?:(?:(?:https?://)?(?:\w+\.)?youtube\.com/(?:user/)?)|ytuser:)(?!feed/)([A-Za-z0-9_-]+)'
     _TEMPLATE_URL = 'http://gdata.youtube.com/feeds/api/users/%s'
     _TEMPLATE_URL = 'http://gdata.youtube.com/feeds/api/users/%s'
     _GDATA_PAGE_SIZE = 50
     _GDATA_PAGE_SIZE = 50
     _GDATA_URL = 'http://gdata.youtube.com/feeds/api/users/%s/uploads?max-results=%d&start-index=%d&alt=json'
     _GDATA_URL = 'http://gdata.youtube.com/feeds/api/users/%s/uploads?max-results=%d&start-index=%d&alt=json'
     IE_NAME = u'youtube:user'
     IE_NAME = u'youtube:user'
 
 
     def suitable(cls, url):
     def suitable(cls, url):
-        if YoutubeIE.suitable(url): return False
+        if YoutubeIE.suitable(url) or YoutubeFavouritesIE.suitable(url): return False
         else: return super(YoutubeUserIE, cls).suitable(url)
         else: return super(YoutubeUserIE, cls).suitable(url)
 
 
     def _real_extract(self, url):
     def _real_extract(self, url):