added myspaceIE and tests for myspace

This commit is contained in:
M.Yasoob Khalid 2013-06-10 22:07:01 +05:00
parent 8cd252f115
commit fb6fabf5d0
2 changed files with 54 additions and 0 deletions

View File

@ -509,5 +509,15 @@
"info_dict":{ "info_dict":{
"title":"Смях! Чудо - чист за секунди - Скрита камера" "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"
}
} }
] ]

View File

@ -4627,6 +4627,49 @@ class Vbox7IE(InfoExtractor):
'thumbnail': thumbnail_url, 'thumbnail': thumbnail_url,
}] }]
class MyspaceIE(InfoExtractor):
"""Information Extractor for Myspace"""
_VALID_URL = r'(?:http://)?(?:www\.)?myspace\.com/([^/]+)/music/songs/([^/]+)-(?P<id>[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(): def gen_extractors():
""" Return a list of an instance of every supported extractor. """ Return a list of an instance of every supported extractor.
The order does matter; the first extractor matched is the one handling the URL. The order does matter; the first extractor matched is the one handling the URL.
@ -4692,6 +4735,7 @@ def gen_extractors():
XHamsterIE(), XHamsterIE(),
HypemIE(), HypemIE(),
Vbox7IE(), Vbox7IE(),
MyspaceIE(),
GenericIE() GenericIE()
] ]