]>
Commit | Line | Data |
---|---|---|
6daaf210 R |
1 | from .common import InfoExtractor |
2 | from .youtube import YoutubeIE | |
3 | from ..utils import traverse_obj | |
4 | ||
5 | ||
6 | class DiscogsReleasePlaylistIE(InfoExtractor): | |
7 | _VALID_URL = r'https?://(?:www\.)?discogs\.com/(?P<type>release|master)/(?P<id>\d+)' | |
8 | _TESTS = [{ | |
9 | 'url': 'https://www.discogs.com/release/1-The-Persuader-Stockholm', | |
10 | 'info_dict': { | |
11 | 'id': 'release1', | |
12 | 'title': 'Stockholm', | |
13 | }, | |
14 | 'playlist_mincount': 7, | |
15 | }, { | |
16 | 'url': 'https://www.discogs.com/master/113-Vince-Watson-Moments-In-Time', | |
17 | 'info_dict': { | |
18 | 'id': 'master113', | |
19 | 'title': 'Moments In Time', | |
20 | }, | |
21 | 'playlist_mincount': 53, | |
22 | }] | |
23 | ||
24 | def _real_extract(self, url): | |
25 | playlist_id, playlist_type = self._match_valid_url(url).group('id', 'type') | |
26 | ||
27 | display_id = f'{playlist_type}{playlist_id}' | |
28 | response = self._download_json( | |
29 | f'https://api.discogs.com/{playlist_type}s/{playlist_id}', display_id) | |
30 | ||
31 | entries = [ | |
32 | self.url_result(video['uri'], YoutubeIE, video_title=video.get('title')) | |
33 | for video in traverse_obj(response, ('videos', lambda _, v: YoutubeIE.suitable(v['uri'])))] | |
34 | ||
35 | return self.playlist_result(entries, display_id, response.get('title')) |