eyedotv.py 2.6 KB

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