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