]>
jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/filmon.py
1 from .common
import InfoExtractor
2 from ..compat
import compat_str
3 from ..networking
.exceptions
import HTTPError
12 class FilmOnIE(InfoExtractor
):
14 _VALID_URL
= r
'(?:https?://(?:www\.)?filmon\.com/vod/view/|filmon:)(?P<id>\d+)'
16 'url': 'https://www.filmon.com/vod/view/24869-0-plan-9-from-outer-space',
20 'title': 'Plan 9 From Outer Space',
21 'description': 'Dead human, zombies and vampires',
24 'url': 'https://www.filmon.com/vod/view/2825-1-popeye-series-1',
27 'title': 'Popeye Series 1',
28 'description': 'The original series of Popeye.',
30 'playlist_mincount': 8,
33 def _real_extract(self
, url
):
34 video_id
= self
._match
_id
(url
)
37 response
= self
._download
_json
(
38 'https://www.filmon.com/api/vod/movie?id=%s' % video_id
,
40 except ExtractorError
as e
:
41 if isinstance(e
.cause
, HTTPError
):
42 errmsg
= self
._parse
_json
(e
.cause
.response
.read().decode(), video_id
)['reason']
43 raise ExtractorError('%s said: %s' % (self
.IE_NAME
, errmsg
), expected
=True)
46 title
= response
['title']
47 description
= strip_or_none(response
.get('description'))
49 if response
.get('type_id') == 1:
50 entries
= [self
.url_result('filmon:' + episode_id
) for episode_id
in response
.get('episodes', [])]
51 return self
.playlist_result(entries
, video_id
, title
, description
)
53 QUALITY
= qualities(('low', 'high'))
55 for format_id
, stream
in response
.get('streams', {}).items():
56 stream_url
= stream
.get('url')
60 'format_id': format_id
,
63 'quality': QUALITY(stream
.get('quality')),
64 'protocol': 'm3u8_native',
68 poster
= response
.get('poster', {})
69 thumbs
= poster
.get('thumbs', {})
70 thumbs
['poster'] = poster
71 for thumb_id
, thumb
in thumbs
.items():
72 thumb_url
= thumb
.get('url')
78 'width': int_or_none(thumb
.get('width')),
79 'height': int_or_none(thumb
.get('height')),
86 'description': description
,
87 'thumbnails': thumbnails
,
91 class FilmOnChannelIE(InfoExtractor
):
92 IE_NAME
= 'filmon:channel'
93 _VALID_URL
= r
'https?://(?:www\.)?filmon\.com/(?:tv|channel)/(?P<id>[a-z0-9-]+)'
96 'url': 'http://www.filmon.com/tv/sports-haters',
100 'title': 'Sports Haters',
101 'description': 'md5:dabcb4c1d9cfc77085612f1a85f8275d',
105 'url': 'https://www.filmon.com/channel/filmon-sports',
106 'only_matching': True,
108 'url': 'https://www.filmon.com/tv/2894',
109 'only_matching': True,
114 ('big_logo', 106, 106),
115 ('extra_big_logo', 300, 300),
118 def _real_extract(self
, url
):
119 channel_id
= self
._match
_id
(url
)
122 channel_data
= self
._download
_json
(
123 'http://www.filmon.com/api-v2/channel/' + channel_id
, channel_id
)['data']
124 except ExtractorError
as e
:
125 if isinstance(e
.cause
, HTTPError
):
126 errmsg
= self
._parse
_json
(e
.cause
.response
.read().decode(), channel_id
)['message']
127 raise ExtractorError('%s said: %s' % (self
.IE_NAME
, errmsg
), expected
=True)
130 channel_id
= compat_str(channel_data
['id'])
131 is_live
= not channel_data
.get('is_vod') and not channel_data
.get('is_vox')
132 title
= channel_data
['title']
134 QUALITY
= qualities(('low', 'high'))
136 for stream
in channel_data
.get('streams', []):
137 stream_url
= stream
.get('url')
141 formats
.extend(self
._extract
_wowza
_formats
(
142 stream_url
, channel_id
, skip_protocols
=['dash', 'rtmp', 'rtsp']))
144 quality
= stream
.get('quality')
146 'format_id': quality
,
147 # this is an m3u8 stream, but we are deliberately not using _extract_m3u8_formats
148 # because it doesn't have bitrate variants anyway
151 'quality': QUALITY(quality
),
155 for name
, width
, height
in self
._THUMBNAIL
_RES
:
158 'url': 'http://static.filmon.com/assets/channels/%s/%s.png' % (channel_id
, name
),
165 'display_id': channel_data
.get('alias'),
167 'description': channel_data
.get('description'),
168 'thumbnails': thumbnails
,