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.

32 lines
1.3 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. def _real_extract(self, url):
  6. mobj = re.match(self._VALID_URL, url)
  7. video_id = mobj.group(2).replace('.html','')
  8. webpage = self._download_webpage(url, video_id)
  9. video_id = re.search('"k":(.+?),',webpage).group(1)
  10. title = re.search(",kw:\"(.+)\"",webpage)
  11. if title is None:
  12. title = re.search(",kw: \'(.+)\'",webpage)
  13. title = title.group(1)
  14. thumbnail_url = re.search(",pic: \'(.+?)\'",webpage)
  15. if thumbnail_url is None:
  16. thumbnail_url = re.search(",pic:\"(.+?)\"",webpage)
  17. thumbnail_url = thumbnail_url.group(1)
  18. info_url = "http://v2.tudou.com/f?id="+str(video_id)
  19. webpage = self._download_webpage(info_url, video_id, "Opening the info webpage")
  20. final_url = re.search('\>(.+?)\<\/f\>',webpage).group(1)
  21. ext = (final_url.split('?')[0]).split('.')[-1]
  22. return [{
  23. 'id': video_id,
  24. 'url': final_url,
  25. 'ext': ext,
  26. 'title': title,
  27. 'thumbnail': thumbnail_url,
  28. }]