Improve shorts check (shared connection)

This commit is contained in:
BreadTube 2025-09-30 00:27:11 +09:00 committed by Corentin
commit a9e0fd26d7
2 changed files with 4 additions and 3 deletions

View file

@ -58,9 +58,8 @@ class YoutubeManager:
except TimeoutError as error:
raise RuntimeError(f'Timeout calling YT API ({url}): {error}') from error
def is_shorts(self, video_id: str, request_timeout: float) -> bool:
def is_shorts(self, connection: http.client.HTTPConnection, video_id: str) -> bool:
try:
connection = http.client.HTTPSConnection('www.youtube.com', timeout=request_timeout)
connection.request('GET', f'/shorts/{video_id}')
response = connection.getresponse()
return response.status != self.SHORTS_CHECK_STATUS