You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

45 lines
1.6 KiB

  1. import re
  2. import xml.etree.ElementTree
  3. from .common import InfoExtractor
  4. from ..utils import (
  5. unified_strdate,
  6. )
  7. class GameSpotIE(InfoExtractor):
  8. _VALID_URL = r'(?:http://)?(?:www\.)?gamespot\.com/([^/]+)/videos/([^/]+)-([^/d]+)/'
  9. _TEST = {
  10. u"url": u"http://www.gamespot.com/arma-iii/videos/arma-iii-community-guide-sitrep-i-6410818/",
  11. u"file": u"6410818.mp4",
  12. u"md5": u"5569d64ca98db01f0177c934fe8c1e9b",
  13. u"info_dict": {
  14. u"title": u"Arma III - Community Guide: SITREP I",
  15. u"upload_date": u"20130627",
  16. }
  17. }
  18. def _real_extract(self, url):
  19. mobj = re.match(self._VALID_URL, url)
  20. video_id = mobj.group(3).split("-")[-1]
  21. info_url = "http://www.gamespot.com/pages/video_player/xml.php?id="+str(video_id)
  22. info_xml = self._download_webpage(info_url, video_id)
  23. doc = xml.etree.ElementTree.fromstring(info_xml)
  24. clip_el = doc.find('./playList/clip')
  25. video_url = clip_el.find('./URI').text
  26. title = clip_el.find('./title').text
  27. ext = video_url.rpartition('.')[2]
  28. thumbnail_url = clip_el.find('./screenGrabURI').text
  29. view_count = int(clip_el.find('./views').text)
  30. upload_date = unified_strdate(clip_el.find('./postDate').text)
  31. return [{
  32. 'id' : video_id,
  33. 'url' : video_url,
  34. 'ext' : ext,
  35. 'title' : title,
  36. 'thumbnail' : thumbnail_url,
  37. 'upload_date' : upload_date,
  38. 'view_count' : view_count,
  39. }]