]>
Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/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 'add_ie': ['Youtube'],
50 'url': 'https://myspace.com/threedaysgrace/music/song/animal-i-have-become-28400208-28218041',
54 'title': 'Three Days Grace - Animal I Have Become',
55 'description': 'md5:8bd86b3693e72a077cf863a8530c54bb',
56 'uploader': 'ThreeDaysGraceVEVO',
57 'uploader_id': 'ThreeDaysGraceVEVO',
58 'upload_date': '20091002',
61 'url': 'https://myspace.com/starset2/music/song/first-light-95799905-106964426',
62 'only_matching': True,
64 'url': 'https://myspace.com/thelargemouthbassband/music/song/02-pure-eyes.mp3-94422330-105113388',
65 'only_matching': True,
68 def _real_extract(self
, url
):
69 mobj
= re
.match(self
._VALID
_URL
, url
)
70 video_id
= mobj
.group('video_id') or mobj
.group('song_id')
71 is_song
= mobj
.group('mediatype').startswith('music/song')
72 webpage
= self
._download
_webpage
(url
, video_id
)
73 player_url
= self
._search
_regex
(
74 r
'videoSwf":"([^"?]*)', webpage
, 'player URL', fatal
=False)
76 def formats_from_stream_urls(stream_url
, hls_stream_url
, http_stream_url
, width
=None, height
=None):
78 vcodec
= 'none' if is_song
else None
82 'url': hls_stream_url
,
83 'protocol': 'm3u8_native',
84 'ext': 'm4a' if is_song
else 'mp4',
87 if stream_url
and player_url
:
88 rtmp_url
, play_path
= stream_url
.split(';', 1)
92 'play_path': play_path
,
93 'player_url': player_url
,
103 'url': http_stream_url
,
111 # songs don't store any useful info in the 'context' variable
112 song_data
= self
._search
_regex
(
113 r
'''<button.*data-song-id=(["\'])%s\
1.*''' % video_id,
114 webpage, 'song_data', default=None, group=0)
115 if song_data is None:
116 # some songs in an album are not playable
118 '%s: No downloadable song on this page' % video_id)
121 def search_data(name):
122 return self._search_regex(
123 r'''data
-%s=([\'"])(?P<data>.*?)\1''' % name,
124 song_data, name, default='', group='data')
125 formats = formats_from_stream_urls(
126 search_data('stream-url'), search_data('hls-stream-url'),
127 search_data('http-stream-url'))
129 vevo_id = search_data('vevo-id')
130 youtube_id = search_data('youtube-id')
132 self.to_screen('Vevo video detected: %s' % vevo_id)
133 return self.url_result('vevo:%s' % vevo_id, ie='Vevo')
135 self.to_screen('Youtube video detected: %s' % youtube_id)
136 return self.url_result(youtube_id, ie='Youtube')
138 raise ExtractorError(
139 'Found song but don\'t know how to download it')
140 self._sort_formats(formats)
143 'title': self._og_search_title(webpage),
144 'uploader': search_data('artist-name'),
145 'uploader_id': search_data('artist-username'),
146 'thumbnail': self._og_search_thumbnail(webpage),
147 'duration': int_or_none(search_data('duration')),
151 video = self._parse_json(self._search_regex(
152 r'context = ({.*?});', webpage, 'context'),
154 formats = formats_from_stream_urls(
155 video.get('streamUrl'), video.get('hlsStreamUrl'),
156 video.get('mp4StreamUrl'), int_or_none(video.get('width')),
157 int_or_none(video.get('height')))
158 self._sort_formats(formats)
161 'title': video['title'],
162 'description': video.get('description'),
163 'thumbnail': video.get('imageUrl'),
164 'uploader': video.get('artistName'),
165 'uploader_id': video.get('artistUsername'),
166 'duration': int_or_none(video.get('duration')),
167 'timestamp': parse_iso8601(video.get('dateAdded')),
172 class MySpaceAlbumIE(InfoExtractor):
173 IE_NAME = 'MySpace:album'
174 _VALID_URL = r'https?://myspace\.com/([^/]+)/music/album/(?P<title>.*-)(?P<id>\d+)'
177 'url': 'https://myspace.com/starset2/music/album/transmissions-19455773',
179 'title': 'Transmissions',
182 'playlist_count': 14,
183 'skip': 'this album is only available in some countries',
185 'url': 'https://myspace.com/killsorrow/music/album/the-demo-18596029',
193 def _real_extract(self, url):
194 mobj = re.match(self._VALID_URL, url)
195 playlist_id = mobj.group('id')
196 display_id = mobj.group('title') + playlist_id
197 webpage = self._download_webpage(url, display_id)
198 tracks_paths = re.findall(r'"music
:song
" content="(.*?
)"', webpage)
200 raise ExtractorError(
201 '%s: No songs found, try using proxy' % display_id,
204 self.url_result(t_path, ie=MySpaceIE.ie_key())
205 for t_path in tracks_paths]
209 'display_id': display_id,
210 'title': self._og_search_title(webpage),