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.

56 lines
2.0 KiB

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