]> jfr.im git - yt-dlp.git/blame - youtube_dl/extractor/urort.py
[comcarcoff] Add unicode_literals declaration
[yt-dlp.git] / youtube_dl / extractor / urort.py
CommitLineData
e2b06e76
PH
1# coding: utf-8
2from __future__ import unicode_literals
3
4import re
5
6from .common import InfoExtractor
7from ..utils import (
8 compat_urllib_parse,
0dae5083 9 unified_strdate,
e2b06e76
PH
10)
11
12
13class UrortIE(InfoExtractor):
14 IE_DESC = 'NRK P3 Urørt'
15 _VALID_URL = r'https?://(?:www\.)?urort\.p3\.no/#!/Band/(?P<id>[^/]+)$'
16
17 _TEST = {
18 'url': 'https://urort.p3.no/#!/Band/Gerilja',
19 'md5': '5ed31a924be8a05e47812678a86e127b',
20 'info_dict': {
21 'id': '33124-4',
22 'ext': 'mp3',
23 'title': 'The Bomb',
24 'thumbnail': 're:^https?://.+\.jpg',
25 'like_count': int,
26 'uploader': 'Gerilja',
27 'uploader_id': 'Gerilja',
0dae5083 28 'upload_date': '20100323',
e2b06e76
PH
29 },
30 'params': {
31 'matchtitle': '^The Bomb$', # To test, we want just one video
32 }
33 }
34
35 def _real_extract(self, url):
6a1b20de 36 playlist_id = self._match_id(url)
e2b06e76
PH
37
38 fstr = compat_urllib_parse.quote("InternalBandUrl eq '%s'" % playlist_id)
39 json_url = 'http://urort.p3.no/breeze/urort/TrackDtos?$filter=' + fstr
40 songs = self._download_json(json_url, playlist_id)
41
42 entries = [{
43 'id': '%d-%s' % (s['BandId'], s['$id']),
44 'title': s['Title'],
45 'url': s['TrackUrl'],
46 'ext': 'mp3',
47 'uploader_id': playlist_id,
48 'uploader': s.get('BandName', playlist_id),
49 'like_count': s.get('LikeCount'),
50 'thumbnail': 'http://urort.p3.no/cloud/images/%s' % s['Image'],
0dae5083 51 'upload_date': unified_strdate(s.get('Released')),
e2b06e76
PH
52 } for s in songs]
53
54 return {
55 '_type': 'playlist',
56 'id': playlist_id,
57 'title': playlist_id,
58 'entries': entries,
59 }