1 from .common
import InfoExtractor
2 from ..networking
.exceptions
import HTTPError
11 class FilmOnIE(InfoExtractor
):
13 _VALID_URL
= r
'(?:https?://(?:www\.)?filmon\.com/vod/view/|filmon:)(?P<id>\d+)'
15 'url': 'https://www.filmon.com/vod/view/24869-0-plan-9-from-outer-space',
19 'title': 'Plan 9 From Outer Space',
20 'description': 'Dead human, zombies and vampires',
23 'url': 'https://www.filmon.com/vod/view/2825-1-popeye-series-1',
26 'title': 'Popeye Series 1',
27 'description': 'The original series of Popeye.',
29 'playlist_mincount': 8,
32 def _real_extract(self
, url
):
33 video_id
= self
._match
_id
(url
)
36 response
= self
._download
_json
(
37 f
'https://www.filmon.com/api/vod/movie?id={video_id}',
39 except ExtractorError
as e
:
40 if isinstance(e
.cause
, HTTPError
):
41 errmsg
= self
._parse
_json
(e
.cause
.response
.read().decode(), video_id
)['reason']
42 raise ExtractorError(f
'{self.IE_NAME} said: {errmsg}', expected
=True)
45 title
= response
['title']
46 description
= strip_or_none(response
.get('description'))
48 if response
.get('type_id') == 1:
49 entries
= [self
.url_result('filmon:' + episode_id
) for episode_id
in response
.get('episodes', [])]
50 return self
.playlist_result(entries
, video_id
, title
, description
)
52 QUALITY
= qualities(('low', 'high'))
54 for format_id
, stream
in response
.get('streams', {}).items():
55 stream_url
= stream
.get('url')
59 'format_id': format_id
,
62 'quality': QUALITY(stream
.get('quality')),
63 'protocol': 'm3u8_native',
67 poster
= response
.get('poster', {})
68 thumbs
= poster
.get('thumbs', {})
69 thumbs
['poster'] = poster
70 for thumb_id
, thumb
in thumbs
.items():
71 thumb_url
= thumb
.get('url')
77 'width': int_or_none(thumb
.get('width')),
78 'height': int_or_none(thumb
.get('height')),
85 'description': description
,
86 'thumbnails': thumbnails
,
90 class FilmOnChannelIE(InfoExtractor
):
91 IE_NAME
= 'filmon:channel'
92 _VALID_URL
= r
'https?://(?:www\.)?filmon\.com/(?:tv|channel)/(?P<id>[a-z0-9-]+)'
95 'url': 'http://www.filmon.com/tv/sports-haters',
99 'title': 'Sports Haters',
100 'description': 'md5:dabcb4c1d9cfc77085612f1a85f8275d',
104 'url': 'https://www.filmon.com/channel/filmon-sports',
105 'only_matching': True,
107 'url': 'https://www.filmon.com/tv/2894',
108 'only_matching': True,
113 ('big_logo', 106, 106),
114 ('extra_big_logo', 300, 300),
117 def _real_extract(self
, url
):
118 channel_id
= self
._match
_id
(url
)
121 channel_data
= self
._download
_json
(
122 'http://www.filmon.com/api-v2/channel/' + channel_id
, channel_id
)['data']
123 except ExtractorError
as e
:
124 if isinstance(e
.cause
, HTTPError
):
125 errmsg
= self
._parse
_json
(e
.cause
.response
.read().decode(), channel_id
)['message']
126 raise ExtractorError(f
'{self.IE_NAME} said: {errmsg}', expected
=True)
129 channel_id
= str(channel_data
['id'])
130 is_live
= not channel_data
.get('is_vod') and not channel_data
.get('is_vox')
131 title
= channel_data
['title']
133 QUALITY
= qualities(('low', 'high'))
135 for stream
in channel_data
.get('streams', []):
136 stream_url
= stream
.get('url')
140 formats
.extend(self
._extract
_wowza
_formats
(
141 stream_url
, channel_id
, skip_protocols
=['dash', 'rtmp', 'rtsp']))
143 quality
= stream
.get('quality')
145 'format_id': quality
,
146 # this is an m3u8 stream, but we are deliberately not using _extract_m3u8_formats
147 # because it doesn't have bitrate variants anyway
150 'quality': QUALITY(quality
),
154 for name
, width
, height
in self
._THUMBNAIL
_RES
:
157 'url': f
'http://static.filmon.com/assets/channels/{channel_id}/{name}.png',
164 'display_id': channel_data
.get('alias'),
166 'description': channel_data
.get('description'),
167 'thumbnails': thumbnails
,