aboutsummaryrefslogtreecommitdiff
path: root/youtube_dl
diff options
context:
space:
mode:
authorxavier <xavier.beynon@gmail.com>2014-10-23 16:55:39 -0500
committerxavier <xavier.beynon@gmail.com>2014-10-23 16:55:39 -0500
commit67500bf939d7db66cdfb9f742fdedca1b83b8309 (patch)
tree32dd8478bc8fadd6e4894f8082c92ad85d7fb300 /youtube_dl
parent6b445558ffe292c11327862ab510b1abf4e36616 (diff)
downloadyoutube-dl-67500bf939d7db66cdfb9f742fdedca1b83b8309.tar.xz
Initial version of audiomack.py
Diffstat (limited to 'youtube_dl')
-rw-r--r--youtube_dl/extractor/audiomack.py43
1 files changed, 43 insertions, 0 deletions
diff --git a/youtube_dl/extractor/audiomack.py b/youtube_dl/extractor/audiomack.py
new file mode 100644
index 000000000..c5214f401
--- /dev/null
+++ b/youtube_dl/extractor/audiomack.py
@@ -0,0 +1,43 @@
+# coding: utf-8
+from __future__ import unicode_literals
+
+from .common import InfoExtractor
+import datetime
+import time
+import urllib.request
+import json
+
+
+class AudiomackIE(InfoExtractor):
+ _VALID_URL = r'https?://(?:www\.)?audiomack\.com/song/(?P<id>[\w/-]+)'
+ _TEST = {
+ 'url': 'https://www.audiomack.com/song/crewneckkramer/story-i-tell',
+ 'info_dict': {
+ 'id': 'story-i-tell',
+ 'ext': 'mp3',
+ 'title': 'story-i-tell'
+ }
+ }
+
+ def _real_extract(self, url):
+ # TODO more code goes here, for example ...
+ #webpage = self._download_webpage(url, video_id)
+ #title = self._html_search_regex(r'<h1>(.*?)</h1>', webpage, 'title')
+
+ assert("/song/" in url)
+ songurl = url[url.index("/song/")+5:]
+ title = songurl[songurl.rindex("/")+1:]
+ video_id = title
+ t = int(time.mktime(datetime.datetime.now().timetuple()))
+ s = "http://www.audiomack.com/api/music/url/song"+songurl+"?_="+str(t)
+ f = urllib.request.urlopen(s)
+ j = f.read(1000).decode("utf-8")
+ data = json.loads(j)
+
+ return {
+ 'id': video_id,
+ 'title': title,
+ 'url' : data["url"],
+ 'ext' : 'mp3'
+ # TODO more properties (see youtube_dl/extractor/common.py)
+ }