From b6ef4029055fdb5c6b27ac0d82d365475f84f32d Mon Sep 17 00:00:00 2001 From: "M.Yasoob Khalid" Date: Thu, 18 Jul 2013 12:30:21 +0500 Subject: [PATCH 1/5] added an IE for ex.fm --- youtube_dl/extractor/__init__.py | 1 + youtube_dl/extractor/exfm.py | 31 +++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 youtube_dl/extractor/exfm.py diff --git a/youtube_dl/extractor/__init__.py b/youtube_dl/extractor/__init__.py index 79868aa06..70a2363e4 100644 --- a/youtube_dl/extractor/__init__.py +++ b/youtube_dl/extractor/__init__.py @@ -19,6 +19,7 @@ from .dreisat import DreiSatIE from .ehow import EHowIE from .eighttracks import EightTracksIE from .escapist import EscapistIE +from .exfm import ExfmIE from .facebook import FacebookIE from .flickr import FlickrIE from .freesound import FreesoundIE diff --git a/youtube_dl/extractor/exfm.py b/youtube_dl/extractor/exfm.py new file mode 100644 index 000000000..cc0758b96 --- /dev/null +++ b/youtube_dl/extractor/exfm.py @@ -0,0 +1,31 @@ +import re +import json +import time + +from .common import InfoExtractor + + +class ExfmIE(InfoExtractor): + _VALID_URL = r'(?:http://)?(?:www\.)?ex\.fm/song/([^/]+)' + _SOUNDCLOUD_URL_ = r'(?:http://)?(?:www\.)?api\.soundcloud.com/tracks/([^/]+)/stream' + + def _real_extract(self, url): + mobj = re.match(self._VALID_URL, url) + video_id = mobj.group(1) + info_url = "http://ex.fm/api/v3/song/%s" %(video_id) + webpage = self._download_webpage(info_url, video_id) + info = json.loads(webpage) + song_url = re.match(self._SOUNDCLOUD_URL_,info['song']['url']) + if song_url is not None: + song_url = song_url.group() + "?client_id=b45b1aa10f1ac2941910a7f0d10f8e28" + else: + song_url = info['song']['url'] + return [{ + 'id': video_id, + 'url': song_url, + 'ext': 'mp3', + 'title': info['song']['title'], + 'thumbnail': info['song']['image']['large'], + 'uploader': info['song']['artist'], + 'view_count': info['song']['loved_count'], + }] From c4949c50f97e1f8f9eaa6b9af4b998592c4a4975 Mon Sep 17 00:00:00 2001 From: "M.Yasoob Khalid" Date: Thu, 18 Jul 2013 12:33:31 +0500 Subject: [PATCH 2/5] added test for ex.fm --- youtube_dl/extractor/exfm.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/youtube_dl/extractor/exfm.py b/youtube_dl/extractor/exfm.py index cc0758b96..777bc4dce 100644 --- a/youtube_dl/extractor/exfm.py +++ b/youtube_dl/extractor/exfm.py @@ -8,6 +8,16 @@ from .common import InfoExtractor class ExfmIE(InfoExtractor): _VALID_URL = r'(?:http://)?(?:www\.)?ex\.fm/song/([^/]+)' _SOUNDCLOUD_URL_ = r'(?:http://)?(?:www\.)?api\.soundcloud.com/tracks/([^/]+)/stream' + _TEST = { + u'url': u'http://ex.fm/song/1bgtzg', + u'file': u'1bgtzg.mp3', + u'md5': u'8a7967a3fef10e59a1d6f86240fd41cf', + u'info_dict': { + u"title": u"We Can't Stop", + u"uploader": u"Miley Cyrus", + u'thumbnail': u'http://i1.sndcdn.com/artworks-000049666230-w9i7ef-t500x500.jpg?9d68d37' + } + } def _real_extract(self, url): mobj = re.match(self._VALID_URL, url) From 233ad24ecf99e5a44541536e3d3352f6f7ebb526 Mon Sep 17 00:00:00 2001 From: "M.Yasoob Khalid" Date: Thu, 18 Jul 2013 12:37:02 +0500 Subject: [PATCH 3/5] corrected a typo and added myself to travis notifications. --- .travis.yml | 1 + youtube_dl/extractor/exfm.py | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 7f1fa8a3c..45b71f11b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,6 +9,7 @@ notifications: - filippo.valsorda@gmail.com - phihag@phihag.de - jaime.marquinez.ferrandiz+travis@gmail.com + - yasoob.khld@gmail.com # irc: # channels: # - "irc.freenode.org#youtube-dl" diff --git a/youtube_dl/extractor/exfm.py b/youtube_dl/extractor/exfm.py index 777bc4dce..0a80638d3 100644 --- a/youtube_dl/extractor/exfm.py +++ b/youtube_dl/extractor/exfm.py @@ -21,9 +21,9 @@ class ExfmIE(InfoExtractor): def _real_extract(self, url): mobj = re.match(self._VALID_URL, url) - video_id = mobj.group(1) - info_url = "http://ex.fm/api/v3/song/%s" %(video_id) - webpage = self._download_webpage(info_url, video_id) + song_id = mobj.group(1) + info_url = "http://ex.fm/api/v3/song/%s" %(song_id) + webpage = self._download_webpage(info_url, song_id) info = json.loads(webpage) song_url = re.match(self._SOUNDCLOUD_URL_,info['song']['url']) if song_url is not None: @@ -31,7 +31,7 @@ class ExfmIE(InfoExtractor): else: song_url = info['song']['url'] return [{ - 'id': video_id, + 'id': song_id, 'url': song_url, 'ext': 'mp3', 'title': info['song']['title'], From 2b1b511f6bf38d0d9e949ceccca82090a4c9dbbc Mon Sep 17 00:00:00 2001 From: "M.Yasoob Khalid" Date: Thu, 18 Jul 2013 12:37:47 +0500 Subject: [PATCH 4/5] removed some unnecessary imports --- youtube_dl/extractor/exfm.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/youtube_dl/extractor/exfm.py b/youtube_dl/extractor/exfm.py index 0a80638d3..f6e58cdc7 100644 --- a/youtube_dl/extractor/exfm.py +++ b/youtube_dl/extractor/exfm.py @@ -1,6 +1,4 @@ import re -import json -import time from .common import InfoExtractor From 8e5e059d7d787b5618ab7269b44f66c4a2f509ec Mon Sep 17 00:00:00 2001 From: "M.Yasoob Khalid" Date: Thu, 18 Jul 2013 12:40:56 +0500 Subject: [PATCH 5/5] forgot to import json json --- youtube_dl/extractor/exfm.py | 1 + 1 file changed, 1 insertion(+) diff --git a/youtube_dl/extractor/exfm.py b/youtube_dl/extractor/exfm.py index f6e58cdc7..81c620531 100644 --- a/youtube_dl/extractor/exfm.py +++ b/youtube_dl/extractor/exfm.py @@ -1,4 +1,5 @@ import re +import json from .common import InfoExtractor