2 from __future__ import unicode_literals
6 from .common import InfoExtractor
14 class MySpaceIE(InfoExtractor):
15 _VALID_URL = r'https?://myspace\.com/([^/]+)/(?P<mediatype>video/[^/]+/|music/song/.*?)(?P<id>\d+)'
19 'url': 'https://myspace.com/fiveminutestothestage/video/little-big-town/109594919',
23 'title': 'Little Big Town',
24 'description': 'This country quartet was all smiles while playing a sold out show at the Pacific Amphitheatre in Orange County, California.',
25 'uploader': 'Five Minutes to the Stage',
26 'uploader_id': 'fiveminutestothestage',
27 'timestamp': 1414108751,
28 'upload_date': '20141023',
32 'skip_download': True,
37 'url': 'https://myspace.com/killsorrow/music/song/of-weakened-soul...-93388656-103880681',
41 'title': 'Of weakened soul...',
42 'uploader': 'Killsorrow',
43 'uploader_id': 'killsorrow',
47 'skip_download': True,
51 'url': 'https://myspace.com/threedaysgrace/music/song/animal-i-have-become-28400208-28218041',
55 'title': 'Animal I Have Become',
56 'uploader': 'Three Days Grace',
58 'upload_date': '20060502',
60 'skip': 'VEVO is only available in some countries',
62 'add_ie': ['Youtube'],
63 'url': 'https://myspace.com/starset2/music/song/first-light-95799905-106964426',
67 'title': 'Starset - First Light',
68 'description': 'md5:2d5db6c9d11d527683bcda818d332414',
70 'uploader_id': 'SorenPromotions',
71 'upload_date': '20140725',
76 def _real_extract(self, url):
77 mobj = re.match(self._VALID_URL, url)
78 video_id = mobj.group('id')
79 webpage = self._download_webpage(url, video_id)
80 player_url = self._search_regex(
81 r'playerSwf":"([^"?]*)', webpage, 'player URL')
83 def rtmp_format_from_stream_url(stream_url, width=None, height=None):
84 rtmp_url, play_path = stream_url.split(';', 1)
88 'play_path': play_path,
89 'player_url': player_url,
96 if mobj.group('mediatype').startswith('music/song'):
97 # songs don't store any useful info in the 'context' variable
98 song_data = self._search_regex(
99 r'''<button.*data-song-id=(["\'])%s\1.*''' % video_id,
100 webpage, 'song_data', default=None, group=0)
101 if song_data is None:
102 # some songs in an album are not playable
104 '%s: No downloadable song on this page' % video_id)
107 def search_data(name):
108 return self._search_regex(
109 r'''data-%s=([\'"])(?P<data>.*?)\1''' % name,
110 song_data, name, default='', group='data')
111 stream_url = search_data('stream-url')
113 vevo_id = search_data('vevo-id')
114 youtube_id = search_data('youtube-id')
116 self.to_screen('Vevo video detected: %s' % vevo_id)
117 return self.url_result('vevo:%s' % vevo_id, ie='Vevo')
119 self.to_screen('Youtube video detected: %s' % youtube_id)
120 return self.url_result(youtube_id, ie='Youtube')
122 raise ExtractorError(
123 'Found song but don\'t know how to download it')
126 'title': self._og_search_title(webpage),
127 'uploader': search_data('artist-name'),
128 'uploader_id': search_data('artist-username'),
129 'thumbnail': self._og_search_thumbnail(webpage),
130 'duration': int_or_none(search_data('duration')),
131 'formats': [rtmp_format_from_stream_url(stream_url)]
134 video = self._parse_json(self._search_regex(
135 r'context = ({.*?});', webpage, 'context'),
138 hls_stream_url = video.get('hlsStreamUrl')
142 'url': hls_stream_url,
143 'protocol': 'm3u8_native',
146 stream_url = video.get('streamUrl')
148 formats.append(rtmp_format_from_stream_url(
150 int_or_none(video.get('width')),
151 int_or_none(video.get('height'))))
152 self._sort_formats(formats)
155 'title': video['title'],
156 'description': video.get('description'),
157 'thumbnail': video.get('imageUrl'),
158 'uploader': video.get('artistName'),
159 'uploader_id': video.get('artistUsername'),
160 'duration': int_or_none(video.get('duration')),
161 'timestamp': parse_iso8601(video.get('dateAdded')),
166 class MySpaceAlbumIE(InfoExtractor):
167 IE_NAME = 'MySpace:album'
168 _VALID_URL = r'https?://myspace\.com/([^/]+)/music/album/(?P<title>.*-)(?P<id>\d+)'
171 'url': 'https://myspace.com/starset2/music/album/transmissions-19455773',
173 'title': 'Transmissions',
176 'playlist_count': 14,
177 'skip': 'this album is only available in some countries',
179 'url': 'https://myspace.com/killsorrow/music/album/the-demo-18596029',
187 def _real_extract(self, url):
188 mobj = re.match(self._VALID_URL, url)
189 playlist_id = mobj.group('id')
190 display_id = mobj.group('title') + playlist_id
191 webpage = self._download_webpage(url, display_id)
192 tracks_paths = re.findall(r'"music:song" content="(.*?)"', webpage)
194 raise ExtractorError(
195 '%s: No songs found, try using proxy' % display_id,
198 self.url_result(t_path, ie=MySpaceIE.ie_key())
199 for t_path in tracks_paths]
203 'display_id': display_id,
204 'title': self._og_search_title(webpage),