[thvideo] Add support for playlists
authorAnton Larionov <diffident.cat@gmail.com>
Sun, 28 Sep 2014 19:36:55 +0000 (23:36 +0400)
committerAnton Larionov <diffident.cat@gmail.com>
Sun, 28 Sep 2014 19:36:55 +0000 (23:36 +0400)
youtube_dl/extractor/__init__.py
youtube_dl/extractor/thvideo.py

index 86bff185b40db1680593e0c6a96b0a7dcd5dd928..89a9d8106ce1f14bdc0ae04c0aa1669d6564dc2a 100644 (file)
@@ -371,7 +371,10 @@ from .thisav import ThisAVIE
 from .tinypic import TinyPicIE
 from .tlc import TlcIE, TlcDeIE
 from .tnaflix import TNAFlixIE
-from .thvideo import THVideoIE
+from .thvideo import (
+    THVideoIE,
+    THVideoPlaylistIE
+)
 from .toutv import TouTvIE
 from .toypics import ToypicsUserIE, ToypicsIE
 from .traileraddict import TrailerAddictIE
index 607e947bbaf506c71814cd5a36ff3851f3afbb91..0ae20ea30bc307e014f63bc31c1288945b9a4046 100644 (file)
@@ -57,3 +57,27 @@ class THVideoIE(InfoExtractor):
             'description': description,
             'upload_date': upload_date
         }
+
+
+class THVideoPlaylistIE(InfoExtractor):
+    _VALID_URL = r'http?://(?:www\.)?thvideo\.tv/mylist(?P<id>[0-9]+)'
+    _TEST = {
+        'url': 'http://thvideo.tv/mylist2',
+        'info_dict': {
+            'id': '2',
+            'title': '幻想万華鏡',
+        },
+        'playlist_mincount': 23,
+    }
+
+    def _real_extract(self, url):
+        webpage = self._download_webpage(url, 'playlist')
+        mobj = re.match(self._VALID_URL, url)
+        list_id = mobj.group('id')
+        list_title = self._html_search_regex(r'<h1 class="show_title">(.*?)<b id', webpage, 'playlist title')
+
+        entries = [
+            self.url_result('http://thvideo.tv/v/th' + id, 'THVideo')
+            for id in re.findall(r'<dd><a href="http://thvideo.tv/v/th(\d+)/" target=', webpage)]
+
+        return self.playlist_result(entries, list_id, list_title)
\ No newline at end of file