[Jamendo] Extract more metadata (#3672)

Authored by: evansp
This commit is contained in:
Evan Spensley 2022-05-07 18:48:34 -04:00 committed by GitHub
parent d7a1aa00c6
commit 5f8ea7e0d8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -28,10 +28,11 @@ class JamendoIE(InfoExtractor):
'ext': 'flac', 'ext': 'flac',
# 'title': 'Maya Filipič - Stories from Emona I', # 'title': 'Maya Filipič - Stories from Emona I',
'title': 'Stories from Emona I', 'title': 'Stories from Emona I',
# 'artist': 'Maya Filipič', 'artist': 'Maya Filipič',
'album': 'Between two worlds',
'track': 'Stories from Emona I', 'track': 'Stories from Emona I',
'duration': 210, 'duration': 210,
'thumbnail': r're:^https?://.*\.jpg', 'thumbnail': 'https://usercontent.jamendo.com?type=album&id=29279&width=300&trackid=196219',
'timestamp': 1217438117, 'timestamp': 1217438117,
'upload_date': '20080730', 'upload_date': '20080730',
'license': 'by-nc-nd', 'license': 'by-nc-nd',
@ -45,11 +46,11 @@ class JamendoIE(InfoExtractor):
'only_matching': True, 'only_matching': True,
}] }]
def _call_api(self, resource, resource_id): def _call_api(self, resource, resource_id, fatal=True):
path = '/api/%ss' % resource path = '/api/%ss' % resource
rand = compat_str(random.random()) rand = compat_str(random.random())
return self._download_json( return self._download_json(
'https://www.jamendo.com' + path, resource_id, query={ 'https://www.jamendo.com' + path, resource_id, fatal=fatal, query={
'id[]': resource_id, 'id[]': resource_id,
}, headers={ }, headers={
'X-Jam-Call': '$%s*%s~' % (hashlib.sha1((path + rand).encode()).hexdigest(), rand) 'X-Jam-Call': '$%s*%s~' % (hashlib.sha1((path + rand).encode()).hexdigest(), rand)
@ -71,6 +72,8 @@ class JamendoIE(InfoExtractor):
# if artist_name: # if artist_name:
# title = '%s - %s' % (artist_name, title) # title = '%s - %s' % (artist_name, title)
# album = get_model('album') # album = get_model('album')
artist = self._call_api("artist", track.get('artistId'), fatal=False)
album = self._call_api("album", track.get('albumId'), fatal=False)
formats = [{ formats = [{
'url': 'https://%s.jamendo.com/?trackid=%s&format=%s&from=app-97dab294' 'url': 'https://%s.jamendo.com/?trackid=%s&format=%s&from=app-97dab294'
@ -118,9 +121,9 @@ class JamendoIE(InfoExtractor):
'title': title, 'title': title,
'description': track.get('description'), 'description': track.get('description'),
'duration': int_or_none(track.get('duration')), 'duration': int_or_none(track.get('duration')),
# 'artist': artist_name, 'artist': artist.get('name'),
'track': track_name, 'track': track_name,
# 'album': album.get('name'), 'album': album.get('name'),
'formats': formats, 'formats': formats,
'license': '-'.join(license) if license else None, 'license': '-'.join(license) if license else None,
'timestamp': int_or_none(track.get('dateCreated')), 'timestamp': int_or_none(track.get('dateCreated')),
@ -145,22 +148,38 @@ class JamendoAlbumIE(JamendoIE):
'info_dict': { 'info_dict': {
'id': '1032333', 'id': '1032333',
'ext': 'flac', 'ext': 'flac',
'title': 'Shearer - Warmachine', 'title': 'Warmachine',
'artist': 'Shearer', 'artist': 'Shearer',
'track': 'Warmachine', 'track': 'Warmachine',
'timestamp': 1368089771, 'timestamp': 1368089771,
'upload_date': '20130509', 'upload_date': '20130509',
'view_count': int,
'thumbnail': 'https://usercontent.jamendo.com?type=album&id=121486&width=300&trackid=1032333',
'duration': 190,
'license': 'by',
'album': 'Duck On Cover',
'average_rating': 4,
'tags': ['rock', 'drums', 'bass', 'world', 'punk', 'neutral'],
'like_count': int,
} }
}, { }, {
'md5': '1f358d7b2f98edfe90fd55dac0799d50', 'md5': '1f358d7b2f98edfe90fd55dac0799d50',
'info_dict': { 'info_dict': {
'id': '1032330', 'id': '1032330',
'ext': 'flac', 'ext': 'flac',
'title': 'Shearer - Without Your Ghost', 'title': 'Without Your Ghost',
'artist': 'Shearer', 'artist': 'Shearer',
'track': 'Without Your Ghost', 'track': 'Without Your Ghost',
'timestamp': 1368089771, 'timestamp': 1368089771,
'upload_date': '20130509', 'upload_date': '20130509',
'duration': 192,
'tags': ['rock', 'drums', 'bass', 'world', 'punk'],
'album': 'Duck On Cover',
'thumbnail': 'https://usercontent.jamendo.com?type=album&id=121486&width=300&trackid=1032330',
'view_count': int,
'average_rating': 4,
'license': 'by',
'like_count': int,
} }
}], }],
'params': { 'params': {