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.

47 lines
1.9 KiB

  1. # coding: utf-8
  2. import json
  3. import re
  4. import xml.etree.ElementTree
  5. from .common import InfoExtractor
  6. class JeuxVideoIE(InfoExtractor):
  7. _VALID_URL = r'http://.*?\.jeuxvideo\.com/.*/(.*?)-\d+\.htm'
  8. _TEST = {
  9. u'url': u'http://www.jeuxvideo.com/reportages-videos-jeux/0004/00046170/tearaway-playstation-vita-gc-2013-tearaway-nous-presente-ses-papiers-d-identite-00115182.htm',
  10. u'file': u'5182.mp4',
  11. u'md5': u'046e491afb32a8aaac1f44dd4ddd54ee',
  12. u'info_dict': {
  13. u'title': u'GC 2013 : Tearaway nous présente ses papiers d\'identité',
  14. u'description': u'Lorsque les développeurs de LittleBigPlanet proposent un nouveau titre, on ne peut que s\'attendre à un résultat original et fort attrayant.\n',
  15. },
  16. }
  17. def _real_extract(self, url):
  18. mobj = re.match(self._VALID_URL, url)
  19. title = re.match(self._VALID_URL, url).group(1)
  20. webpage = self._download_webpage(url, title)
  21. m_download = re.search(r'<param name="flashvars" value="config=(.*?)" />', webpage)
  22. xml_link = m_download.group(1)
  23. id = re.search(r'http://www.jeuxvideo.com/config/\w+/0011/(.*?)/\d+_player\.xml', xml_link).group(1)
  24. xml_config = self._download_webpage(xml_link, title,
  25. 'Downloading XML config')
  26. config = xml.etree.ElementTree.fromstring(xml_config.encode('utf-8'))
  27. info = re.search(r'<format\.json>(.*?)</format\.json>',
  28. xml_config, re.MULTILINE|re.DOTALL).group(1)
  29. info = json.loads(info)['versions'][0]
  30. video_url = 'http://video720.jeuxvideo.com/' + info['file']
  31. return {'id': id,
  32. 'title' : config.find('titre_video').text,
  33. 'ext' : 'mp4',
  34. 'url' : video_url,
  35. 'description': self._og_search_description(webpage),
  36. 'thumbnail': config.find('image').text,
  37. }