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.

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