logo

youtube-dl

[mirror] Download/Watch videos from video hostersgit clone https://hacktivis.me/git/mirror/youtube-dl.git

clubic.py (1976B)


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