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.

33 lines
1.2 KiB

  1. import json
  2. import re
  3. from .common import InfoExtractor
  4. class JeuxVideoIE(InfoExtractor):
  5. _VALID_URL = r'http://.*?\.jeuxvideo\.com/.*/(.*?)-\d+\.htm'
  6. def _real_extract(self, url):
  7. mobj = re.match(self._VALID_URL, url)
  8. title = re.match(self._VALID_URL, url).group(1)
  9. webpage = self._download_webpage(url, title)
  10. m_download = re.search(r'<param name="flashvars" value="config=(.*?)" />', webpage)
  11. xml_link = m_download.group(1)
  12. id = re.search(r'http://www.jeuxvideo.com/config/\w+/0011/(.*?)/\d+_player\.xml', xml_link).group(1)
  13. xml_config = self._download_webpage(xml_link, title,
  14. 'Downloading XML config')
  15. info = re.search(r'<format\.json>(.*?)</format\.json>',
  16. xml_config, re.MULTILINE|re.DOTALL).group(1)
  17. info = json.loads(info)['versions'][0]
  18. video_url = 'http://video720.jeuxvideo.com/' + info['file']
  19. track_info = {'id':id,
  20. 'title' : title,
  21. 'ext' : 'mp4',
  22. 'url' : video_url
  23. }
  24. return [track_info]