]> jfr.im git - yt-dlp.git/blame - yt_dlp/extractor/urort.py
[ie/orf:on] Improve extraction (#9677)
[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):
df773c3d 8 _WORKING = False
e2b06e76
PH
9 IE_DESC = 'NRK P3 Urørt'
10 _VALID_URL = r'https?://(?:www\.)?urort\.p3\.no/#!/Band/(?P<id>[^/]+)$'
11
12 _TEST = {
13 'url': 'https://urort.p3.no/#!/Band/Gerilja',
14 'md5': '5ed31a924be8a05e47812678a86e127b',
15 'info_dict': {
baa7081d 16 'id': '33124-24',
e2b06e76
PH
17 'ext': 'mp3',
18 'title': 'The Bomb',
ec85ded8 19 'thumbnail': r're:^https?://.+\.jpg',
e2b06e76
PH
20 'uploader': 'Gerilja',
21 'uploader_id': 'Gerilja',
0dae5083 22 'upload_date': '20100323',
e2b06e76
PH
23 },
24 'params': {
25 'matchtitle': '^The Bomb$', # To test, we want just one video
26 }
27 }
28
29 def _real_extract(self, url):
6a1b20de 30 playlist_id = self._match_id(url)
e2b06e76 31
ac668111 32 fstr = urllib.parse.quote("InternalBandUrl eq '%s'" % playlist_id)
baa7081d 33 json_url = 'http://urort.p3.no/breeze/urort/TrackDTOViews?$filter=%s&$orderby=Released%%20desc&$expand=Tags%%2CFiles' % fstr
e2b06e76 34 songs = self._download_json(json_url, playlist_id)
baa7081d
PH
35 entries = []
36 for s in songs:
37 formats = [{
38 'tbr': f.get('Quality'),
39 'ext': f['FileType'],
40 'format_id': '%s-%s' % (f['FileType'], f.get('Quality', '')),
41 'url': 'http://p3urort.blob.core.windows.net/tracks/%s' % f['FileRef'],
f983b875 42 'quality': 3 if f['FileType'] == 'mp3' else 2,
baa7081d 43 } for f in s['Files']]
baa7081d
PH
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 }