]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/gamespot.py
d570e3f6a85ca399d81328e3afedee4f98158e5f
1 from __future__
import unicode_literals
6 from .common
import InfoExtractor
14 class GameSpotIE(InfoExtractor
):
15 _VALID_URL
= r
'(?:http://)?(?:www\.)?gamespot\.com/.*-(?P<id>\d+)/?'
17 'url': 'http://www.gamespot.com/videos/arma-3-community-guide-sitrep-i/2300-6410818/',
18 'md5': 'b2a30deaa8654fcccd43713a6b6a4825',
20 'id': 'gs-2300-6410818',
22 'title': 'Arma 3 - Community Guide: SITREP I',
23 'description': 'Check out this video where some of the basics of Arma 3 is explained.',
27 def _real_extract(self
, url
):
28 page_id
= self
._match
_id
(url
)
29 webpage
= self
._download
_webpage
(url
, page_id
)
30 data_video_json
= self
._search
_regex
(
31 r
'data-video=["\'](.*?
)["\']', webpage, 'data video')
32 data_video = json.loads(unescapeHTML(data_video_json))
34 # Transform the manifest url to a link to the mp4 files
35 # they are used in mobile devices.
36 f4m_url = data_video['videoStreams']['f4m_stream']
37 f4m_path = compat_urlparse.urlparse(f4m_url).path
38 QUALITIES_RE = r'((,\d+)+,?)'
39 qualities = self._search_regex(QUALITIES_RE, f4m_path, 'qualities').strip(',').split(',')
40 http_path = f4m_path[1:].split('/', 1)[1]
41 http_template = re.sub(QUALITIES_RE, r'%s', http_path)
42 http_template = http_template.replace('.csmil/manifest.f4m', '')
43 http_template = compat_urlparse.urljoin(
44 'http://video.gamespotcdn.com/', http_template)
48 'url': http_template % q,
54 'id': data_video['guid'],
55 'display_id': page_id,
56 'title': compat_urllib_parse.unquote(data_video['title']),
58 'description': self._html_search_meta('description', webpage),
59 'thumbnail': self._og_search_thumbnail(webpage),