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.

51 lines
1.8 KiB

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