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.

60 lines
2.2 KiB

  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. from .common import InfoExtractor
  4. from ..utils import (
  5. qualities,
  6. int_or_none,
  7. )
  8. class SixPlayIE(InfoExtractor):
  9. _VALID_URL = r'(?:6play:|https?://(?:www\.)?6play\.fr/.+?-c_)(?P<id>[0-9]+)'
  10. _TEST = {
  11. 'url': 'http://www.6play.fr/jamel-et-ses-amis-au-marrakech-du-rire-p_1316/jamel-et-ses-amis-au-marrakech-du-rire-2015-c_11495320',
  12. 'md5': '42310bffe4ba3982db112b9cd3467328',
  13. 'info_dict': {
  14. 'id': '11495320',
  15. 'ext': 'mp4',
  16. 'title': 'Jamel et ses amis au Marrakech du rire 2015',
  17. 'description': 'md5:ba2149d5c321d5201b78070ee839d872',
  18. },
  19. }
  20. def _real_extract(self, url):
  21. video_id = self._match_id(url)
  22. clip_data = self._download_json(
  23. 'https://player.m6web.fr/v2/video/config/6play-auth/FR/%s.json' % video_id,
  24. video_id)
  25. video_data = clip_data['videoInfo']
  26. quality_key = qualities(['lq', 'sd', 'hq', 'hd'])
  27. formats = []
  28. for source in clip_data['sources']:
  29. source_type, source_url = source.get('type'), source.get('src')
  30. if not source_url or source_type == 'hls/primetime':
  31. continue
  32. if source_type == 'application/vnd.apple.mpegURL':
  33. formats.extend(self._extract_m3u8_formats(
  34. source_url, video_id, 'mp4', 'm3u8_native',
  35. m3u8_id='hls', fatal=False))
  36. formats.extend(self._extract_f4m_formats(
  37. source_url.replace('.m3u8', '.f4m'),
  38. video_id, f4m_id='hds', fatal=False))
  39. elif source_type == 'video/mp4':
  40. quality = source.get('quality')
  41. formats.append({
  42. 'url': source_url,
  43. 'format_id': quality,
  44. 'quality': quality_key(quality),
  45. })
  46. self._sort_formats(formats)
  47. return {
  48. 'id': video_id,
  49. 'title': video_data['title'].strip(),
  50. 'description': video_data.get('description'),
  51. 'duration': int_or_none(video_data.get('duration')),
  52. 'series': video_data.get('titlePgm'),
  53. 'formats': formats,
  54. }