]>
jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/filmon.py
1 from .common
import InfoExtractor
14 class FilmOnIE(InfoExtractor
):
16 _VALID_URL
= r
'(?:https?://(?:www\.)?filmon\.com/vod/view/|filmon:)(?P<id>\d+)'
18 'url': 'https://www.filmon.com/vod/view/24869-0-plan-9-from-outer-space',
22 'title': 'Plan 9 From Outer Space',
23 'description': 'Dead human, zombies and vampires',
26 'url': 'https://www.filmon.com/vod/view/2825-1-popeye-series-1',
29 'title': 'Popeye Series 1',
30 'description': 'The original series of Popeye.',
32 'playlist_mincount': 8,
35 def _real_extract(self
, url
):
36 video_id
= self
._match
_id
(url
)
39 response
= self
._download
_json
(
40 'https://www.filmon.com/api/vod/movie?id=%s' % video_id
,
42 except ExtractorError
as e
:
43 if isinstance(e
.cause
, compat_HTTPError
):
44 errmsg
= self
._parse
_json
(e
.cause
.read().decode(), video_id
)['reason']
45 raise ExtractorError('%s said: %s' % (self
.IE_NAME
, errmsg
), expected
=True)
48 title
= response
['title']
49 description
= strip_or_none(response
.get('description'))
51 if response
.get('type_id') == 1:
52 entries
= [self
.url_result('filmon:' + episode_id
) for episode_id
in response
.get('episodes', [])]
53 return self
.playlist_result(entries
, video_id
, title
, description
)
55 QUALITY
= qualities(('low', 'high'))
57 for format_id
, stream
in response
.get('streams', {}).items():
58 stream_url
= stream
.get('url')
62 'format_id': format_id
,
65 'quality': QUALITY(stream
.get('quality')),
66 'protocol': 'm3u8_native',
70 poster
= response
.get('poster', {})
71 thumbs
= poster
.get('thumbs', {})
72 thumbs
['poster'] = poster
73 for thumb_id
, thumb
in thumbs
.items():
74 thumb_url
= thumb
.get('url')
80 'width': int_or_none(thumb
.get('width')),
81 'height': int_or_none(thumb
.get('height')),
88 'description': description
,
89 'thumbnails': thumbnails
,
93 class FilmOnChannelIE(InfoExtractor
):
94 IE_NAME
= 'filmon:channel'
95 _VALID_URL
= r
'https?://(?:www\.)?filmon\.com/(?:tv|channel)/(?P<id>[a-z0-9-]+)'
98 'url': 'http://www.filmon.com/tv/sports-haters',
102 'title': 'Sports Haters',
103 'description': 'md5:dabcb4c1d9cfc77085612f1a85f8275d',
107 'url': 'https://www.filmon.com/channel/filmon-sports',
108 'only_matching': True,
110 'url': 'https://www.filmon.com/tv/2894',
111 'only_matching': True,
116 ('big_logo', 106, 106),
117 ('extra_big_logo', 300, 300),
120 def _real_extract(self
, url
):
121 channel_id
= self
._match
_id
(url
)
124 channel_data
= self
._download
_json
(
125 'http://www.filmon.com/api-v2/channel/' + channel_id
, channel_id
)['data']
126 except ExtractorError
as e
:
127 if isinstance(e
.cause
, compat_HTTPError
):
128 errmsg
= self
._parse
_json
(e
.cause
.read().decode(), channel_id
)['message']
129 raise ExtractorError('%s said: %s' % (self
.IE_NAME
, errmsg
), expected
=True)
132 channel_id
= compat_str(channel_data
['id'])
133 is_live
= not channel_data
.get('is_vod') and not channel_data
.get('is_vox')
134 title
= channel_data
['title']
136 QUALITY
= qualities(('low', 'high'))
138 for stream
in channel_data
.get('streams', []):
139 stream_url
= stream
.get('url')
143 formats
.extend(self
._extract
_wowza
_formats
(
144 stream_url
, channel_id
, skip_protocols
=['dash', 'rtmp', 'rtsp']))
146 quality
= stream
.get('quality')
148 'format_id': quality
,
149 # this is an m3u8 stream, but we are deliberately not using _extract_m3u8_formats
150 # because it doesn't have bitrate variants anyway
153 'quality': QUALITY(quality
),
157 for name
, width
, height
in self
._THUMBNAIL
_RES
:
160 'url': 'http://static.filmon.com/assets/channels/%s/%s.png' % (channel_id
, name
),
167 'display_id': channel_data
.get('alias'),
169 'description': channel_data
.get('description'),
170 'thumbnails': thumbnails
,