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.

36 lines
1.2 KiB

  1. # coding: utf-8
  2. import re
  3. import json
  4. from .common import InfoExtractor
  5. from ..utils import determine_ext
  6. class C56IE(InfoExtractor):
  7. _VALID_URL = r'https?://((www|player)\.)?56\.com/(.+?/)?(v_|(play_album.+-))(?P<textid>.+?)\.(html|swf)'
  8. IE_NAME = u'56.com'
  9. _TEST ={
  10. u'url': u'http://www.56.com/u39/v_OTM0NDA3MTY.html',
  11. u'file': u'93440716.mp4',
  12. u'md5': u'9dc07b5c8e978112a6441f9e75d2b59e',
  13. u'info_dict': {
  14. u'title': u'网事知多少 第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, u'Downloading video info')
  22. info = json.loads(info_page)['info']
  23. best_format = sorted(info['rfiles'], key=lambda f: int(f['filesize']))[-1]
  24. video_url = best_format['url']
  25. return {'id': info['vid'],
  26. 'title': info['Subject'],
  27. 'url': video_url,
  28. 'ext': determine_ext(video_url),
  29. 'thumbnail': info.get('bimg') or info.get('img'),
  30. }