2 import xml.etree.ElementTree
4 from .common import InfoExtractor
10 class GameSpotIE(InfoExtractor):
12 _VALID_URL = r'(?:http://)?(?:www\.)?gamespot\.com/.*-(?P<page_id>\d+)/?'
14 u"url": u"http://www.gamespot.com/arma-iii/videos/arma-iii-community-guide-sitrep-i-6410818/",
15 u"file": u"6410818.mp4",
16 u"md5": u"b2a30deaa8654fcccd43713a6b6a4825",
18 u"title": u"Arma 3 - Community Guide: SITREP I",
19 u"upload_date": u"20130627",
24 def _real_extract(self, url):
25 mobj = re.match(self._VALID_URL, url)
26 page_id = mobj.group('page_id')
27 webpage = self._download_webpage(url, page_id)
28 video_id = self._html_search_regex([r'"og:video" content=".*?\?id=(\d+)"',
29 r'http://www\.gamespot\.com/videoembed/(\d+)'],
31 data = compat_urllib_parse.urlencode({'id': video_id, 'newplayer': '1'})
32 info_url = 'http://www.gamespot.com/pages/video_player/xml.php?' + data
33 info_xml = self._download_webpage(info_url, video_id)
34 doc = xml.etree.ElementTree.fromstring(info_xml)
35 clip_el = doc.find('./playList/clip')
37 http_urls = [{'url': node.find('filePath').text,
38 'rate': int(node.find('rate').text)}
39 for node in clip_el.find('./httpURI')]
40 best_quality = sorted(http_urls, key=lambda f: f['rate'])[-1]
41 video_url = best_quality['url']
42 title = clip_el.find('./title').text
43 ext = video_url.rpartition('.')[2]
44 thumbnail_url = clip_el.find('./screenGrabURI').text
45 view_count = int(clip_el.find('./views').text)
46 upload_date = unified_strdate(clip_el.find('./postDate').text)
53 'thumbnail' : thumbnail_url,
54 'upload_date' : upload_date,
55 'view_count' : view_count,