+ 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:
+ # some songs in an album are not playable
+ self.report_warning(
+ '%s: No downloadable song on this page' % video_id)
+ return
+ def search_data(name):
+ return self._search_regex(
+ r'''data-%s=([\'"])(?P<data>.*?)\1''' % name,
+ song_data, name, default='', group='data')
+ 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),
+ 'uploader': search_data('artist-name'),
+ 'uploader_id': search_data('artist-username'),
+ 'thumbnail': self._og_search_thumbnail(webpage),
+ }
+ else:
+ context = json.loads(self._search_regex(
+ r'context = ({.*?});', webpage, 'context'))
+ video = context['video']
+ streamUrl = video['streamUrl']
+ info = {
+ 'id': compat_str(video['mediaId']),
+ 'title': video['title'],
+ 'description': video['description'],
+ 'thumbnail': video['imageUrl'],
+ 'uploader': video['artistName'],
+ 'uploader_id': video['artistUsername'],
+ }
+
+ rtmp_url, play_path = streamUrl.split(';', 1)
+ info.update({