]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/gamespot.py
098768361ede01d8acc01dc773a31b5b8fc67241
4 from .common
import InfoExtractor
13 class GameSpotIE(InfoExtractor
):
14 _VALID_URL
= r
'(?:http://)?(?:www\.)?gamespot\.com/.*-(?P<page_id>\d+)/?'
16 u
"url": u
"http://www.gamespot.com/arma-iii/videos/arma-iii-community-guide-sitrep-i-6410818/",
17 u
"file": u
"gs-2300-6410818.mp4",
18 u
"md5": u
"b2a30deaa8654fcccd43713a6b6a4825",
20 u
"title": u
"Arma 3 - Community Guide: SITREP I",
21 u
'description': u
'Check out this video where some of the basics of Arma 3 is explained.',
25 def _real_extract(self
, url
):
26 mobj
= re
.match(self
._VALID
_URL
, url
)
27 page_id
= video_id
= mobj
.group('page_id')
28 webpage
= self
._download
_webpage
(url
, page_id
)
29 data_video_json
= self
._search
_regex
(r
'data-video=\'(.*?
)\'', webpage, u'data video
')
30 data_video = json.loads(unescapeHTML(data_video_json))
32 # Transform the manifest url to a link to the mp4 files
33 # they are used in mobile devices.
34 f4m_url = data_video['videoStreams
']['f4m_stream
']
35 f4m_path = compat_urlparse.urlparse(f4m_url).path
36 QUALITIES_RE = r'((,\d
+)+,?
)'
37 qualities = self._search_regex(QUALITIES_RE, f4m_path, u'qualities
').strip(',').split(',')
38 http_path = f4m_path[1:].split('/', 1)[1]
39 http_template = re.sub(QUALITIES_RE, r'%s', http_path)
40 http_template = http_template.replace('.csmil
/manifest
.f4m
', '')
41 http_template = compat_urlparse.urljoin('http
://video
.gamespotcdn
.com
/', http_template)
45 'url
': http_template % q,
51 'id': data_video['guid
'],
52 'title
': compat_urllib_parse.unquote(data_video['title
']),
54 'description
': get_meta_content('description
', webpage),
55 'thumbnail
': self._og_search_thumbnail(webpage),
57 # TODO: Remove when #980 has been merged
58 info.update(formats[-1])