]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/myspace.py
Prepare for upload.
[youtubedl] / youtube_dl / extractor / myspace.py
1 import re
2 import json
3
4 from .common import InfoExtractor
5 from ..utils import (
6 compat_str,
7 )
8
9
10 class MySpaceIE(InfoExtractor):
11 _VALID_URL = r'https?://myspace\.com/([^/]+)/video/[^/]+/(?P<id>\d+)'
12
13 _TEST = {
14 u'url': u'https://myspace.com/coldplay/video/viva-la-vida/100008689',
15 u'info_dict': {
16 u'id': u'100008689',
17 u'ext': u'flv',
18 u'title': u'Viva La Vida',
19 u'description': u'The official Viva La Vida video, directed by Hype Williams',
20 u'uploader': u'Coldplay',
21 u'uploader_id': u'coldplay',
22 },
23 u'params': {
24 # rtmp download
25 u'skip_download': True,
26 },
27 }
28
29 def _real_extract(self, url):
30 mobj = re.match(self._VALID_URL, url)
31 video_id = mobj.group('id')
32 webpage = self._download_webpage(url, video_id)
33 context = json.loads(self._search_regex(r'context = ({.*?});', webpage,
34 u'context'))
35 video = context['video']
36 rtmp_url, play_path = video['streamUrl'].split(';', 1)
37
38 return {
39 'id': compat_str(video['mediaId']),
40 'title': video['title'],
41 'url': rtmp_url,
42 'play_path': play_path,
43 'ext': 'flv',
44 'description': video['description'],
45 'thumbnail': video['imageUrl'],
46 'uploader': video['artistName'],
47 'uploader_id': video['artistUsername'],
48 }