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.

47 lines
1.3 KiB

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