]>
Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/myspace.py
f281238c93cd0f184b5a5213e67fb16ac82bc8c7
   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', 
  20             'md5': '9c1483c106f4a695c47d2911feed50a7', 
  24                 'title': 'Little Big Town', 
  25                 'description': 'This country quartet was all smiles while playing a sold out show at the Pacific Amphitheatre in Orange County, California.', 
  26                 'uploader': 'Five Minutes to the Stage', 
  27                 'uploader_id': 'fiveminutestothestage', 
  28                 'timestamp': 1414108751, 
  29                 'upload_date': '20141023', 
  34             'url': 'https://myspace.com/killsorrow/music/song/of-weakened-soul...-93388656-103880681', 
  35             'md5': '1d7ee4604a3da226dd69a123f748b262', 
  39                 'title': 'Of weakened soul...', 
  40                 'uploader': 'Killsorrow', 
  41                 'uploader_id': 'killsorrow', 
  44             'add_ie': ['Youtube'], 
  45             'url': 'https://myspace.com/threedaysgrace/music/song/animal-i-have-become-28400208-28218041', 
  49                 'title': 'Three Days Grace - Animal I Have Become', 
  50                 'description': 'md5:8bd86b3693e72a077cf863a8530c54bb', 
  51                 'uploader': 'ThreeDaysGraceVEVO', 
  52                 'uploader_id': 'ThreeDaysGraceVEVO', 
  53                 'upload_date': '20091002', 
  56             'add_ie': ['Youtube'], 
  57             'url': 'https://myspace.com/starset2/music/song/first-light-95799905-106964426', 
  61                 'title': 'Starset - First Light', 
  62                 'description': 'md5:2d5db6c9d11d527683bcda818d332414', 
  64                 'uploader_id': 'SorenPromotions', 
  65                 'upload_date': '20140725', 
  70     def _real_extract(self
, url
): 
  71         mobj 
= re
.match(self
._VALID
_URL
, url
) 
  72         video_id 
= mobj
.group('id') 
  73         is_song 
= mobj
.group('mediatype').startswith('music/song') 
  74         webpage 
= self
._download
_webpage
(url
, video_id
) 
  75         player_url 
= self
._search
_regex
( 
  76             r
'videoSwf":"([^"?]*)', webpage
, 'player URL', fatal
=False) 
  78         def formats_from_stream_urls(stream_url
, hls_stream_url
, http_stream_url
, width
=None, height
=None): 
  80             vcodec 
= 'none' if is_song 
else None 
  84                     'url': hls_stream_url
, 
  85                     'protocol': 'm3u8_native', 
  86                     'ext': 'm4a' if is_song 
else 'mp4', 
  89             if stream_url 
and player_url
: 
  90                 rtmp_url
, play_path 
= stream_url
.split(';', 1) 
  94                     'play_path': play_path
, 
  95                     'player_url': player_url
, 
 105                     'url': http_stream_url
, 
 113             # songs don't store any useful info in the 'context' variable 
 114             song_data 
= self
._search
_regex
( 
 115                 r
'''<button.*data-song-id=(["\'])%s\
1.*''' % video_id, 
 116                 webpage, 'song_data', default=None, group=0) 
 117             if song_data is None: 
 118                 # some songs in an album are not playable 
 120                     '%s: No downloadable song on this page' % video_id) 
 123             def search_data(name): 
 124                 return self._search_regex( 
 125                     r'''data
-%s=([\'"])(?P<data>.*?)\1''' % name, 
 126                     song_data, name, default='', group='data') 
 127             formats = formats_from_stream_urls( 
 128                 search_data('stream-url'), search_data('hls-stream-url'), 
 129                 search_data('http-stream-url')) 
 131                 vevo_id = search_data('vevo-id') 
 132                 youtube_id = search_data('youtube-id') 
 134                     self.to_screen('Vevo video detected: %s' % vevo_id) 
 135                     return self.url_result('vevo:%s' % vevo_id, ie='Vevo') 
 137                     self.to_screen('Youtube video detected: %s' % youtube_id) 
 138                     return self.url_result(youtube_id, ie='Youtube') 
 140                     raise ExtractorError( 
 141                         'Found song but don\'t know how to download it') 
 142             self._sort_formats(formats) 
 145                 'title': self._og_search_title(webpage), 
 146                 'uploader': search_data('artist-name'), 
 147                 'uploader_id': search_data('artist-username'), 
 148                 'thumbnail': self._og_search_thumbnail(webpage), 
 149                 'duration': int_or_none(search_data('duration')), 
 153             video = self._parse_json(self._search_regex( 
 154                 r'context = ({.*?});', webpage, 'context'), 
 156             formats = formats_from_stream_urls( 
 157                 video.get('streamUrl'), video.get('hlsStreamUrl'), 
 158                 video.get('mp4StreamUrl'), int_or_none(video.get('width')), 
 159                 int_or_none(video.get('height'))) 
 160             self._sort_formats(formats) 
 163                 'title': video['title'], 
 164                 'description': video.get('description'), 
 165                 'thumbnail': video.get('imageUrl'), 
 166                 'uploader': video.get('artistName'), 
 167                 'uploader_id': video.get('artistUsername'), 
 168                 'duration': int_or_none(video.get('duration')), 
 169                 'timestamp': parse_iso8601(video.get('dateAdded')), 
 174 class MySpaceAlbumIE(InfoExtractor): 
 175     IE_NAME = 'MySpace:album' 
 176     _VALID_URL = r'https?://myspace\.com/([^/]+)/music/album/(?P<title>.*-)(?P<id>\d+)' 
 179         'url': 'https://myspace.com/starset2/music/album/transmissions-19455773', 
 181             'title': 'Transmissions', 
 184         'playlist_count': 14, 
 185         'skip': 'this album is only available in some countries', 
 187         'url': 'https://myspace.com/killsorrow/music/album/the-demo-18596029', 
 195     def _real_extract(self, url): 
 196         mobj = re.match(self._VALID_URL, url) 
 197         playlist_id = mobj.group('id') 
 198         display_id = mobj.group('title') + playlist_id 
 199         webpage = self._download_webpage(url, display_id) 
 200         tracks_paths = re.findall(r'"music
:song
" content="(.*?
)"', webpage) 
 202             raise ExtractorError( 
 203                 '%s: No songs found, try using proxy' % display_id, 
 206             self.url_result(t_path, ie=MySpaceIE.ie_key()) 
 207             for t_path in tracks_paths] 
 211             'display_id': display_id, 
 212             'title': self._og_search_title(webpage),