Added a Playlist Info Extractor for WebOfStories
authorShadab Zafar <dufferzafar0@gmail.com>
Fri, 26 Jun 2015 15:57:43 +0000 (21:27 +0530)
committerShadab Zafar <dufferzafar0@gmail.com>
Fri, 26 Jun 2015 15:57:43 +0000 (21:27 +0530)
youtube_dl/extractor/__init__.py
youtube_dl/extractor/webofstories.py

index 46cc4cd0653f5afee4cad5ed7568c1317fd8a3bf..c3f3a3e385f4efb4dd5b0a96b22b608b7d23f746 100644 (file)
@@ -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
index 73077a312549f6b883fdf549a2b364f6de35db9f..d70e30c00a5943eea77b139f6219c0b39fd458f3 100644 (file)
@@ -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<id>[^/]+)'
+    _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'<title>([^<]+)\s*-\s*Web\sof\sStories</title>', webpage, 'title')
+
+        description = self._html_search_meta(
+            'description', webpage, 'description')
+
+        return self.playlist_result(entries, playlist_id, title, description)