]> git.bitcoin.ninja Git - youtube-dl/commitdiff
[myspace] Handle non-playable songs
authorTithen-Firion <Tithen-Firion@users.noreply.github.com>
Sun, 30 Nov 2014 18:36:24 +0000 (19:36 +0100)
committerJaime Marquínez Ferrándiz <jaime.marquinez.ferrandiz@gmail.com>
Sun, 30 Nov 2014 23:10:11 +0000 (00:10 +0100)
I'm adding this because sometimes there is a song page, but you cannot play it.
Example: https://myspace.com/starset2/music/song/let-it-die-maniac-agenda-remix-bonus-track-95799916-106964439
It will be useful for downloading whole album with songs like this.

youtube_dl/extractor/myspace.py

index 1a118a37f7cba821d378671a9ab035c00567cd64..843e1f24a39f074ea6304fb44c7e4d6d23d4bc21 100644 (file)
@@ -53,9 +53,17 @@ class MySpaceIE(InfoExtractor):
 
         if mobj.group('mediatype').startswith('music/song'):
             # songs don't store any useful info in the 'context' variable
+            song_data = self._search_regex(
+                r'''<button.*data-song-id=(["\'])%s\1.*''' % video_id,
+                webpage, 'song_data', default=None, group=0)
+            if song_data is None:
+                self.to_screen(
+                    '%s: No downloadable song on this page' % video_id)
+                return
             def search_data(name):
                 return self._search_regex(
-                    r'data-%s="(.*?)"' % name, webpage, name)
+                    r'''data-%s=([\'"])(.*?)\1''' % name,
+                    song_data, name, default='', group=2)
             streamUrl = search_data('stream-url')
             info = {
                 'id': video_id,