fix: started relying on own error handling instead of none

This commit is contained in:
2024-04-25 14:50:19 +02:00
parent 85139d98a4
commit 07a933c625
2 changed files with 2 additions and 9 deletions

View File

@@ -43,7 +43,7 @@ class SponsorBlock:
self.logger: logging.Logger = logging.Logger("SponsorBlock")
def _get_video_id(self, video: str) -> Optional[str]:
def _get_video_id(self, video: str) -> str:
if re.match(r"^[a-zA-Z0-9_-]{11}$", video):
return video.strip()
@@ -56,9 +56,7 @@ class SponsorBlock:
query_stuff = parse_qs(url.query)
if "v" not in query_stuff:
if not self.silent:
raise SponsorBlockIdNotFoundError("No video id found in the url")
return None
raise SponsorBlockIdNotFoundError("No video id found in the url")
else:
return query_stuff["v"][0]
@@ -91,8 +89,6 @@ class SponsorBlock:
@error_handling(default=[])
def get_segments(self, video: str) -> List[Segment]:
video_id = self._get_video_id(video)
if video_id is None:
return []
# build query parameters
query = {