From 2028c6e03d7e254831350081bb4b4741b0b47ac4 Mon Sep 17 00:00:00 2001 From: Shadab Zafar Date: Fri, 26 Jun 2015 21:27:43 +0530 Subject: [PATCH 1/2] Added a Playlist Info Extractor for WebOfStories --- youtube_dl/extractor/__init__.py | 5 ++++- youtube_dl/extractor/webofstories.py | 25 +++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/youtube_dl/extractor/__init__.py b/youtube_dl/extractor/__init__.py index 46cc4cd06..c3f3a3e38 100644 --- a/youtube_dl/extractor/__init__.py +++ b/youtube_dl/extractor/__init__.py @@ -693,7 +693,10 @@ from .wdr import ( WDRMobileIE, WDRMausIE, ) -from .webofstories import WebOfStoriesIE +from .webofstories import ( + WebOfStoriesIE, + WebOfStoriesPlaylistIE, +) from .weibo import WeiboIE from .wimp import WimpIE from .wistia import WistiaIE diff --git a/youtube_dl/extractor/webofstories.py b/youtube_dl/extractor/webofstories.py index 73077a312..d70e30c00 100644 --- a/youtube_dl/extractor/webofstories.py +++ b/youtube_dl/extractor/webofstories.py @@ -1,6 +1,8 @@ # coding: utf-8 from __future__ import unicode_literals +import re + from .common import InfoExtractor from ..utils import int_or_none @@ -98,3 +100,26 @@ class WebOfStoriesIE(InfoExtractor): 'description': description, 'duration': duration, } + + +class WebOfStoriesPlaylistIE(InfoExtractor): + _VALID_URL = r'https?://(?:www\.)?webofstories\.com/playAll/(?P[^/]+)' + _TESTS = [] + + def _real_extract(self, url): + playlist_id = self._match_id(url) + + webpage = self._download_webpage(url, playlist_id) + + entries = [ + self.url_result('http://www.webofstories.com/play/%s' % video_number, 'WebOfStories') + for video_number in set(re.findall('href="/playAll/%s\?sId=(\d+)"' % playlist_id, webpage)) + ] + + title = self._html_search_regex( + r'([^<]+)\s*-\s*Web\sof\sStories', webpage, 'title') + + description = self._html_search_meta( + 'description', webpage, 'description') + + return self.playlist_result(entries, playlist_id, title, description) From fac54cb426d85572c6928ce0d9e5bf1efb459548 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergey=20M=E2=80=A4?= Date: Sat, 11 Jul 2015 04:43:29 +0600 Subject: [PATCH 2/2] [webofstories:playlist] Improve and add test --- youtube_dl/extractor/webofstories.py | 32 +++++++++++++++++++++------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/youtube_dl/extractor/webofstories.py b/youtube_dl/extractor/webofstories.py index d70e30c00..2037d9b3d 100644 --- a/youtube_dl/extractor/webofstories.py +++ b/youtube_dl/extractor/webofstories.py @@ -104,7 +104,14 @@ class WebOfStoriesIE(InfoExtractor): class WebOfStoriesPlaylistIE(InfoExtractor): _VALID_URL = r'https?://(?:www\.)?webofstories\.com/playAll/(?P[^/]+)' - _TESTS = [] + _TEST = { + 'url': 'http://www.webofstories.com/playAll/donald.knuth', + 'info_dict': { + 'id': 'donald.knuth', + 'title': 'Donald Knuth (Scientist)', + }, + 'playlist_mincount': 97, + } def _real_extract(self, url): playlist_id = self._match_id(url) @@ -116,10 +123,19 @@ class WebOfStoriesPlaylistIE(InfoExtractor): for video_number in set(re.findall('href="/playAll/%s\?sId=(\d+)"' % playlist_id, webpage)) ] - title = self._html_search_regex( - r'([^<]+)\s*-\s*Web\sof\sStories', webpage, 'title') - - description = self._html_search_meta( - 'description', webpage, 'description') - - return self.playlist_result(entries, playlist_id, title, description) + title = self._search_regex( + r'
\s*([^<]+)', + webpage, 'speaker', default=None) + if title: + field = self._search_regex( + r'([^<]+)', + webpage, 'field', default=None) + if field: + title += ' (%s)' % field + + if not title: + title = self._search_regex( + r'Play\s+all\s+stories\s*-\s*([^<]+)\s*-\s*Web\s+of\s+Stories', + webpage, 'title') + + return self.playlist_result(entries, playlist_id, title)