jeuxvideo.py 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. from .common import InfoExtractor
  2. class JeuxVideoIE(InfoExtractor):
  3. _VALID_URL = r'https?://.*?\.jeuxvideo\.com/.*/(.*?)\.htm'
  4. _TESTS = [{
  5. 'url': 'http://www.jeuxvideo.com/reportages-videos-jeux/0004/00046170/tearaway-playstation-vita-gc-2013-tearaway-nous-presente-ses-papiers-d-identite-00115182.htm',
  6. 'md5': '046e491afb32a8aaac1f44dd4ddd54ee',
  7. 'info_dict': {
  8. 'id': '114765',
  9. 'ext': 'mp4',
  10. 'title': 'Tearaway : GC 2013 : Tearaway nous présente ses papiers d\'identité',
  11. 'description': 'Lorsque les développeurs de LittleBigPlanet proposent un nouveau titre, on ne peut que s\'attendre à un résultat original et fort attrayant.',
  12. },
  13. }, {
  14. 'url': 'http://www.jeuxvideo.com/videos/chroniques/434220/l-histoire-du-jeu-video-la-saturn.htm',
  15. 'only_matching': True,
  16. }]
  17. def _real_extract(self, url):
  18. mobj = self._match_valid_url(url)
  19. title = mobj.group(1)
  20. webpage = self._download_webpage(url, title)
  21. title = self._html_search_meta('name', webpage) or self._og_search_title(webpage)
  22. config_url = self._html_search_regex(
  23. r'data-src(?:set-video)?="(/contenu/medias/video\.php.*?)"',
  24. webpage, 'config URL')
  25. config_url = 'http://www.jeuxvideo.com' + config_url
  26. video_id = self._search_regex(
  27. r'id=(\d+)',
  28. config_url, 'video ID')
  29. config = self._download_json(
  30. config_url, title, 'Downloading JSON config')
  31. formats = [{
  32. 'url': source['file'],
  33. 'format_id': source['label'],
  34. 'resolution': source['label'],
  35. } for source in reversed(config['sources'])]
  36. return {
  37. 'id': video_id,
  38. 'title': title,
  39. 'formats': formats,
  40. 'description': self._og_search_description(webpage),
  41. 'thumbnail': config.get('image'),
  42. }