]> git.bitcoin.ninja Git - youtube-dl/blob - youtube_dl/extractor/weiqitv.py
Merge branch 'Weiqitv' of https://github.com/FounderSG/youtube-dl into FounderSG...
[youtube-dl] / youtube_dl / extractor / weiqitv.py
1 # coding: utf-8
2 from __future__ import unicode_literals
3
4 from .common import InfoExtractor
5
6
7 class WeiqitvIE(InfoExtractor):
8     IE_DESC = 'WQTV'
9     _VALID_URL = r'http://www\.weiqitv\.com/index/video_play\?videoId=(?P<id>[A-Za-z0-9]+)'
10
11     _TESTS = [{
12         'url': 'http://www.weiqitv.com/index/video_play?videoId=53c744f09874f0e76a8b46f3',
13         'md5': '26450599afd64c513bc77030ad15db44',
14         'info_dict': {
15             'id': '53c744f09874f0e76a8b46f3',
16             'ext': 'mp4',
17             'title': '2013年度盘点',
18         },
19     }, {
20         'url': 'http://www.weiqitv.com/index/video_play?videoId=567379a2d4c36cca518b4569',
21         'info_dict': {
22             'id': '567379a2d4c36cca518b4569',
23             'ext': 'mp4',
24             'title': '民国围棋史',
25         },
26     }, {
27         'url': 'http://www.weiqitv.com/index/video_play?videoId=5430220a9874f088658b4567',
28         'info_dict': {
29             'id': '5430220a9874f088658b4567',
30             'ext': 'mp4',
31             'title': '二路托过的手段和运用',
32         },
33     }]
34
35     def _real_extract(self, url):
36         media_id = self._match_id(url)
37         page = self._download_webpage(url, media_id)
38
39         info_json_str = self._search_regex(
40             'var\s+video\s*=\s*(.+});',
41             page, 'info_json_str')
42         info_json = self._parse_json(info_json_str, media_id)
43
44         letvcloud_url = self._search_regex(
45             'var\s+letvurl\s*=\s*"([^"]+)',
46             page, 'letvcloud_url')
47
48         return {
49             '_type': 'url_transparent',
50             "ie_key": 'LetvCloud',
51             'url': letvcloud_url,
52             'title': info_json['name'],
53             'id': media_id,
54         }