weiqitv.py 1.7 KB

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