Skip to content

Commit

Permalink
feat: detect dead links
Browse files Browse the repository at this point in the history
Old episode links may return 404
  • Loading branch information
un-def committed Mar 11, 2024
1 parent 3e49e4e commit 3f8baad
Showing 1 changed file with 13 additions and 16 deletions.
29 changes: 13 additions & 16 deletions src/dl_plus/extractors/un1def/rinsefm.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
])


__version__ = '0.1.1'
__version__ = '0.2.0.dev0'


plugin = ExtractorPlugin(__name__)
Expand Down Expand Up @@ -92,23 +92,20 @@ def _fetch_formats(self, url, slug) -> List[dict]:
filesize = None
# HEAD requests won't work
response = self._request_webpage(url, video_id=slug, fatal=False)
if response:
format_url = response.url
ext = urlhandle_detect_ext(response)
filesize = int_or_none(response.headers.get('Content-Length'))
else:
format_url = url
format_dict = {
'url': format_url,
'vcodec': 'none',
}
if not response:
raise ExtractorError(
'Probably dead link', video_id=slug, expected=True)
format_url = response.url
ext = urlhandle_detect_ext(response)
if not ext:
ext = determine_ext(format_url)
if ext:
format_dict['ext'] = ext
if filesize:
format_dict['filesize'] = filesize
return [format_dict]
filesize = int_or_none(response.headers.get('Content-Length'))
return [{
'url': format_url,
'ext': ext,
'filesize': filesize,
'vcodec': 'none',
}]


@plugin.register('channel')
Expand Down

0 comments on commit 3f8baad

Please sign in to comment.