From e277123d3643fbd4d61df08147e9e97c73880e24 Mon Sep 17 00:00:00 2001 From: Tithen-Firion Date: Sun, 30 Nov 2014 19:06:23 +0100 Subject: [PATCH 1/6] [myspace] Use player_url for faster download It keeps reconnecting without it. Download time decreased from 7+ minutes to 25 seconds for me. --- youtube_dl/extractor/myspace.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/youtube_dl/extractor/myspace.py b/youtube_dl/extractor/myspace.py index c3c1a27c3..24da36212 100644 --- a/youtube_dl/extractor/myspace.py +++ b/youtube_dl/extractor/myspace.py @@ -48,6 +48,8 @@ class MySpaceIE(InfoExtractor): mobj = re.match(self._VALID_URL, url) video_id = mobj.group('id') webpage = self._download_webpage(url, video_id) + player_url = self._search_regex( + r'playerSwf":"([^"?]*)', webpage, 'player URL') if mobj.group('mediatype').startswith('music/song'): # songs don't store any useful info in the 'context' variable @@ -79,6 +81,7 @@ class MySpaceIE(InfoExtractor): info.update({ 'url': rtmp_url, 'play_path': play_path, + 'player_url': player_url, 'ext': 'flv', }) return info From 9717d6bf204bee1f89716a8c7c5a7240b6ed9326 Mon Sep 17 00:00:00 2001 From: Tithen-Firion Date: Sun, 30 Nov 2014 19:07:36 +0100 Subject: [PATCH 2/6] [myspace] Add more data to info dict `uploader` is an artist `playlist` is an album --- youtube_dl/extractor/myspace.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/youtube_dl/extractor/myspace.py b/youtube_dl/extractor/myspace.py index 24da36212..1a118a37f 100644 --- a/youtube_dl/extractor/myspace.py +++ b/youtube_dl/extractor/myspace.py @@ -60,7 +60,9 @@ class MySpaceIE(InfoExtractor): info = { 'id': video_id, 'title': self._og_search_title(webpage), + 'uploader': search_data('artist-name'), 'uploader_id': search_data('artist-username'), + 'playlist': search_data('album-title'), 'thumbnail': self._og_search_thumbnail(webpage), } else: From e55867e6e9dfcd8162cac4878ff8be6ff6f0836e Mon Sep 17 00:00:00 2001 From: Tithen-Firion Date: Sun, 30 Nov 2014 19:36:24 +0100 Subject: [PATCH 3/6] [myspace] Handle non-playable songs 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 | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/youtube_dl/extractor/myspace.py b/youtube_dl/extractor/myspace.py index 1a118a37f..843e1f24a 100644 --- a/youtube_dl/extractor/myspace.py +++ b/youtube_dl/extractor/myspace.py @@ -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''' Date: Sun, 30 Nov 2014 20:00:16 +0100 Subject: [PATCH 4/6] [myspace] Redirect to other extractors There are many songs just linked from Vevo/YouTube to MySpace. Vevo example: https://myspace.com/threedaysgrace/music/song/animal-i-have-become-28400208-28218041 YouTube example: https://myspace.com/starset2/music/song/first-light-95799905-106964426 --- youtube_dl/extractor/myspace.py | 13 +++++++++++++ youtube_dl/extractor/vevo.py | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/youtube_dl/extractor/myspace.py b/youtube_dl/extractor/myspace.py index 843e1f24a..dd0a0415e 100644 --- a/youtube_dl/extractor/myspace.py +++ b/youtube_dl/extractor/myspace.py @@ -7,6 +7,7 @@ from .common import InfoExtractor from ..compat import ( compat_str, ) +from ..utils import ExtractorError class MySpaceIE(InfoExtractor): @@ -65,6 +66,18 @@ class MySpaceIE(InfoExtractor): r'''data-%s=([\'"])(.*?)\1''' % name, song_data, name, default='', group=2) streamUrl = search_data('stream-url') + if not streamUrl: + vevo_id = search_data('vevo-id') + youtube_id = search_data('youtube-id') + if vevo_id: + self.to_screen('Vevo video detected: %s' % vevo_id) + return self.url_result('vevo:%s' % vevo_id, ie='Vevo') + elif youtube_id: + self.to_screen('Youtube video detected: %s' % youtube_id) + return self.url_result(youtube_id, ie='Youtube') + else: + raise ExtractorError( + 'Found song but don\'t know how to download it') info = { 'id': video_id, 'title': self._og_search_title(webpage), diff --git a/youtube_dl/extractor/vevo.py b/youtube_dl/extractor/vevo.py index 5b1a3ec78..c912c3cbe 100644 --- a/youtube_dl/extractor/vevo.py +++ b/youtube_dl/extractor/vevo.py @@ -13,7 +13,7 @@ from ..utils import ( class VevoIE(InfoExtractor): """ Accepts urls from vevo.com or in the format 'vevo:{id}' - (currently used by MTVIE) + (currently used by MTVIE and MySpaceIE) """ _VALID_URL = r'''(?x) (?:https?://www\.vevo\.com/watch/(?:[^/]+/(?:[^/]+/)?)?| From d4f6750c532dc59f236f05235af6debfc7b7aa35 Mon Sep 17 00:00:00 2001 From: Tithen-Firion Date: Sun, 30 Nov 2014 19:57:35 +0100 Subject: [PATCH 5/6] [myspace] Update tests --- youtube_dl/extractor/myspace.py | 33 ++++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/youtube_dl/extractor/myspace.py b/youtube_dl/extractor/myspace.py index dd0a0415e..b4b1fb51d 100644 --- a/youtube_dl/extractor/myspace.py +++ b/youtube_dl/extractor/myspace.py @@ -29,19 +29,42 @@ class MySpaceIE(InfoExtractor): 'skip_download': True, }, }, - # song + # songs { - 'url': 'https://myspace.com/spiderbags/music/song/darkness-in-my-heart-39008454-27041242', + 'url': 'https://myspace.com/killsorrow/music/song/of-weakened-soul...-93388656-103880681', + 'md5': 'f1d7323321f6b7775bf1e3754c1707dc', 'info_dict': { - 'id': '39008454', + 'id': '93388656', 'ext': 'flv', - 'title': 'Darkness In My Heart', - 'uploader_id': 'spiderbags', + 'playlist': 'The Demo', + 'title': 'Of weakened soul...', + 'uploader': 'Killsorrow', + 'uploader_id': 'killsorrow', }, 'params': { # rtmp download 'skip_download': True, }, + }, { + 'add_ie': ['Vevo'], + 'url': 'https://myspace.com/threedaysgrace/music/song/animal-i-have-become-28400208-28218041', + 'info_dict': { + 'id': u'USZM20600099', + 'title': u'Animal I Have Become', + 'uploader': u'Three Days Grace', + 'timestamp': int, + }, + 'skip': 'VEVO is only available in some countries', + }, { + 'add_ie': ['Youtube'], + 'url': 'https://myspace.com/starset2/music/song/first-light-95799905-106964426', + 'info_dict': { + 'id': 'ypWvQgnJrSU', + 'title': 'Starset - First Light', + 'uploader': 'Jacob Soren', + 'uploader_id': 'SorenPromotions', + 'upload_date': '20140725', + } }, ] From 32ab8ebba8728de50c5514d15b3ed9a2f5576771 Mon Sep 17 00:00:00 2001 From: Tithen-Firion Date: Sun, 30 Nov 2014 21:36:00 +0100 Subject: [PATCH 6/6] [myspace] Add extractor for albums --- youtube_dl/extractor/__init__.py | 2 +- youtube_dl/extractor/myspace.py | 43 ++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 1 deletion(-) diff --git a/youtube_dl/extractor/__init__.py b/youtube_dl/extractor/__init__.py index 9387feef1..0339d1386 100644 --- a/youtube_dl/extractor/__init__.py +++ b/youtube_dl/extractor/__init__.py @@ -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 diff --git a/youtube_dl/extractor/myspace.py b/youtube_dl/extractor/myspace.py index b4b1fb51d..759bc7fed 100644 --- a/youtube_dl/extractor/myspace.py +++ b/youtube_dl/extractor/myspace.py @@ -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.*-)(?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, + }