logo

youtube-dl

[mirror] Download/Watch videos from video hostersgit clone https://hacktivis.me/git/mirror/youtube-dl.git

tudou.py (1699B)


  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. from .common import InfoExtractor
  4. class TudouPlaylistIE(InfoExtractor):
  5. IE_NAME = 'tudou:playlist'
  6. _VALID_URL = r'https?://(?:www\.)?tudou\.com/listplay/(?P<id>[\w-]{11})\.html'
  7. _TESTS = [{
  8. 'url': 'http://www.tudou.com/listplay/zzdE77v6Mmo.html',
  9. 'info_dict': {
  10. 'id': 'zzdE77v6Mmo',
  11. },
  12. 'playlist_mincount': 209,
  13. }]
  14. def _real_extract(self, url):
  15. playlist_id = self._match_id(url)
  16. playlist_data = self._download_json(
  17. 'http://www.tudou.com/tvp/plist.action?lcode=%s' % playlist_id, playlist_id)
  18. entries = [self.url_result(
  19. 'http://www.tudou.com/programs/view/%s' % item['icode'],
  20. 'Tudou', item['icode'],
  21. item['kw']) for item in playlist_data['items']]
  22. return self.playlist_result(entries, playlist_id)
  23. class TudouAlbumIE(InfoExtractor):
  24. IE_NAME = 'tudou:album'
  25. _VALID_URL = r'https?://(?:www\.)?tudou\.com/album(?:cover|play)/(?P<id>[\w-]{11})'
  26. _TESTS = [{
  27. 'url': 'http://www.tudou.com/albumplay/v5qckFJvNJg.html',
  28. 'info_dict': {
  29. 'id': 'v5qckFJvNJg',
  30. },
  31. 'playlist_mincount': 45,
  32. }]
  33. def _real_extract(self, url):
  34. album_id = self._match_id(url)
  35. album_data = self._download_json(
  36. 'http://www.tudou.com/tvp/alist.action?acode=%s' % album_id, album_id)
  37. entries = [self.url_result(
  38. 'http://www.tudou.com/programs/view/%s' % item['icode'],
  39. 'Tudou', item['icode'],
  40. item['kw']) for item in album_data['items']]
  41. return self.playlist_result(entries, album_id)