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.6 KiB

  1. import re
  2. from .common import InfoExtractor
  3. class TudouIE(InfoExtractor):
  4. _VALID_URL = r'(?:http://)?(?:www\.)?tudou\.com/(?:listplay|programs)/(?:view|(.+?))/(?:([^/]+)|([^/]+)\.html)'
  5. _TEST = {
  6. u'url': u'http://www.tudou.com/listplay/zzdE77v6Mmo/2xN2duXMxmw.html',
  7. u'file': u'159447792.f4v',
  8. u'md5': u'ad7c358a01541e926a1e413612c6b10a',
  9. u'info_dict': {
  10. u"title": u"\u5361\u9a6c\u4e54\u56fd\u8db3\u5f00\u5927\u811a\u957f\u4f20\u51b2\u540a\u96c6\u9526"
  11. }
  12. }
  13. def _real_extract(self, url):
  14. mobj = re.match(self._VALID_URL, url)
  15. video_id = mobj.group(2).replace('.html','')
  16. webpage = self._download_webpage(url, video_id)
  17. video_id = re.search('"k":(.+?),',webpage).group(1)
  18. title = re.search(",kw:\"(.+)\"",webpage)
  19. if title is None:
  20. title = re.search(",kw: \'(.+)\'",webpage)
  21. title = title.group(1)
  22. thumbnail_url = re.search(",pic: \'(.+?)\'",webpage)
  23. if thumbnail_url is None:
  24. thumbnail_url = re.search(",pic:\"(.+?)\"",webpage)
  25. thumbnail_url = thumbnail_url.group(1)
  26. info_url = "http://v2.tudou.com/f?id="+str(video_id)
  27. webpage = self._download_webpage(info_url, video_id, "Opening the info webpage")
  28. final_url = re.search('\>(.+?)\<\/f\>',webpage).group(1)
  29. ext = (final_url.split('?')[0]).split('.')[-1]
  30. return [{
  31. 'id': video_id,
  32. 'url': final_url,
  33. 'ext': ext,
  34. 'title': title,
  35. 'thumbnail': thumbnail_url,
  36. }]