fix: started relying on own error handling instead of none
This commit is contained in:
		@@ -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
 | 
			
		||||
        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 = {
 | 
			
		||||
 
 | 
			
		||||
@@ -16,9 +16,6 @@ class TestVideoIdParsing(unittest.TestCase):
 | 
			
		||||
        with self.assertRaises(exceptions.SponsorBlockIdNotFoundError):
 | 
			
		||||
            s._get_video_id("eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee")
 | 
			
		||||
 | 
			
		||||
        s = SponsorBlock(silent=True)
 | 
			
		||||
        self.assertEqual(s._get_video_id("eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee"), None)
 | 
			
		||||
 | 
			
		||||
    def test_youtu_dot_be(self):
 | 
			
		||||
        s = SponsorBlock()
 | 
			
		||||
        self.assertEqual(s._get_video_id("https://youtu.be/" + MAGIC_ID), MAGIC_ID)
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user