From 09496419ad3cbe7b7d34e872fbb9ab0acee38eed Mon Sep 17 00:00:00 2001 From: realRobotix <82544307+realRobotix@users.noreply.github.com> Date: Mon, 6 Nov 2023 10:51:31 +0100 Subject: [PATCH] [Epidemic Sound] Add simple extractor --- youtube_dl/extractor/epidemicsound.py | 41 +++++++++++++++++++++++++++ youtube_dl/extractor/extractors.py | 1 + 2 files changed, 42 insertions(+) create mode 100644 youtube_dl/extractor/epidemicsound.py diff --git a/youtube_dl/extractor/epidemicsound.py b/youtube_dl/extractor/epidemicsound.py new file mode 100644 index 000000000..df8cb8408 --- /dev/null +++ b/youtube_dl/extractor/epidemicsound.py @@ -0,0 +1,41 @@ +# coding: utf-8 +from __future__ import unicode_literals + +from .common import InfoExtractor +from datetime import datetime + + +class EpidemicSoundIE(InfoExtractor): + _VALID_URL = r'https?://(?:www\.)?epidemicsound\.com/track/(?P[0-9a-zA-Z]+)' + _TEST = { + 'url': 'https://www.epidemicsound.com/track/yFfQVRpSPz/', + 'md5': 'd98ff2ddb49e8acab9716541cbc9dfac', + 'info_dict': { + 'id': 'yFfQVRpSPz', + 'ext': 'mp3', + 'tags': ['foley', 'door', 'knock', 'glass', 'window', 'glass door knock'], + 'title': 'Door Knock Door 1', + 'duration': 1, + 'thumbnail': 'https://cdn.epidemicsound.com/curation-assets/commercial-release-cover-images/default-sfx/3000x3000.jpg', + } + } + + def _real_extract(self, url): + video_id = self._match_id(url) + json_data = self._download_json('https://www.epidemicsound.com/json/track/' + video_id, video_id) + title = json_data.get('title') + image_url = json_data.get('imageUrl') + media_url = json_data.get('stems').get('full').get('lqMp3Url') + media_len = json_data.get('length') + timestamp = int(datetime.strptime(json_data.get('added'), '%Y-%m-%dT%H:%M:%S').timestamp()) + tags = json_data.get('metadataTags') + + return { + 'id': video_id, + 'url': media_url, + 'tags': tags, + 'title': title, + 'duration': media_len, + 'timestamp': timestamp, + 'thumbnail': image_url, + } \ No newline at end of file diff --git a/youtube_dl/extractor/extractors.py b/youtube_dl/extractor/extractors.py index d9289e5bf..82221445f 100644 --- a/youtube_dl/extractor/extractors.py +++ b/youtube_dl/extractor/extractors.py @@ -357,6 +357,7 @@ from .ellentube import ( from .elpais import ElPaisIE from .embedly import EmbedlyIE from .engadget import EngadgetIE +from .epidemicsound import EpidemicSoundIE from .eporner import EpornerIE from .eroprofile import EroProfileIE from .escapist import EscapistIE