]>
jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/myspace.py
2 from __future__
import unicode_literals
6 from .common
import InfoExtractor
14 class MySpaceIE(InfoExtractor
):
19 video/[^/]+/(?P<video_id>\d+)|
20 music/song/[^/?#&]+-(?P<song_id>\d+)-\d+(?:[/?#&]|$)
25 'url': 'https://myspace.com/fiveminutestothestage/video/little-big-town/109594919',
26 'md5': '9c1483c106f4a695c47d2911feed50a7',
30 'title': 'Little Big Town',
31 'description': 'This country quartet was all smiles while playing a sold out show at the Pacific Amphitheatre in Orange County, California.',
32 'uploader': 'Five Minutes to the Stage',
33 'uploader_id': 'fiveminutestothestage',
34 'timestamp': 1414108751,
35 'upload_date': '20141023',
39 'url': 'https://myspace.com/killsorrow/music/song/of-weakened-soul...-93388656-103880681',
40 'md5': '1d7ee4604a3da226dd69a123f748b262',
44 'title': 'Of weakened soul...',
45 'uploader': 'Killsorrow',
46 'uploader_id': 'killsorrow',
49 'url': 'https://myspace.com/starset2/music/song/first-light-95799905-106964426',
50 'only_matching': True,
52 'url': 'https://myspace.com/thelargemouthbassband/music/song/02-pure-eyes.mp3-94422330-105113388',
53 'only_matching': True,
56 def _real_extract(self
, url
):
57 mobj
= re
.match(self
._VALID
_URL
, url
)
58 video_id
= mobj
.group('video_id') or mobj
.group('song_id')
59 is_song
= mobj
.group('mediatype').startswith('music/song')
60 webpage
= self
._download
_webpage
(url
, video_id
)
61 player_url
= self
._search
_regex
(
62 r
'videoSwf":"([^"?]*)', webpage
, 'player URL', fatal
=False)
64 def formats_from_stream_urls(stream_url
, hls_stream_url
, http_stream_url
, width
=None, height
=None):
66 vcodec
= 'none' if is_song
else None
70 'url': hls_stream_url
,
71 'protocol': 'm3u8_native',
72 'ext': 'm4a' if is_song
else 'mp4',
75 if stream_url
and player_url
:
76 rtmp_url
, play_path
= stream_url
.split(';', 1)
80 'play_path': play_path
,
81 'player_url': player_url
,
91 'url': http_stream_url
,
99 # songs don't store any useful info in the 'context' variable
100 song_data
= self
._search
_regex
(
101 r
'''<button.*data-song-id=(["\'])%s\
1.*''' % video_id,
102 webpage, 'song_data', default=None, group=0)
103 if song_data is None:
104 # some songs in an album are not playable
106 '%s: No downloadable song on this page' % video_id)
109 def search_data(name):
110 return self._search_regex(
111 r'''data
-%s=([\'"])(?P<data>.*?)\1''' % name,
112 song_data, name, default='', group='data')
113 formats = formats_from_stream_urls(
114 search_data('stream-url'), search_data('hls-stream-url'),
115 search_data('http-stream-url'))
117 vevo_id = search_data('vevo-id')
118 youtube_id = search_data('youtube-id')
120 self.to_screen('Vevo video detected: %s' % vevo_id)
121 return self.url_result('vevo:%s' % vevo_id, ie='Vevo')
123 self.to_screen('Youtube video detected: %s' % youtube_id)
124 return self.url_result(youtube_id, ie='Youtube')
126 raise ExtractorError(
127 'Found song but don\'t know how to download it')
128 self._sort_formats(formats)
131 'title': self._og_search_title(webpage),
132 'uploader': search_data('artist-name'),
133 'uploader_id': search_data('artist-username'),
134 'thumbnail': self._og_search_thumbnail(webpage),
135 'duration': int_or_none(search_data('duration')),
139 video = self._parse_json(self._search_regex(
140 r'context = ({.*?});', webpage, 'context'),
142 formats = formats_from_stream_urls(
143 video.get('streamUrl'), video.get('hlsStreamUrl'),
144 video.get('mp4StreamUrl'), int_or_none(video.get('width')),
145 int_or_none(video.get('height')))
146 self._sort_formats(formats)
149 'title': video['title'],
150 'description': video.get('description'),
151 'thumbnail': video.get('imageUrl'),
152 'uploader': video.get('artistName'),
153 'uploader_id': video.get('artistUsername'),
154 'duration': int_or_none(video.get('duration')),
155 'timestamp': parse_iso8601(video.get('dateAdded')),
160 class MySpaceAlbumIE(InfoExtractor):
161 IE_NAME = 'MySpace:album'
162 _VALID_URL = r'https?://myspace\.com/([^/]+)/music/album/(?P<title>.*-)(?P<id>\d+)'
165 'url': 'https://myspace.com/starset2/music/album/transmissions-19455773',
167 'title': 'Transmissions',
170 'playlist_count': 14,
171 'skip': 'this album is only available in some countries',
173 'url': 'https://myspace.com/killsorrow/music/album/the-demo-18596029',
181 def _real_extract(self, url):
182 mobj = re.match(self._VALID_URL, url)
183 playlist_id = mobj.group('id')
184 display_id = mobj.group('title') + playlist_id
185 webpage = self._download_webpage(url, display_id)
186 tracks_paths = re.findall(r'"music
:song
" content="(.*?
)"', webpage)
188 raise ExtractorError(
189 '%s: No songs found, try using proxy' % display_id,
192 self.url_result(t_path, ie=MySpaceIE.ie_key())
193 for t_path in tracks_paths]
197 'display_id': display_id,
198 'title': self._og_search_title(webpage),