]> jfr.im git - yt-dlp.git/blame - yt_dlp/extractor/urort.py
[cleanup] Consistent style for file heads
[yt-dlp.git] / yt_dlp / extractor / urort.py
CommitLineData
ac668111 1import urllib.parse
2
e2b06e76 3from .common import InfoExtractor
ac668111 4from ..utils import unified_strdate
e2b06e76
PH
5
6
7class 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
PH
42 } for f in s['Files']]
43 self._sort_formats(formats)
44 e = {
45 'id': '%d-%s' % (s['BandId'], s['$id']),
46 'title': s['Title'],
47 'uploader_id': playlist_id,
48 'uploader': s.get('BandName', playlist_id),
49 'thumbnail': 'http://urort.p3.no/cloud/images/%s' % s['Image'],
50 'upload_date': unified_strdate(s.get('Released')),
51 'formats': formats,
52 }
53 entries.append(e)
e2b06e76
PH
54
55 return {
56 '_type': 'playlist',
57 'id': playlist_id,
58 'title': playlist_id,
59 'entries': entries,
60 }