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