From fb6fabf5d0f021e5bc2d3f9d6873b6d77c3fa649 Mon Sep 17 00:00:00 2001 From: "M.Yasoob Khalid" Date: Mon, 10 Jun 2013 22:07:01 +0500 Subject: [PATCH] added myspaceIE and tests for myspace --- test/tests.json | 10 ++++++++ youtube_dl/InfoExtractors.py | 44 ++++++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+) diff --git a/test/tests.json b/test/tests.json index 04be912ce..3f83d54af 100644 --- a/test/tests.json +++ b/test/tests.json @@ -509,5 +509,15 @@ "info_dict":{ "title":"Смях! Чудо - чист за секунди - Скрита камера" } + }, + { + "name": "Myspace", + "url": "http://www.myspace.com/dfgdageargrrqtgqe/music/songs/before-i-let-u-go-28570483", + "file": "28570483.flv", + "md5": "32342396fc85bd19d872b69c9bf6a558", + "info_dict":{ + "title":"12" + } } ] + diff --git a/youtube_dl/InfoExtractors.py b/youtube_dl/InfoExtractors.py index 24a77a1ab..73014655c 100755 --- a/youtube_dl/InfoExtractors.py +++ b/youtube_dl/InfoExtractors.py @@ -4627,6 +4627,49 @@ class Vbox7IE(InfoExtractor): 'thumbnail': thumbnail_url, }] +class MyspaceIE(InfoExtractor): + """Information Extractor for Myspace""" + _VALID_URL = r'(?:http://)?(?:www\.)?myspace\.com/([^/]+)/music/songs/([^/]+)-(?P[0-9]+)' + + def _real_extract(self,url): + mobj = re.match(self._VALID_URL, url) + if mobj is None: + raise ExtractorError(u'Invalid URL: %s' % url) + track_id = mobj.group('id') + data = 'type=song&id={}&at=1'.format(track_id) + info_url = "http://www.myspace.com/Modules/PageEditor/Handlers/music/queue.ashx" + headers = { + 'Hash':'MIGcBgkrBgEEAYI3WAOggY4wgYsGCisGAQQBgjdYAwGgfTB7AgMCAAECAmYDAgIAwAQIYLI97pYniaIEEEZ7OzdEz%2bIWLU44SUNWb30EUFjzQCE6jLLj9dgPm5be2u4N4ljriq5Up6l3RTd81ynC8UyNrmT8KElNy5%2bz8uxPHY3FdSDSgkJUuW3iF4SdT53bMvA8fAP2iOBxBMhGjy9d', + } + request = compat_urllib_request.Request(info_url, data , headers) + request.add_header('Content-Type', 'application/x-www-form-urlencoded') + song_data_json = self._download_webpage(request, track_id, u'Downloading song information') + try: + song_data = json.loads(song_data_json) + except ValueError: + raise ExtractorError(u'Myspace contained invalid JSON.') + url = "rtmpte://fms.ec-music.myspacecdn.com/" + title = song_data['songTitle'] + artist = song_data['artistName'] + player_url = "http://lads.myspacecdn.com/music/sdkwrapper/SDKWrapper.2.2.16.swf?ili=false&pguid=bd1ab4fde7b84b7089e5ed714007719e&pertid64=-6868838582826384204&cip=115.167.69.194&sip=172.16.0.2&hash=MIGmBgkrBgEEAYI3WAOggZgwgZUGCisGAQQBgjdYAwGggYYwgYMCAwIAAQICZgMCAgDABAg30iVjjk7mowQQADI7jEQRqtXEHalqOxdJbwRYHt7ZytsvewZpywM16%252fvP58Ii0sDljgh97xfuXDzKDYiI%252fjPiID7lEVopr2XgVMyOVbgdqfEotNmXWlPL6ORFvJ8fjk4hPQEBKkudN9zd0WHsFN190OHl8A%253d%253d&pertid=b4c4229bb3fbaca00000000000000000&ptype=30&hostenv=www.&uid=-1&pcc=en-US&cc=en-US" + page_url = "http://www.myspace.com" + play_path = "mp4:"+ song_data['streamURL'].split(".com/")[1] + thumbnail_url = song_data["songImageURL"] + ext = "flv" + flashVer = "LNX 11,2,202,235" + return[{ + 'id' : track_id, + 'title' : title, + 'url' : url, + 'thumbnail' : thumbnail_url, + 'artist' : artist, + 'player_url' : player_url, + 'flashVer' : flashVer, + 'ext' : ext, + 'page_url' : page_url, + 'play_path' : play_path, + }] + def gen_extractors(): """ Return a list of an instance of every supported extractor. The order does matter; the first extractor matched is the one handling the URL. @@ -4692,6 +4735,7 @@ def gen_extractors(): XHamsterIE(), HypemIE(), Vbox7IE(), + MyspaceIE(), GenericIE() ]