1
0
mirror of https://github.com/l1ving/youtube-dl synced 2024-11-30 11:05:35 +08:00
youtube-dl/youtube_dl/extractor/weiqitv.py

53 lines
1.6 KiB
Python
Raw Normal View History

2015-12-20 19:09:45 +08:00
# coding: utf-8
from __future__ import unicode_literals
from .common import InfoExtractor
class WeiqiTVIE(InfoExtractor):
2015-12-20 19:09:45 +08:00
IE_DESC = 'WQTV'
_VALID_URL = r'http://www\.weiqitv\.com/index/video_play\?videoId=(?P<id>[A-Za-z0-9]+)'
_TESTS = [{
'url': 'http://www.weiqitv.com/index/video_play?videoId=53c744f09874f0e76a8b46f3',
'md5': '26450599afd64c513bc77030ad15db44',
'info_dict': {
'id': '53c744f09874f0e76a8b46f3',
'ext': 'mp4',
'title': '2013年度盘点',
},
}, {
'url': 'http://www.weiqitv.com/index/video_play?videoId=567379a2d4c36cca518b4569',
'info_dict': {
'id': '567379a2d4c36cca518b4569',
'ext': 'mp4',
'title': '民国围棋史',
},
}, {
'url': 'http://www.weiqitv.com/index/video_play?videoId=5430220a9874f088658b4567',
'info_dict': {
'id': '5430220a9874f088658b4567',
'ext': 'mp4',
'title': '二路托过的手段和运用',
},
}]
def _real_extract(self, url):
media_id = self._match_id(url)
page = self._download_webpage(url, media_id)
info_json_str = self._search_regex(
2016-01-20 04:02:30 +08:00
'var\s+video\s*=\s*(.+});', page, 'info json str')
2015-12-20 19:09:45 +08:00
info_json = self._parse_json(info_json_str, media_id)
letvcloud_url = self._search_regex(
2016-01-20 04:02:30 +08:00
'var\s+letvurl\s*=\s*"([^"]+)', page, 'letvcloud url')
2015-12-20 19:09:45 +08:00
return {
'_type': 'url_transparent',
2016-01-20 04:04:39 +08:00
'ie_key': 'LetvCloud',
2015-12-20 19:09:45 +08:00
'url': letvcloud_url,
'title': info_json['name'],
'id': media_id,
}