1
0
mirror of https://codeberg.org/polarisfm/youtube-dl synced 2024-11-29 19:47:54 +01:00

Handle 404's

Display error message when attempting to download deleted or removed video, or when the page cannot be found
This commit is contained in:
chazardsquair 2019-04-29 06:37:12 -05:00 committed by GitHub
parent df7e8f5b36
commit 75493fcc0e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -85,8 +85,20 @@ class XVideosIE(InfoExtractor):
video_id = self._match_id(url) video_id = self._match_id(url)
webpage = self._download_webpage( webpage = self._download_webpage(
'https://www.xvideos.com/video%s/' % video_id, video_id) 'https://www.xvideos.com/video%s/' % video_id, video_id, expected_status=404)
status_404 = get_element_by_class("status-404", webpage) or get_element_by_class("http-error-page", webpage)
if status_404:
reg_not_found = r'<div[^>]+id=["\']content["\']>[\r\n]*?<h1[^>]*>(?P<reason>[^<]*)'
deleted = get_element_by_class("text-danger", status_404)
not_found = self._search_regex(reg_not_found, status_404, 'reason', default=None, group='reason')
reason = deleted or not_found or None
if reason:
raise ExtractorError('%s said: %s' % (self.IE_NAME, reason), expected=True, video_id=video_id)
mobj = re.search(r'<h1 class="inlineError">(.+?)</h1>', webpage)
if mobj:
raise ExtractorError('%s said: %s' % (self.IE_NAME, clean_html(mobj.group(1))), expected=True)
mobj = re.search(r'<h1 class="inlineError">(.+?)</h1>', webpage) mobj = re.search(r'<h1 class="inlineError">(.+?)</h1>', webpage)
if mobj: if mobj:
raise ExtractorError('%s said: %s' % (self.IE_NAME, clean_html(mobj.group(1))), expected=True) raise ExtractorError('%s said: %s' % (self.IE_NAME, clean_html(mobj.group(1))), expected=True)