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