[mixcloud] Fix URL extraction
authorPhilipp Hagemeister <phihag@phihag.de>
Fri, 17 Jan 2014 03:05:15 +0000 (04:05 +0100)
committerPhilipp Hagemeister <phihag@phihag.de>
Fri, 17 Jan 2014 03:05:15 +0000 (04:05 +0100)
youtube_dl/extractor/mixcloud.py

index 7c54ea0f4c7f351161adae175edca2743ab55266..2796dcd98ec61c1ce2a79817889a8d93488d4f43 100644 (file)
@@ -42,17 +42,18 @@ class MixcloudIE(InfoExtractor):
 
     def _real_extract(self, url):
         mobj = re.match(self._VALID_URL, url)
-
         uploader = mobj.group(1)
         cloudcast_name = mobj.group(2)
         track_id = '-'.join((uploader, cloudcast_name))
-        api_url = 'http://api.mixcloud.com/%s/%s/' % (uploader, cloudcast_name)
+
         webpage = self._download_webpage(url, track_id)
-        json_data = self._download_webpage(api_url, track_id,
-            u'Downloading cloudcast info')
-        info = json.loads(json_data)
 
-        preview_url = self._search_regex(r'data-preview-url="(.+?)"', webpage, u'preview url')
+        api_url = 'http://api.mixcloud.com/%s/%s/' % (uploader, cloudcast_name)
+        info = self._download_json(
+            api_url, track_id, u'Downloading cloudcast info')
+
+        preview_url = self._search_regex(
+            r'\s(?:data-preview-url|m-preview)="(.+?)"', webpage, u'preview url')
         song_url = preview_url.replace('/previews/', '/c/originals/')
         template_url = re.sub(r'(stream\d*)', 'stream%d', song_url)
         final_song_url = self._get_url(template_url)