From 877963b21f1bf97e547349b3025f0ef3025e4074 Mon Sep 17 00:00:00 2001 From: Surya Oktafendri Date: Tue, 3 Apr 2018 10:28:40 +0700 Subject: [PATCH 1/2] [Orfium] Add new extractor (Fixes #16025) --- youtube_dl/extractor/extractors.py | 3 +++ youtube_dl/extractor/orfium.py | 41 ++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 youtube_dl/extractor/orfium.py diff --git a/youtube_dl/extractor/extractors.py b/youtube_dl/extractor/extractors.py index de48a37ad..6babd14bd 100644 --- a/youtube_dl/extractor/extractors.py +++ b/youtube_dl/extractor/extractors.py @@ -796,6 +796,9 @@ from .orf import ( ORFOE1IE, ORFIPTVIE, ) +from .orfium import ( + OrfiumTrackIE, +) from .packtpub import ( PacktPubIE, PacktPubCourseIE, diff --git a/youtube_dl/extractor/orfium.py b/youtube_dl/extractor/orfium.py new file mode 100644 index 000000000..5e4b75009 --- /dev/null +++ b/youtube_dl/extractor/orfium.py @@ -0,0 +1,41 @@ +# coding: utf-8 +from __future__ import unicode_literals + +import re + +from .common import InfoExtractor +from ..utils import ExtractorError + + +class OrfiumTrackIE(InfoExtractor): + _VALID_URL = r'https?://(www\.)?orfium\.com/track/(?P\d+)' + IE_NAME = 'orfium' + _TESTS = [{ + 'url': 'https://www.orfium.com/track/694466/misery-aciou/', + 'md5': 'ceae78f12a22b05d7f796e04de5f6cae', + 'info_dict': { + 'id': '694466', + 'title': 'misery', + 'artist': 'aciou', + 'thumbnail': 'https://g3w6qqdmbl.execute-api.us-west-1.amazonaws.com/prod/thumb/temp?url=https://s3-us-west-2.amazonaws.com/orfium-public/tracks/artwork/9f493b6e01d8416ca4b0417437b1709c.png&w=360&h=380', + 'url': 'https://cdn.orfium.com/tracks%2Fa281276f-8126-48aa-98ad-9121c282e6eb-1522252307.mp3', + 'ext': 'mp3' + } + }] + + def _real_extract(self, url): + mobj = re.match(self._VALID_URL, url) + track_id = mobj.group('id') + info_url = 'https://www.orfium.com/api/track/%s/info/' % track_id + info_json = self._download_json(info_url, track_id, fatal=False) + if info_json is None: + raise ExtractorError('Track not found') + track_file = info_json.get('file') + + return { + 'id': track_id, + 'title': info_json.get('title'), + 'artist': info_json.get('artist'), + 'thumbnail': info_json.get('image'), + 'url': track_file + } From 84622e970af0b81fb9d0a3a8614002fb39bf49f9 Mon Sep 17 00:00:00 2001 From: Surya Oktafendri Date: Tue, 3 Apr 2018 10:36:30 +0700 Subject: [PATCH 2/2] [Extractors] Clean up the code --- youtube_dl/extractor/extractors.py | 4 +--- youtube_dl/extractor/orfium.py | 4 ++-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/youtube_dl/extractor/extractors.py b/youtube_dl/extractor/extractors.py index b1fe68d77..249fd98cf 100644 --- a/youtube_dl/extractor/extractors.py +++ b/youtube_dl/extractor/extractors.py @@ -796,9 +796,7 @@ from .orf import ( ORFOE1IE, ORFIPTVIE, ) -from .orfium import ( - OrfiumTrackIE, -) +from .orfium import OrfiumTrackIE from .packtpub import ( PacktPubIE, PacktPubCourseIE, diff --git a/youtube_dl/extractor/orfium.py b/youtube_dl/extractor/orfium.py index 5e4b75009..f0abdacbb 100644 --- a/youtube_dl/extractor/orfium.py +++ b/youtube_dl/extractor/orfium.py @@ -10,7 +10,7 @@ from ..utils import ExtractorError class OrfiumTrackIE(InfoExtractor): _VALID_URL = r'https?://(www\.)?orfium\.com/track/(?P\d+)' IE_NAME = 'orfium' - _TESTS = [{ + _TEST = { 'url': 'https://www.orfium.com/track/694466/misery-aciou/', 'md5': 'ceae78f12a22b05d7f796e04de5f6cae', 'info_dict': { @@ -21,7 +21,7 @@ class OrfiumTrackIE(InfoExtractor): 'url': 'https://cdn.orfium.com/tracks%2Fa281276f-8126-48aa-98ad-9121c282e6eb-1522252307.mp3', 'ext': 'mp3' } - }] + } def _real_extract(self, url): mobj = re.match(self._VALID_URL, url)