weiqitv.py 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. from .common import InfoExtractor
  2. class WeiqiTVIE(InfoExtractor):
  3. IE_DESC = 'WQTV'
  4. _VALID_URL = r'https?://(?:www\.)?weiqitv\.com/index/video_play\?videoId=(?P<id>[A-Za-z0-9]+)'
  5. _TESTS = [{
  6. 'url': 'http://www.weiqitv.com/index/video_play?videoId=53c744f09874f0e76a8b46f3',
  7. 'md5': '26450599afd64c513bc77030ad15db44',
  8. 'info_dict': {
  9. 'id': '53c744f09874f0e76a8b46f3',
  10. 'ext': 'mp4',
  11. 'title': '2013年度盘点',
  12. },
  13. }, {
  14. 'url': 'http://www.weiqitv.com/index/video_play?videoId=567379a2d4c36cca518b4569',
  15. 'info_dict': {
  16. 'id': '567379a2d4c36cca518b4569',
  17. 'ext': 'mp4',
  18. 'title': '民国围棋史',
  19. },
  20. }, {
  21. 'url': 'http://www.weiqitv.com/index/video_play?videoId=5430220a9874f088658b4567',
  22. 'info_dict': {
  23. 'id': '5430220a9874f088658b4567',
  24. 'ext': 'mp4',
  25. 'title': '二路托过的手段和运用',
  26. },
  27. }]
  28. def _real_extract(self, url):
  29. media_id = self._match_id(url)
  30. page = self._download_webpage(url, media_id)
  31. info_json_str = self._search_regex(
  32. r'var\s+video\s*=\s*(.+});', page, 'info json str')
  33. info_json = self._parse_json(info_json_str, media_id)
  34. letvcloud_url = self._search_regex(
  35. r'var\s+letvurl\s*=\s*"([^"]+)', page, 'letvcloud url')
  36. return {
  37. '_type': 'url_transparent',
  38. 'ie_key': 'LetvCloud',
  39. 'url': letvcloud_url,
  40. 'title': info_json['name'],
  41. 'id': media_id,
  42. }