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.

58 lines
1.8 KiB

  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. import json
  4. import re
  5. from .common import InfoExtractor
  6. from ..utils import (
  7. clean_html,
  8. qualities,
  9. )
  10. class ClubicIE(InfoExtractor):
  11. _VALID_URL = r'http://(?:www\.)?clubic\.com/video/[^/]+/video.*-(?P<id>[0-9]+)\.html'
  12. _TEST = {
  13. 'url': 'http://www.clubic.com/video/clubic-week/video-clubic-week-2-0-le-fbi-se-lance-dans-la-photo-d-identite-448474.html',
  14. 'md5': '1592b694ba586036efac1776b0b43cd3',
  15. 'info_dict': {
  16. 'id': '448474',
  17. 'ext': 'mp4',
  18. 'title': 'Clubic Week 2.0 : le FBI se lance dans la photo d\u0092identité',
  19. 'description': 're:Gueule de bois chez Nokia. Le constructeur a indiqué cette.*',
  20. 'thumbnail': 're:^http://img\.clubic\.com/.*\.jpg$',
  21. }
  22. }
  23. def _real_extract(self, url):
  24. mobj = re.match(self._VALID_URL, url)
  25. video_id = mobj.group('id')
  26. player_url = 'http://player.m6web.fr/v1/player/clubic/%s.html' % video_id
  27. player_page = self._download_webpage(player_url, video_id)
  28. config_json = self._search_regex(
  29. r'(?m)M6\.Player\.config\s*=\s*(\{.+?\});$', player_page,
  30. 'configuration')
  31. config = json.loads(config_json)
  32. video_info = config['videoInfo']
  33. sources = config['sources']
  34. quality_order = qualities(['sd', 'hq'])
  35. formats = [{
  36. 'format_id': src['streamQuality'],
  37. 'url': src['src'],
  38. 'quality': quality_order(src['streamQuality']),
  39. } for src in sources]
  40. self._sort_formats(formats)
  41. return {
  42. 'id': video_id,
  43. 'title': video_info['title'],
  44. 'formats': formats,
  45. 'description': clean_html(video_info.get('description')),
  46. 'thumbnail': config.get('poster'),
  47. }