mirror of
https://github.com/ytdl-org/youtube-dl
synced 2025-07-28 06:14:17 +09:00
Compare commits
No commits in common. "020d7057443f9c5bdcacb16e99b51cc7661fd96c" and "d8c171109064b308d49e8ee013f4d27eedbd83f6" have entirely different histories.
020d705744
...
d8c1711090
@ -2,21 +2,12 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
from .common import InfoExtractor
|
from .common import InfoExtractor
|
||||||
from ..utils import (
|
from ..utils import unified_timestamp
|
||||||
ExtractorError,
|
|
||||||
float_or_none,
|
|
||||||
txt_or_none,
|
|
||||||
unified_timestamp,
|
|
||||||
url_or_none,
|
|
||||||
traverse_obj,
|
|
||||||
str_or_none,
|
|
||||||
T,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class EpidemicSoundIE(InfoExtractor):
|
class EpidemicSoundIE(InfoExtractor):
|
||||||
_VALID_URL = r'https?://(?:www\.)?epidemicsound\.com/track/(?P<id>[0-9a-zA-Z]+)'
|
_VALID_URL = r'https?://(?:www\.)?epidemicsound\.com/track/(?P<id>[0-9a-zA-Z]+)'
|
||||||
_TESTS = [{
|
_TEST = {
|
||||||
'url': 'https://www.epidemicsound.com/track/yFfQVRpSPz/',
|
'url': 'https://www.epidemicsound.com/track/yFfQVRpSPz/',
|
||||||
'md5': 'd98ff2ddb49e8acab9716541cbc9dfac',
|
'md5': 'd98ff2ddb49e8acab9716541cbc9dfac',
|
||||||
'info_dict': {
|
'info_dict': {
|
||||||
@ -28,58 +19,19 @@ class EpidemicSoundIE(InfoExtractor):
|
|||||||
'thumbnail': 'https://cdn.epidemicsound.com/curation-assets/commercial-release-cover-images/default-sfx/3000x3000.jpg',
|
'thumbnail': 'https://cdn.epidemicsound.com/curation-assets/commercial-release-cover-images/default-sfx/3000x3000.jpg',
|
||||||
'timestamp': 1415320353,
|
'timestamp': 1415320353,
|
||||||
'upload_date': '20141107',
|
'upload_date': '20141107',
|
||||||
},
|
}
|
||||||
}, {
|
}
|
||||||
'url': 'https://www.epidemicsound.com/track/mj8GTTwsZd/',
|
|
||||||
'md5': 'c82b745890f9baf18dc2f8d568ee3830',
|
|
||||||
'info_dict': {
|
|
||||||
'id': 'mj8GTTwsZd',
|
|
||||||
'ext': 'mp3',
|
|
||||||
'tags': ['liquid drum n bass', 'energetic'],
|
|
||||||
'title': 'Noplace',
|
|
||||||
'duration': 237,
|
|
||||||
'thumbnail': 'https://cdn.epidemicsound.com/curation-assets/commercial-release-cover-images/11138/3000x3000.jpg',
|
|
||||||
'timestamp': 1694426482,
|
|
||||||
'upload_date': '20230911',
|
|
||||||
},
|
|
||||||
}]
|
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
video_id = self._match_id(url)
|
video_id = self._match_id(url)
|
||||||
json_data = self._download_json('https://www.epidemicsound.com/json/track/' + video_id, video_id)
|
json_data = self._download_json('https://www.epidemicsound.com/json/track/' + video_id, video_id)
|
||||||
|
|
||||||
if not traverse_obj(json_data, ('stems', Ellipsis)):
|
return {
|
||||||
raise ExtractorError('No downloadable content found')
|
'id': video_id,
|
||||||
|
'url': json_data.get('stems').get('full').get('lqMp3Url'),
|
||||||
formats = list(reversed([
|
'tags': json_data.get('metadataTags'),
|
||||||
{
|
'title': json_data.get('title'),
|
||||||
'format_id': str_or_none(key),
|
'duration': json_data.get('length'),
|
||||||
'url': url_or_none(value.get('lqMp3Url'))
|
'timestamp': unified_timestamp(json_data.get('added')),
|
||||||
} for key, value in json_data.get('stems').items()
|
'thumbnail': json_data.get('imageUrl'),
|
||||||
]))
|
}
|
||||||
|
|
||||||
for f in formats:
|
|
||||||
for key, value in f.items():
|
|
||||||
if value is None or key is None:
|
|
||||||
del f
|
|
||||||
|
|
||||||
if len(formats) == 0:
|
|
||||||
raise ExtractorError('No downloadable content found')
|
|
||||||
|
|
||||||
info = traverse_obj(json_data, {
|
|
||||||
'tags': ('metadataTags', Ellipsis, T(txt_or_none)),
|
|
||||||
'title': ('title', T(txt_or_none)),
|
|
||||||
'duration': ('length', T(float_or_none)),
|
|
||||||
'timestamp': ('added', T(unified_timestamp)),
|
|
||||||
'thumbnail': ('imageUrl', T(url_or_none))})
|
|
||||||
|
|
||||||
info['id'] = video_id
|
|
||||||
info['formats'] = formats
|
|
||||||
|
|
||||||
if not info.get('tags'):
|
|
||||||
del info['tags']
|
|
||||||
|
|
||||||
if not info.get('title'):
|
|
||||||
raise ExtractorError('No title found')
|
|
||||||
|
|
||||||
return info
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user