[Letv] Add playlist support
authorYen Chi Hsuan <yan12125@gmail.com>
Tue, 24 Feb 2015 16:45:11 +0000 (00:45 +0800)
committerYen Chi Hsuan <yan12125@gmail.com>
Tue, 24 Feb 2015 17:26:44 +0000 (01:26 +0800)
youtube_dl/extractor/__init__.py
youtube_dl/extractor/letv.py

index 829ab18a99ffab978756d1635ed41fa00ebea115..7b7d41adf1ec8b6f06789c633f5e8167901f3034 100644 (file)
@@ -237,7 +237,11 @@ from .krasview import KrasViewIE
 from .ku6 import Ku6IE
 from .la7 import LA7IE
 from .laola1tv import Laola1TvIE
-from .letv import LetvIE
+from .letv import (
+    LetvIE,
+    LetvTvIE,
+    LetvPlaylistIE
+)
 from .lifenews import LifeNewsIE
 from .liveleak import LiveLeakIE
 from .livestream import (
index 3eb20678eda3a40d53abdadb3a6498ebf1b214ac..d7d3156346afdb4c4314ba4cac5e33e9186fead6 100644 (file)
@@ -2,6 +2,7 @@
 from __future__ import unicode_literals
 
 import os.path
+import re
 import time
 import datetime
 
@@ -11,7 +12,7 @@ from ..utils import (ExtractorError, parse_iso8601)
 
 
 class LetvIE(InfoExtractor):
-    _VALID_URL = r'http://www.letv.com/ptv/vplay/(?P<id>\d+).html'
+    _VALID_URL = r'http://www\.letv\.com/ptv/vplay/(?P<id>\d+).html'
 
     _TESTS = [{
         'url': 'http://www.letv.com/ptv/vplay/22005890.html',
@@ -118,3 +119,54 @@ class LetvIE(InfoExtractor):
             'thumbnail': playurl['pic'],
             'timestamp': publish_time,
         }
+
+
+class LetvTvIE(InfoExtractor):
+    _VALID_URL = r'http://www.letv.com/tv/(?P<id>\d+).html'
+    _TESTS = [{
+        'url': 'http://www.letv.com/tv/46177.html',
+        'info_dict': {
+            'id': '46177',
+            'title': '美人天下',
+            'description': 'md5:395666ff41b44080396e59570dbac01c'
+        },
+        'playlist_count': 35
+    }]
+
+    def _real_extract(self, url):
+        playlist_id = self._match_id(url)
+        page = self._download_webpage(url, playlist_id)
+
+        media_urls = list(set(re.findall(
+            r'http://www.letv.com/ptv/vplay/\d+.html', page)))
+        entries = [self.url_result(media_url, ie='Letv')
+                   for media_url in media_urls]
+
+        title = self._html_search_meta('keywords', page, fatal=False).split(',')[0]
+        description = self._html_search_meta('description', page, fatal=False)
+
+        return self.playlist_result(entries, playlist_id, playlist_title=title,
+                                    playlist_description=description)
+
+
+class LetvPlaylistIE(LetvTvIE):
+    _VALID_URL = r'http://tv.letv.com/[a-z]+/(?P<id>[a-z]+)/index.s?html'
+    _TESTS = [{
+        'url': 'http://tv.letv.com/izt/wuzetian/index.html',
+        'info_dict': {
+            'id': 'wuzetian',
+            'title': '武媚娘传奇',
+            'description': 'md5:e12499475ab3d50219e5bba00b3cb248'
+        },
+        'playlist_count': 96
+    }, {
+        'url': 'http://tv.letv.com/pzt/lswjzzjc/index.shtml',
+        'info_dict': {
+            'id': 'lswjzzjc',
+            # should be "劲舞青春", but I can't find a simple way to determine
+            # the playlist title
+            'title': '乐视午间自制剧场',
+            'description': 'md5:b1eef244f45589a7b5b1af9ff25a4489'
+        },
+        'playlist_mincount': 7
+    }]