]>
jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/hearthisat.py
2 from __future__
import unicode_literals
5 from .common
import InfoExtractor
13 class HearThisAtIE(InfoExtractor
):
14 _VALID_URL
= r
'https?://(?:www\.)?hearthis\.at/(?P<artist>[^/]+)/(?P<title>[A-Za-z0-9\-]+)/?$'
15 _PLAYLIST_URL
= 'https://hearthis.at/playlist.php'
17 'url': 'https://hearthis.at/moofi/dr-kreep',
18 'md5': 'ab6ec33c8fed6556029337c7885eb4e0',
22 'title': 'Moofi - Dr. Kreep',
23 'thumbnail': r
're:^https?://.*\.jpg$',
24 'timestamp': 1421564134,
25 'description': 'md5:1adb0667b01499f9d27e97ddfd53852a',
26 'upload_date': '20150118',
29 'genre': 'Experimental',
32 # 'download' link redirects to the original webpage
33 'url': 'https://hearthis.at/twitchsf/dj-jim-hopkins-totally-bitchin-80s-dance-mix/',
34 'md5': '5980ceb7c461605d30f1f039df160c6e',
38 'title': 'TwitchSF - DJ Jim Hopkins - Totally Bitchin\' 80\'s Dance Mix!',
39 'description': 'md5:ef26815ca8f483272a87b137ff175be2',
40 'upload_date': '20160328',
41 'timestamp': 1459186146,
42 'thumbnail': r
're:^https?://.*\.jpg$',
49 def _real_extract(self
, url
):
50 m
= self
._match
_valid
_url
(url
)
51 display_id
= '{artist:s} - {title:s}'.format(**m
.groupdict())
52 api_url
= url
.replace('www.', '').replace('hearthis.at', 'api-v2.hearthis.at')
53 data_json
= self
._download
_json
(api_url
, display_id
)
54 track_id
= data_json
.get('id')
55 artist_json
= data_json
.get('user')
56 title
= '{} - {}'.format(artist_json
.get('username'), data_json
.get('title'))
57 genre
= data_json
.get('genre')
58 description
= data_json
.get('description')
59 thumbnail
= data_json
.get('artwork_url') or data_json
.get('thumb')
60 view_count
= str_to_int(data_json
.get('playback_count'))
61 duration
= str_to_int(data_json
.get('duration'))
62 timestamp
= data_json
.get('release_timestamp')
65 mp3_url
= data_json
.get('stream_url')
76 if data_json
.get('download_url'):
77 download_url
= data_json
['download_url']
78 ext
= determine_ext(data_json
['download_filename'])
79 if ext
in KNOWN_EXTENSIONS
:
86 'quality': 2, # Usually better quality
88 self
._sort
_formats
(formats
)
92 'display_id': display_id
,
95 'thumbnail': thumbnail
,
96 'description': description
,
98 'timestamp': timestamp
,
99 'view_count': view_count
,