]> jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/urort.py
[ie/matchtv] Fix extractor (#10190)
[yt-dlp.git] / yt_dlp / extractor / urort.py
1 import urllib.parse
2
3 from .common import InfoExtractor
4 from ..utils import unified_strdate
5
6
7 class UrortIE(InfoExtractor):
8 _WORKING = False
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': {
16 'id': '33124-24',
17 'ext': 'mp3',
18 'title': 'The Bomb',
19 'thumbnail': r're:^https?://.+\.jpg',
20 'uploader': 'Gerilja',
21 'uploader_id': 'Gerilja',
22 'upload_date': '20100323',
23 },
24 'params': {
25 'matchtitle': '^The Bomb$', # To test, we want just one video
26 },
27 }
28
29 def _real_extract(self, url):
30 playlist_id = self._match_id(url)
31
32 fstr = urllib.parse.quote(f"InternalBandUrl eq '{playlist_id}'")
33 json_url = f'http://urort.p3.no/breeze/urort/TrackDTOViews?$filter={fstr}&$orderby=Released%20desc&$expand=Tags%2CFiles'
34 songs = self._download_json(json_url, playlist_id)
35 entries = []
36 for s in songs:
37 formats = [{
38 'tbr': f.get('Quality'),
39 'ext': f['FileType'],
40 'format_id': '{}-{}'.format(f['FileType'], f.get('Quality', '')),
41 'url': 'http://p3urort.blob.core.windows.net/tracks/{}'.format(f['FileRef']),
42 'quality': 3 if f['FileType'] == 'mp3' else 2,
43 } for f in s['Files']]
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/{}'.format(s['Image']),
50 'upload_date': unified_strdate(s.get('Released')),
51 'formats': formats,
52 }
53 entries.append(e)
54
55 return {
56 '_type': 'playlist',
57 'id': playlist_id,
58 'title': playlist_id,
59 'entries': entries,
60 }