You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

40 lines
1.2 KiB

  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. import re
  4. import json
  5. from .common import InfoExtractor
  6. class C56IE(InfoExtractor):
  7. _VALID_URL = r'https?://((www|player)\.)?56\.com/(.+?/)?(v_|(play_album.+-))(?P<textid>.+?)\.(html|swf)'
  8. IE_NAME = '56.com'
  9. _TEST = {
  10. 'url': 'http://www.56.com/u39/v_OTM0NDA3MTY.html',
  11. 'file': '93440716.flv',
  12. 'md5': 'e59995ac63d0457783ea05f93f12a866',
  13. 'info_dict': {
  14. 'title': '网事知多少 第32期:车怒',
  15. },
  16. }
  17. def _real_extract(self, url):
  18. mobj = re.match(self._VALID_URL, url, flags=re.VERBOSE)
  19. text_id = mobj.group('textid')
  20. info_page = self._download_webpage('http://vxml.56.com/json/%s/' % text_id,
  21. text_id, 'Downloading video info')
  22. info = json.loads(info_page)['info']
  23. formats = [{
  24. 'format_id': f['type'],
  25. 'filesize': int(f['filesize']),
  26. 'url': f['url']
  27. } for f in info['rfiles']]
  28. self._sort_formats(formats)
  29. return {
  30. 'id': info['vid'],
  31. 'title': info['Subject'],
  32. 'formats': formats,
  33. 'thumbnail': info.get('bimg') or info.get('img'),
  34. }