[KeezMovies] Applied second requested fixes for PR #16154
This commit is contained in:
parent
f4262a00c0
commit
d8e7e9aa0a
@ -1078,9 +1078,14 @@ class InfoExtractor(object):
|
|||||||
html, '%s form' % form_id, group='form')
|
html, '%s form' % form_id, group='form')
|
||||||
return self._hidden_inputs(form)
|
return self._hidden_inputs(form)
|
||||||
|
|
||||||
def _sort_formats(self, formats, field_preference=None):
|
def _sort_formats(self, formats, field_preference=None, fatal=True):
|
||||||
if not formats:
|
if not formats:
|
||||||
raise ExtractorError('No video formats found')
|
msg = 'No video formats found'
|
||||||
|
if fatal:
|
||||||
|
raise ExtractorError(msg)
|
||||||
|
else:
|
||||||
|
self._downloader.report_warning(msg)
|
||||||
|
return None
|
||||||
|
|
||||||
for f in formats:
|
for f in formats:
|
||||||
# Automatically determine tbr when missing based on abr and vbr (improves
|
# Automatically determine tbr when missing based on abr and vbr (improves
|
||||||
|
@ -36,22 +36,16 @@ class KeezMoviesIE(InfoExtractor):
|
|||||||
'only_matching': True,
|
'only_matching': True,
|
||||||
}]
|
}]
|
||||||
|
|
||||||
def _get_ids(self, url):
|
def _extract_info(self, url):
|
||||||
mobj = re.match(self._VALID_URL, url)
|
mobj = re.match(self._VALID_URL, url)
|
||||||
video_id = mobj.group('id')
|
video_id = mobj.group('id')
|
||||||
display_id = (mobj.group('display_id')
|
display_id = (mobj.group('display_id')
|
||||||
if 'display_id' in mobj.groupdict()
|
if 'display_id' in mobj.groupdict()
|
||||||
else None) or mobj.group('id')
|
else None) or mobj.group('id')
|
||||||
return video_id, display_id
|
|
||||||
|
|
||||||
def _download_webpage_age_verified(self, url, display_id):
|
webpage = self._download_webpage(
|
||||||
return self._download_webpage(
|
|
||||||
url, display_id, headers={'Cookie': 'age_verified=1'})
|
url, display_id, headers={'Cookie': 'age_verified=1'})
|
||||||
|
|
||||||
def _extract_info(self, url, require_http_prefix=True):
|
|
||||||
video_id, display_id = self._get_ids(url)
|
|
||||||
webpage = self._download_webpage_age_verified(url, display_id)
|
|
||||||
|
|
||||||
formats = []
|
formats = []
|
||||||
format_urls = set()
|
format_urls = set()
|
||||||
|
|
||||||
@ -60,13 +54,9 @@ class KeezMoviesIE(InfoExtractor):
|
|||||||
duration = None
|
duration = None
|
||||||
encrypted = False
|
encrypted = False
|
||||||
|
|
||||||
def extract_format(format_url, height=None, require_http_prefix=True):
|
def extract_format(format_url, height=None):
|
||||||
if require_http_prefix:
|
if not isinstance(format_url, compat_str) or not format_url.startswith(('http', '//')):
|
||||||
if not isinstance(format_url, compat_str) or not format_url.startswith('http'):
|
return
|
||||||
return
|
|
||||||
else:
|
|
||||||
if not isinstance(format_url, compat_str):
|
|
||||||
return
|
|
||||||
if format_url in format_urls:
|
if format_url in format_urls:
|
||||||
return
|
return
|
||||||
format_urls.add(format_url)
|
format_urls.add(format_url)
|
||||||
@ -99,23 +89,23 @@ class KeezMoviesIE(InfoExtractor):
|
|||||||
for key, value in flashvars.items():
|
for key, value in flashvars.items():
|
||||||
mobj = re.search(r'quality_(\d+)[pP]', key)
|
mobj = re.search(r'quality_(\d+)[pP]', key)
|
||||||
if mobj:
|
if mobj:
|
||||||
extract_format(value, int(mobj.group(1)), require_http_prefix=require_http_prefix)
|
extract_format(value, int(mobj.group(1)))
|
||||||
video_url = flashvars.get('video_url')
|
video_url = flashvars.get('video_url')
|
||||||
if video_url and determine_ext(video_url, None):
|
if video_url and determine_ext(video_url, None):
|
||||||
extract_format(video_url, require_http_prefix=require_http_prefix)
|
extract_format(video_url)
|
||||||
|
|
||||||
video_url = self._html_search_regex(
|
video_url = self._html_search_regex(
|
||||||
r'flashvars\.video_url\s*=\s*(["\'])(?P<url>http.+?)\1',
|
r'flashvars\.video_url\s*=\s*(["\'])(?P<url>http.+?)\1',
|
||||||
webpage, 'video url', default=None, group='url')
|
webpage, 'video url', default=None, group='url')
|
||||||
if video_url:
|
if video_url:
|
||||||
extract_format(compat_urllib_parse_unquote(video_url), require_http_prefix=require_http_prefix)
|
extract_format(compat_urllib_parse_unquote(video_url))
|
||||||
|
|
||||||
if not formats:
|
if not formats:
|
||||||
if 'title="This video is no longer available"' in webpage:
|
if 'title="This video is no longer available"' in webpage:
|
||||||
raise ExtractorError(
|
raise ExtractorError(
|
||||||
'Video %s is no longer available' % video_id, expected=True)
|
'Video %s is no longer available' % video_id, expected=True)
|
||||||
|
|
||||||
self._sort_formats(formats)
|
self._sort_formats(formats, fatal=False)
|
||||||
|
|
||||||
if not title:
|
if not title:
|
||||||
title = self._html_search_regex(
|
title = self._html_search_regex(
|
||||||
@ -132,13 +122,11 @@ class KeezMoviesIE(InfoExtractor):
|
|||||||
}
|
}
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
video_id, display_id = self._get_ids(url)
|
webpage, info = self._extract_info(url)
|
||||||
webpage = self._download_webpage_age_verified(url, display_id)
|
if not info['formats']:
|
||||||
embed_url = self._search_regex(
|
embed_url = self._search_regex(
|
||||||
r'<iframe\s+id="embedPlayer"\s+src="//(.+?)"', webpage, 'embed url', default=None)
|
r'<iframe\s+id="embedPlayer"\s+src="//(.+?)"', webpage, 'embed url', default=None)
|
||||||
if embed_url is not None:
|
return self.url_result(embed_url or url, 'Generic')
|
||||||
return self.url_result(embed_url, 'Generic')
|
|
||||||
webpage, info = self._extract_info(url, require_http_prefix=False)
|
|
||||||
info['view_count'] = str_to_int(self._search_regex(
|
info['view_count'] = str_to_int(self._search_regex(
|
||||||
r'<b>([\d,.]+)</b> Views?', webpage, 'view count', fatal=False))
|
r'<b>([\d,.]+)</b> Views?', webpage, 'view count', fatal=False))
|
||||||
return info
|
return info
|
||||||
|
Loading…
x
Reference in New Issue
Block a user