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