[myspace] Add extractor for albums
authorTithen-Firion <Tithen-Firion@users.noreply.github.com>
Sun, 30 Nov 2014 20:36:00 +0000 (21:36 +0100)
committerJaime Marquínez Ferrándiz <jaime.marquinez.ferrandiz@gmail.com>
Sun, 30 Nov 2014 23:10:12 +0000 (00:10 +0100)
youtube_dl/extractor/__init__.py
youtube_dl/extractor/myspace.py

index 9387feef1af50ff4f6d87d64c37ae5de2f669ce3..0339d13860ab81d1a38a3dc624f2336b42e4a6a5 100644 (file)
@@ -242,7 +242,7 @@ from .muenchentv import MuenchenTVIE
 from .musicplayon import MusicPlayOnIE
 from .musicvault import MusicVaultIE
 from .muzu import MuzuTVIE
-from .myspace import MySpaceIE
+from .myspace import MySpaceIE, MySpaceAlbumIE
 from .myspass import MySpassIE
 from .myvideo import MyVideoIE
 from .naver import NaverIE
index b4b1fb51db4d2803bf3182aa519a683143162433..759bc7fed35f212cf2b3f2ecbea24f93c21f4a23 100644 (file)
@@ -131,3 +131,46 @@ class MySpaceIE(InfoExtractor):
             'ext': 'flv',
         })
         return info
+
+
+class MySpaceAlbumIE(InfoExtractor):
+    IE_NAME = 'MySpace:album'
+    _VALID_URL = r'https?://myspace\.com/([^/]+)/music/album/(?P<title>.*-)(?P<id>\d+)'
+
+    _TESTS = [{
+        'url': 'https://myspace.com/starset2/music/album/transmissions-19455773',
+        'info_dict': {
+            'title': 'Transmissions',
+            'id': '19455773',
+        },
+        'playlist_count': 14,
+        'skip': 'this album is only available in some countries',
+    }, {
+        'url': 'https://myspace.com/killsorrow/music/album/the-demo-18596029',
+        'info_dict': {
+            'title': 'The Demo',
+            'id': '18596029',
+        },
+        'playlist_count': 5,
+    }]
+
+    def _real_extract(self, url):
+        mobj = re.match(self._VALID_URL, url)
+        playlist_id = mobj.group('id')
+        display_id = mobj.group('title') + playlist_id
+        webpage = self._download_webpage(url, display_id)
+        tracks_paths = re.findall(r'"music:song" content="(.*?)"', webpage)
+        if not tracks_paths:
+            self.to_screen('%s: No songs found, try using proxy' % display_id)
+            return
+        entries = [
+            self.url_result(t_path, ie=MySpaceIE.ie_key())
+            for t_path in tracks_paths]
+        title = self._og_search_title(webpage)
+        return {
+            '_type': 'playlist',
+            'id': playlist_id,
+            'display_id': display_id,
+            'title': title,
+            'entries': entries,
+        }