weibo.py 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. # coding: utf-8
  2. import re
  3. from .common import InfoExtractor
  4. class WeiboIE(InfoExtractor):
  5. """
  6. The videos in Weibo come from different sites, this IE just finds the link
  7. to the external video and returns it.
  8. """
  9. _VALID_URL = r'https?://video\.weibo\.com/v/weishipin/t_(?P<id>.+?)\.htm'
  10. _TEST = {
  11. u'url': u'http://video.weibo.com/v/weishipin/t_zjUw2kZ.htm',
  12. u'file': u'98322879.flv',
  13. u'info_dict': {
  14. u'title': u'魔声耳机最新广告“All Eyes On Us”',
  15. },
  16. u'note': u'Sina video',
  17. u'params': {
  18. u'skip_download': True,
  19. },
  20. }
  21. # Additional example videos from different sites
  22. # Youku: http://video.weibo.com/v/weishipin/t_zQGDWQ8.htm
  23. # 56.com: http://video.weibo.com/v/weishipin/t_zQ44HxN.htm
  24. def _real_extract(self, url):
  25. mobj = re.match(self._VALID_URL, url, flags=re.VERBOSE)
  26. video_id = mobj.group('id')
  27. webpage = self._download_webpage(url, video_id)
  28. player_url = self._search_regex(r'var defaultPlayer="(.+?)"', webpage,
  29. u'player url')
  30. return self.url_result(player_url)