]>
jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/hearthisat.py
1 from .common
import InfoExtractor
9 class HearThisAtIE(InfoExtractor
):
10 _VALID_URL
= r
'https?://(?:www\.)?hearthis\.at/(?P<artist>[^/]+)/(?P<title>[A-Za-z0-9\-]+)/?$'
11 _PLAYLIST_URL
= 'https://hearthis.at/playlist.php'
13 'url': 'https://hearthis.at/moofi/dr-kreep',
14 'md5': 'ab6ec33c8fed6556029337c7885eb4e0',
18 'title': 'Moofi - Dr. Kreep',
19 'thumbnail': r
're:^https?://.*\.jpg$',
20 'timestamp': 1421564134,
21 'description': 'md5:1adb0667b01499f9d27e97ddfd53852a',
22 'upload_date': '20150118',
25 'genre': 'Experimental',
28 # 'download' link redirects to the original webpage
29 'url': 'https://hearthis.at/twitchsf/dj-jim-hopkins-totally-bitchin-80s-dance-mix/',
30 'md5': '5980ceb7c461605d30f1f039df160c6e',
34 'title': 'TwitchSF - DJ Jim Hopkins - Totally Bitchin\' 80\'s Dance Mix!',
35 'description': 'md5:ef26815ca8f483272a87b137ff175be2',
36 'upload_date': '20160328',
37 'timestamp': 1459186146,
38 'thumbnail': r
're:^https?://.*\.jpg$',
45 def _real_extract(self
, url
):
46 m
= self
._match
_valid
_url
(url
)
47 display_id
= '{artist:s} - {title:s}'.format(**m
.groupdict())
48 api_url
= url
.replace('www.', '').replace('hearthis.at', 'api-v2.hearthis.at')
49 data_json
= self
._download
_json
(api_url
, display_id
)
50 track_id
= data_json
.get('id')
51 artist_json
= data_json
.get('user')
52 title
= '{} - {}'.format(artist_json
.get('username'), data_json
.get('title'))
53 genre
= data_json
.get('genre')
54 description
= data_json
.get('description')
55 thumbnail
= data_json
.get('artwork_url') or data_json
.get('thumb')
56 view_count
= str_to_int(data_json
.get('playback_count'))
57 duration
= str_to_int(data_json
.get('duration'))
58 timestamp
= data_json
.get('release_timestamp')
61 mp3_url
= data_json
.get('stream_url')
72 if data_json
.get('download_url'):
73 download_url
= data_json
['download_url']
74 ext
= determine_ext(data_json
['download_filename'])
75 if ext
in KNOWN_EXTENSIONS
:
82 'quality': 2, # Usually better quality
84 self
._sort
_formats
(formats
)
88 'display_id': display_id
,
91 'thumbnail': thumbnail
,
92 'description': description
,
94 'timestamp': timestamp
,
95 'view_count': view_count
,