2022-06-24 10:10:17 +02:00
|
|
|
import urllib.parse
|
|
|
|
|
2014-03-27 02:51:50 +01:00
|
|
|
from .common import InfoExtractor
|
2022-06-24 10:10:17 +02:00
|
|
|
from ..utils import unified_strdate
|
2014-03-27 02:51:50 +01:00
|
|
|
|
|
|
|
|
|
|
|
class UrortIE(InfoExtractor):
|
2024-03-09 01:02:45 +01:00
|
|
|
_WORKING = False
|
2014-03-27 02:51:50 +01:00
|
|
|
IE_DESC = 'NRK P3 Urørt'
|
|
|
|
_VALID_URL = r'https?://(?:www\.)?urort\.p3\.no/#!/Band/(?P<id>[^/]+)$'
|
|
|
|
|
|
|
|
_TEST = {
|
|
|
|
'url': 'https://urort.p3.no/#!/Band/Gerilja',
|
|
|
|
'md5': '5ed31a924be8a05e47812678a86e127b',
|
|
|
|
'info_dict': {
|
2014-12-12 20:55:18 +01:00
|
|
|
'id': '33124-24',
|
2014-03-27 02:51:50 +01:00
|
|
|
'ext': 'mp3',
|
|
|
|
'title': 'The Bomb',
|
2017-01-02 13:08:07 +01:00
|
|
|
'thumbnail': r're:^https?://.+\.jpg',
|
2014-03-27 02:51:50 +01:00
|
|
|
'uploader': 'Gerilja',
|
|
|
|
'uploader_id': 'Gerilja',
|
2014-03-27 02:56:23 +01:00
|
|
|
'upload_date': '20100323',
|
2014-03-27 02:51:50 +01:00
|
|
|
},
|
|
|
|
'params': {
|
|
|
|
'matchtitle': '^The Bomb$', # To test, we want just one video
|
2024-06-12 01:09:58 +02:00
|
|
|
},
|
2014-03-27 02:51:50 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
def _real_extract(self, url):
|
2014-12-12 20:37:28 +01:00
|
|
|
playlist_id = self._match_id(url)
|
2014-03-27 02:51:50 +01:00
|
|
|
|
2024-06-12 01:09:58 +02:00
|
|
|
fstr = urllib.parse.quote(f"InternalBandUrl eq '{playlist_id}'")
|
|
|
|
json_url = f'http://urort.p3.no/breeze/urort/TrackDTOViews?$filter={fstr}&$orderby=Released%20desc&$expand=Tags%2CFiles'
|
2014-03-27 02:51:50 +01:00
|
|
|
songs = self._download_json(json_url, playlist_id)
|
2014-12-12 20:55:18 +01:00
|
|
|
entries = []
|
|
|
|
for s in songs:
|
|
|
|
formats = [{
|
|
|
|
'tbr': f.get('Quality'),
|
|
|
|
'ext': f['FileType'],
|
2024-06-12 01:09:58 +02:00
|
|
|
'format_id': '{}-{}'.format(f['FileType'], f.get('Quality', '')),
|
|
|
|
'url': 'http://p3urort.blob.core.windows.net/tracks/{}'.format(f['FileRef']),
|
2021-02-18 23:03:16 +01:00
|
|
|
'quality': 3 if f['FileType'] == 'mp3' else 2,
|
2014-12-12 20:55:18 +01:00
|
|
|
} for f in s['Files']]
|
|
|
|
e = {
|
|
|
|
'id': '%d-%s' % (s['BandId'], s['$id']),
|
|
|
|
'title': s['Title'],
|
|
|
|
'uploader_id': playlist_id,
|
|
|
|
'uploader': s.get('BandName', playlist_id),
|
2024-06-12 01:09:58 +02:00
|
|
|
'thumbnail': 'http://urort.p3.no/cloud/images/{}'.format(s['Image']),
|
2014-12-12 20:55:18 +01:00
|
|
|
'upload_date': unified_strdate(s.get('Released')),
|
|
|
|
'formats': formats,
|
|
|
|
}
|
|
|
|
entries.append(e)
|
2014-03-27 02:51:50 +01:00
|
|
|
|
|
|
|
return {
|
|
|
|
'_type': 'playlist',
|
|
|
|
'id': playlist_id,
|
|
|
|
'title': playlist_id,
|
|
|
|
'entries': entries,
|
|
|
|
}
|