clubic.py 1.8 KB

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