jeuxvideo.py 2.0 KB

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