From de906ef54373bcc397895f770992854004248cc4 Mon Sep 17 00:00:00 2001 From: Philipp Hagemeister Date: Sun, 13 Apr 2014 03:19:56 +0200 Subject: [PATCH] [aol] Add support for playlists (Fixes #2730) --- test/test_all_urls.py | 1 - test/test_playlists.py | 11 ++++++++++ youtube_dl/extractor/aol.py | 41 +++++++++++++++++++++++++++++++++++-- 3 files changed, 50 insertions(+), 3 deletions(-) diff --git a/test/test_all_urls.py b/test/test_all_urls.py index d180f23cc..7f7362a3a 100644 --- a/test/test_all_urls.py +++ b/test/test_all_urls.py @@ -176,6 +176,5 @@ class TestAllURLsMatching(unittest.TestCase): 'https://screen.yahoo.com/smartwatches-latest-wearable-gadgets-163745379-cbs.html', ['Yahoo']) - if __name__ == '__main__': unittest.main() diff --git a/test/test_playlists.py b/test/test_playlists.py index 75c6a6bbb..17f1e5fab 100644 --- a/test/test_playlists.py +++ b/test/test_playlists.py @@ -43,6 +43,7 @@ from youtube_dl.extractor import ( XTubeUserIE, InstagramUserIE, CSpanIE, + AolIE, ) @@ -327,6 +328,16 @@ class TestPlaylists(unittest.TestCase): whole_duration = sum(e['duration'] for e in result['entries']) self.assertEqual(whole_duration, 14855) + def test_aol_playlist(self): + dl = FakeYDL() + ie = AolIE(dl) + result = ie.extract( + 'http://on.aol.com/playlist/brace-yourself---todays-weirdest-news-152147?icid=OnHomepageC4_Omg_Img#_videoid=518184316') + self.assertIsPlaylist(result) + self.assertEqual(result['id'], '152147') + self.assertEqual( + result['title'], 'Brace Yourself - Today\'s Weirdest News') + self.assertTrue(len(result['entries']) >= 10) if __name__ == '__main__': unittest.main() diff --git a/youtube_dl/extractor/aol.py b/youtube_dl/extractor/aol.py index abc668912..a7bfe5a5c 100644 --- a/youtube_dl/extractor/aol.py +++ b/youtube_dl/extractor/aol.py @@ -8,7 +8,18 @@ from .fivemin import FiveMinIE class AolIE(InfoExtractor): IE_NAME = 'on.aol.com' - _VALID_URL = r'http://on\.aol\.com/video/.*-(?P\d+)($|\?)' + _VALID_URL = r'''(?x) + (?: + aol-video:| + http://on\.aol\.com/ + (?: + video/.*-| + playlist/(?P[^/?#]+?)-(?P[0-9]+)[?#].*_videoid= + ) + ) + (?P[0-9]+) + (?:$|\?) + ''' _TEST = { 'url': 'http://on.aol.com/video/u-s--official-warns-of-largest-ever-irs-phone-scam-518167793?icid=OnHomepageC2Wide_MustSee_Img', @@ -24,5 +35,31 @@ class AolIE(InfoExtractor): def _real_extract(self, url): mobj = re.match(self._VALID_URL, url) video_id = mobj.group('id') - self.to_screen('Downloading 5min.com video %s' % video_id) + + playlist_id = mobj.group('playlist_id') + if playlist_id and not self._downloader.params.get('noplaylist'): + self.to_screen('Downloading playlist %s - add --no-playlist to just download video %s' % (playlist_id, video_id)) + + webpage = self._download_webpage(url, playlist_id) + title = self._html_search_regex( + r'

(.+?)

', webpage, 'title') + playlist_html = self._search_regex( + r"(?s)(.*?)", webpage, + 'playlist HTML') + entries = [{ + '_type': 'url', + 'url': 'aol-video:%s' % m.group('id'), + 'ie_key': 'Aol', + } for m in re.finditer( + r"[0-9]+)'\s+class='video-thumb'>", + playlist_html)] + + return { + '_type': 'playlist', + 'id': playlist_id, + 'display_id': mobj.group('playlist_display_id'), + 'title': title, + 'entries': entries, + } + return FiveMinIE._build_result(video_id)