]>
Commit | Line | Data |
---|---|---|
e2b06e76 | 1 | from .common import InfoExtractor |
1cc79574 | 2 | from ..compat import ( |
e2b06e76 | 3 | compat_urllib_parse, |
1cc79574 PH |
4 | ) |
5 | from ..utils import ( | |
0dae5083 | 6 | unified_strdate, |
e2b06e76 PH |
7 | ) |
8 | ||
9 | ||
10 | class UrortIE(InfoExtractor): | |
11 | IE_DESC = 'NRK P3 Urørt' | |
12 | _VALID_URL = r'https?://(?:www\.)?urort\.p3\.no/#!/Band/(?P<id>[^/]+)$' | |
13 | ||
14 | _TEST = { | |
15 | 'url': 'https://urort.p3.no/#!/Band/Gerilja', | |
16 | 'md5': '5ed31a924be8a05e47812678a86e127b', | |
17 | 'info_dict': { | |
baa7081d | 18 | 'id': '33124-24', |
e2b06e76 PH |
19 | 'ext': 'mp3', |
20 | 'title': 'The Bomb', | |
ec85ded8 | 21 | 'thumbnail': r're:^https?://.+\.jpg', |
e2b06e76 PH |
22 | 'uploader': 'Gerilja', |
23 | 'uploader_id': 'Gerilja', | |
0dae5083 | 24 | 'upload_date': '20100323', |
e2b06e76 PH |
25 | }, |
26 | 'params': { | |
27 | 'matchtitle': '^The Bomb$', # To test, we want just one video | |
28 | } | |
29 | } | |
30 | ||
31 | def _real_extract(self, url): | |
6a1b20de | 32 | playlist_id = self._match_id(url) |
e2b06e76 PH |
33 | |
34 | fstr = compat_urllib_parse.quote("InternalBandUrl eq '%s'" % playlist_id) | |
baa7081d | 35 | json_url = 'http://urort.p3.no/breeze/urort/TrackDTOViews?$filter=%s&$orderby=Released%%20desc&$expand=Tags%%2CFiles' % fstr |
e2b06e76 | 36 | songs = self._download_json(json_url, playlist_id) |
baa7081d PH |
37 | entries = [] |
38 | for s in songs: | |
39 | formats = [{ | |
40 | 'tbr': f.get('Quality'), | |
41 | 'ext': f['FileType'], | |
42 | 'format_id': '%s-%s' % (f['FileType'], f.get('Quality', '')), | |
43 | 'url': 'http://p3urort.blob.core.windows.net/tracks/%s' % f['FileRef'], | |
f983b875 | 44 | 'quality': 3 if f['FileType'] == 'mp3' else 2, |
baa7081d PH |
45 | } for f in s['Files']] |
46 | self._sort_formats(formats) | |
47 | e = { | |
48 | 'id': '%d-%s' % (s['BandId'], s['$id']), | |
49 | 'title': s['Title'], | |
50 | 'uploader_id': playlist_id, | |
51 | 'uploader': s.get('BandName', playlist_id), | |
52 | 'thumbnail': 'http://urort.p3.no/cloud/images/%s' % s['Image'], | |
53 | 'upload_date': unified_strdate(s.get('Released')), | |
54 | 'formats': formats, | |
55 | } | |
56 | entries.append(e) | |
e2b06e76 PH |
57 | |
58 | return { | |
59 | '_type': 'playlist', | |
60 | 'id': playlist_id, | |
61 | 'title': playlist_id, | |
62 | 'entries': entries, | |
63 | } |