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.6 KiB

  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. from .common import InfoExtractor
  4. from ..utils import (
  5. xpath_text,
  6. parse_duration,
  7. ExtractorError,
  8. )
  9. class EyedoTVIE(InfoExtractor):
  10. _VALID_URL = r'https?://(?:www\.)?eyedo\.tv/[^/]+/(?:#!/)?Live/Detail/(?P<id>[0-9]+)'
  11. _TEST = {
  12. 'url': 'https://www.eyedo.tv/en-US/#!/Live/Detail/16301',
  13. 'md5': 'ba14f17995cdfc20c36ba40e21bf73f7',
  14. 'info_dict': {
  15. 'id': '16301',
  16. 'ext': 'mp4',
  17. 'title': 'Journée du conseil scientifique de l\'Afnic 2015',
  18. 'description': 'md5:4abe07293b2f73efc6e1c37028d58c98',
  19. 'uploader': 'Afnic Live',
  20. 'uploader_id': '8023',
  21. }
  22. }
  23. _ROOT_URL = 'http://live.eyedo.net:1935/'
  24. def _real_extract(self, url):
  25. video_id = self._match_id(url)
  26. video_data = self._download_xml('http://eyedo.tv/api/live/GetLive/%s' % video_id, video_id)
  27. def _add_ns(path):
  28. return self._xpath_ns(path, 'http://schemas.datacontract.org/2004/07/EyeDo.Core.Implementation.Web.ViewModels.Api')
  29. title = xpath_text(video_data, _add_ns('Titre'), 'title', True)
  30. state_live_code = xpath_text(video_data, _add_ns('StateLiveCode'), 'title', True)
  31. if state_live_code == 'avenir':
  32. raise ExtractorError(
  33. '%s said: We\'re sorry, but this video is not yet available.' % self.IE_NAME,
  34. expected=True)
  35. is_live = state_live_code == 'live'
  36. m3u8_url = None
  37. # http://eyedo.tv/Content/Html5/Scripts/html5view.js
  38. if is_live:
  39. if xpath_text(video_data, 'Cdn') == 'true':
  40. m3u8_url = 'http://rrr.sz.xlcdn.com/?account=eyedo&file=A%s&type=live&service=wowza&protocol=http&output=playlist.m3u8' % video_id
  41. else:
  42. m3u8_url = self._ROOT_URL + 'w/%s/eyedo_720p/playlist.m3u8' % video_id
  43. else:
  44. m3u8_url = self._ROOT_URL + 'replay-w/%s/mp4:%s.mp4/playlist.m3u8' % (video_id, video_id)
  45. return {
  46. 'id': video_id,
  47. 'title': title,
  48. 'formats': self._extract_m3u8_formats(
  49. m3u8_url, video_id, 'mp4', 'm3u8' if is_live else 'm3u8_native'),
  50. 'description': xpath_text(video_data, _add_ns('Description')),
  51. 'duration': parse_duration(xpath_text(video_data, _add_ns('Duration'))),
  52. 'uploader': xpath_text(video_data, _add_ns('Createur')),
  53. 'uploader_id': xpath_text(video_data, _add_ns('CreateurId')),
  54. 'chapter': xpath_text(video_data, _add_ns('ChapitreTitre')),
  55. 'chapter_id': xpath_text(video_data, _add_ns('ChapitreId')),
  56. }