3 from .common
import InfoExtractor
11 class MySpaceIE(InfoExtractor
):
16 video/[^/]+/(?P<video_id>\d+)|
17 music/song/[^/?#&]+-(?P<song_id>\d+)-\d+(?:[/?#&]|$)
22 'url': 'https://myspace.com/fiveminutestothestage/video/little-big-town/109594919',
23 'md5': '9c1483c106f4a695c47d2911feed50a7',
27 'title': 'Little Big Town',
28 'description': 'This country quartet was all smiles while playing a sold out show at the Pacific Amphitheatre in Orange County, California.',
29 'uploader': 'Five Minutes to the Stage',
30 'uploader_id': 'fiveminutestothestage',
31 'timestamp': 1414108751,
32 'upload_date': '20141023',
36 'url': 'https://myspace.com/killsorrow/music/song/of-weakened-soul...-93388656-103880681',
37 'md5': '1d7ee4604a3da226dd69a123f748b262',
41 'title': 'Of weakened soul...',
42 'uploader': 'Killsorrow',
43 'uploader_id': 'killsorrow',
46 'url': 'https://myspace.com/starset2/music/song/first-light-95799905-106964426',
47 'only_matching': True,
49 'url': 'https://myspace.com/thelargemouthbassband/music/song/02-pure-eyes.mp3-94422330-105113388',
50 'only_matching': True,
53 def _real_extract(self
, url
):
54 mobj
= self
._match
_valid
_url
(url
)
55 video_id
= mobj
.group('video_id') or mobj
.group('song_id')
56 is_song
= mobj
.group('mediatype').startswith('music/song')
57 webpage
= self
._download
_webpage
(url
, video_id
)
58 player_url
= self
._search
_regex
(
59 r
'videoSwf":"([^"?]*)', webpage
, 'player URL', fatal
=False)
61 def formats_from_stream_urls(stream_url
, hls_stream_url
, http_stream_url
, width
=None, height
=None):
63 vcodec
= 'none' if is_song
else None
67 'url': hls_stream_url
,
68 'protocol': 'm3u8_native',
69 'ext': 'm4a' if is_song
else 'mp4',
72 if stream_url
and player_url
:
73 rtmp_url
, play_path
= stream_url
.split(';', 1)
77 'play_path': play_path
,
78 'player_url': player_url
,
88 'url': http_stream_url
,
96 # songs don't store any useful info in the 'context' variable
97 song_data
= self
._search
_regex
(
98 r
'''<button.*data-song-id=(["\'])%s\
1.*''' % video_id,
99 webpage, 'song_data', default=None, group=0)
100 if song_data is None:
101 # some songs in an album are not playable
103 '%s: No downloadable song on this page' % video_id)
106 def search_data(name):
107 return self._search_regex(
108 r'''data
-%s=([\'"])(?P<data>.*?)\1''' % name,
109 song_data, name, default='', group='data')
110 formats = formats_from_stream_urls(
111 search_data('stream-url'), search_data('hls-stream-url'),
112 search_data('http-stream-url'))
114 vevo_id = search_data('vevo-id')
115 youtube_id = search_data('youtube-id')
117 self.to_screen('Vevo video detected: %s' % vevo_id)
118 return self.url_result('vevo:%s' % vevo_id, ie='Vevo')
120 self.to_screen('Youtube video detected: %s' % youtube_id)
121 return self.url_result(youtube_id, ie='Youtube')
123 raise ExtractorError(
124 'Found song but don\'t know how to download it')
127 'title': self._og_search_title(webpage),
128 'uploader': search_data('artist-name'),
129 'uploader_id': search_data('artist-username'),
130 'thumbnail': self._og_search_thumbnail(webpage),
131 'duration': int_or_none(search_data('duration')),
135 video = self._parse_json(self._search_regex(
136 r'context = ({.*?});', webpage, 'context'),
138 formats = formats_from_stream_urls(
139 video.get('streamUrl'), video.get('hlsStreamUrl'),
140 video.get('mp4StreamUrl'), int_or_none(video.get('width')),
141 int_or_none(video.get('height')))
144 'title': video['title'],
145 'description': video.get('description'),
146 'thumbnail': video.get('imageUrl'),
147 'uploader': video.get('artistName'),
148 'uploader_id': video.get('artistUsername'),
149 'duration': int_or_none(video.get('duration')),
150 'timestamp': parse_iso8601(video.get('dateAdded')),
155 class MySpaceAlbumIE(InfoExtractor):
156 IE_NAME = 'MySpace:album'
157 _VALID_URL = r'https?://myspace\.com/([^/]+)/music/album/(?P<title>.*-)(?P<id>\d+)'
160 'url': 'https://myspace.com/starset2/music/album/transmissions-19455773',
162 'title': 'Transmissions',
165 'playlist_count': 14,
166 'skip': 'this album is only available in some countries',
168 'url': 'https://myspace.com/killsorrow/music/album/the-demo-18596029',
176 def _real_extract(self, url):
177 mobj = self._match_valid_url(url)
178 playlist_id = mobj.group('id')
179 display_id = mobj.group('title') + playlist_id
180 webpage = self._download_webpage(url, display_id)
181 tracks_paths = re.findall(r'"music
:song
" content="(.*?
)"', webpage)
183 raise ExtractorError(
184 '%s: No songs found, try using proxy' % display_id,
187 self.url_result(t_path, ie=MySpaceIE.ie_key())
188 for t_path in tracks_paths]
192 'display_id': display_id,
193 'title': self._og_search_title(webpage),