From db15a022ae6902c1264a53100fa4e3013b01cd96 Mon Sep 17 00:00:00 2001 From: sepro Date: Mon, 17 Feb 2025 17:26:57 +0100 Subject: [PATCH] Apply suggestions from code review Co-authored-by: bashonly <88596187+bashonly@users.noreply.github.com> --- yt_dlp/downloader/bunnycdn.py | 3 +-- yt_dlp/extractor/bunnycdn.py | 6 ++++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/yt_dlp/downloader/bunnycdn.py b/yt_dlp/downloader/bunnycdn.py index a09ebb6d6..1a5a1c03f 100644 --- a/yt_dlp/downloader/bunnycdn.py +++ b/yt_dlp/downloader/bunnycdn.py @@ -38,8 +38,7 @@ def send_ping(): request = Request( f'{ping_url}?hash={md5_hash}&time={time}&paused={paused}&resolution={res}', - headers=headers, - ) + headers=headers) try: self.ydl.urlopen(request).read() diff --git a/yt_dlp/extractor/bunnycdn.py b/yt_dlp/extractor/bunnycdn.py index 18ab0d025..d78753384 100644 --- a/yt_dlp/extractor/bunnycdn.py +++ b/yt_dlp/extractor/bunnycdn.py @@ -104,7 +104,9 @@ def _real_extract(self, url): query=traverse_obj(parse_qs(url), {'token': 'token', 'expires': 'expires'})) if html_title := self._html_extract_title(webpage, default=None) == '403': - raise ExtractorError('This video is inaccessible. Setting a Referer header might be required to access the video', expected=True) + raise ExtractorError( + 'This video is inaccessible. Setting a Referer header ' + 'might be required to access the video', expected=True) elif html_title == '404': raise ExtractorError('This video does not exist', expected=True) @@ -127,7 +129,7 @@ def _real_extract(self, url): 'quality': 1, 'http_headers': headers, 'ext': urlhandle_detect_ext(urlh, default='mp4'), - 'filesize': int_or_none(urlh.headers.get('Content-Length')), + 'filesize': int_or_none(urlh.get_header('Content-Length')), }) # MediaCage Streams require activation and pings