]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/filmon.py
2 from __future__
import unicode_literals
4 from .common
import InfoExtractor
17 class FilmOnIE(InfoExtractor
):
19 _VALID_URL
= r
'(?:https?://(?:www\.)?filmon\.com/vod/view/|filmon:)(?P<id>\d+)'
21 'url': 'https://www.filmon.com/vod/view/24869-0-plan-9-from-outer-space',
25 'title': 'Plan 9 From Outer Space',
26 'description': 'Dead human, zombies and vampires',
29 'url': 'https://www.filmon.com/vod/view/2825-1-popeye-series-1',
32 'title': 'Popeye Series 1',
33 'description': 'The original series of Popeye.',
35 'playlist_mincount': 8,
38 def _real_extract(self
, url
):
39 video_id
= self
._match
_id
(url
)
42 response
= self
._download
_json
(
43 'https://www.filmon.com/api/vod/movie?id=%s' % video_id
,
45 except ExtractorError
as e
:
46 if isinstance(e
.cause
, compat_HTTPError
):
47 errmsg
= self
._parse
_json
(e
.cause
.read().decode(), video_id
)['reason']
48 raise ExtractorError('%s said: %s' % (self
.IE_NAME
, errmsg
), expected
=True)
51 title
= response
['title']
52 description
= strip_or_none(response
.get('description'))
54 if response
.get('type_id') == 1:
55 entries
= [self
.url_result('filmon:' + episode_id
) for episode_id
in response
.get('episodes', [])]
56 return self
.playlist_result(entries
, video_id
, title
, description
)
58 QUALITY
= qualities(('low', 'high'))
60 for format_id
, stream
in response
.get('streams', {}).items():
61 stream_url
= stream
.get('url')
65 'format_id': format_id
,
68 'quality': QUALITY(stream
.get('quality')),
69 'protocol': 'm3u8_native',
71 self
._sort
_formats
(formats
)
74 poster
= response
.get('poster', {})
75 thumbs
= poster
.get('thumbs', {})
76 thumbs
['poster'] = poster
77 for thumb_id
, thumb
in thumbs
.items():
78 thumb_url
= thumb
.get('url')
84 'width': int_or_none(thumb
.get('width')),
85 'height': int_or_none(thumb
.get('height')),
92 'description': description
,
93 'thumbnails': thumbnails
,
97 class FilmOnChannelIE(InfoExtractor
):
98 IE_NAME
= 'filmon:channel'
99 _VALID_URL
= r
'https?://(?:www\.)?filmon\.com/(?:tv|channel)/(?P<id>[a-z0-9-]+)'
102 'url': 'http://www.filmon.com/tv/sports-haters',
106 'title': 'Sports Haters',
107 'description': 'md5:dabcb4c1d9cfc77085612f1a85f8275d',
111 'url': 'https://www.filmon.com/channel/filmon-sports',
112 'only_matching': True,
114 'url': 'https://www.filmon.com/tv/2894',
115 'only_matching': True,
120 ('big_logo', 106, 106),
121 ('extra_big_logo', 300, 300),
124 def _real_extract(self
, url
):
125 channel_id
= self
._match
_id
(url
)
128 channel_data
= self
._download
_json
(
129 'http://www.filmon.com/api-v2/channel/' + channel_id
, channel_id
)['data']
130 except ExtractorError
as e
:
131 if isinstance(e
.cause
, compat_HTTPError
):
132 errmsg
= self
._parse
_json
(e
.cause
.read().decode(), channel_id
)['message']
133 raise ExtractorError('%s said: %s' % (self
.IE_NAME
, errmsg
), expected
=True)
136 channel_id
= compat_str(channel_data
['id'])
137 is_live
= not channel_data
.get('is_vod') and not channel_data
.get('is_vox')
138 title
= channel_data
['title']
140 QUALITY
= qualities(('low', 'high'))
142 for stream
in channel_data
.get('streams', []):
143 stream_url
= stream
.get('url')
147 formats
.extend(self
._extract
_wowza
_formats
(
148 stream_url
, channel_id
, skip_protocols
=['dash', 'rtmp', 'rtsp']))
150 quality
= stream
.get('quality')
152 'format_id': quality
,
153 # this is an m3u8 stream, but we are deliberately not using _extract_m3u8_formats
154 # because it doesn't have bitrate variants anyway
157 'quality': QUALITY(quality
),
159 self
._sort
_formats
(formats
)
162 for name
, width
, height
in self
._THUMBNAIL
_RES
:
165 'url': 'http://static.filmon.com/assets/channels/%s/%s.png' % (channel_id
, name
),
172 'display_id': channel_data
.get('alias'),
173 'title': self
._live
_title
(title
) if is_live
else title
,
174 'description': channel_data
.get('description'),
175 'thumbnails': thumbnails
,