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.

53 lines
1.8 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'http://.*?\.jeuxvideo\.com/.*/(.*?)-\d+\.htm'
  7. _TEST = {
  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. def _real_extract(self, url):
  18. mobj = re.match(self._VALID_URL, url)
  19. title = mobj.group(1)
  20. webpage = self._download_webpage(url, title)
  21. title = self._html_search_meta('name', webpage)
  22. config_url = self._html_search_regex(
  23. r'data-src="(/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. }