2024-04-24 09:22:51 +00:00
|
|
|
import unittest
|
|
|
|
|
2024-04-24 10:35:22 +00:00
|
|
|
from python_sponsorblock import SponsorBlock, exceptions
|
2024-04-24 09:22:51 +00:00
|
|
|
|
|
|
|
|
|
|
|
MAGIC_ID = "dQw4w9WgXcQ"
|
|
|
|
|
|
|
|
|
|
|
|
class TestVideoIdParsing(unittest.TestCase):
|
|
|
|
def test_already_parsed_id(self):
|
2024-04-24 10:35:22 +00:00
|
|
|
s = SponsorBlock()
|
|
|
|
self.assertEqual(s._get_video_id(MAGIC_ID), MAGIC_ID)
|
2024-04-24 09:22:51 +00:00
|
|
|
|
|
|
|
def test_non_existing_id(self):
|
2024-04-24 10:35:22 +00:00
|
|
|
s = SponsorBlock()
|
2024-04-24 09:22:51 +00:00
|
|
|
with self.assertRaises(exceptions.SponsorBlockIdNotFoundError):
|
2024-04-24 10:35:22 +00:00
|
|
|
s._get_video_id("eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee")
|
2024-04-24 09:22:51 +00:00
|
|
|
|
2024-04-24 10:35:22 +00:00
|
|
|
s = SponsorBlock(silent=True)
|
|
|
|
self.assertEqual(s._get_video_id("eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee"), None)
|
2024-04-24 09:22:51 +00:00
|
|
|
|
|
|
|
def test_youtu_dot_be(self):
|
2024-04-24 10:35:22 +00:00
|
|
|
s = SponsorBlock()
|
|
|
|
self.assertEqual(s._get_video_id("https://youtu.be/" + MAGIC_ID), MAGIC_ID)
|
2024-04-24 09:22:51 +00:00
|
|
|
|
|
|
|
def test_youtube_dot_com(self):
|
2024-04-24 10:35:22 +00:00
|
|
|
s = SponsorBlock()
|
|
|
|
self.assertEqual(s._get_video_id("https://www.youtube.com/watch?v=" + MAGIC_ID), MAGIC_ID)
|
2024-04-24 09:22:51 +00:00
|
|
|
|
|
|
|
def test_invidious(self):
|
2024-04-24 10:35:22 +00:00
|
|
|
s = SponsorBlock()
|
|
|
|
self.assertEqual(s._get_video_id("https://invidio.us/watch?v=" + MAGIC_ID), MAGIC_ID)
|
2024-04-24 09:22:51 +00:00
|
|
|
|
|
|
|
def test_piped(self):
|
2024-04-24 10:35:22 +00:00
|
|
|
s = SponsorBlock()
|
|
|
|
self.assertEqual(s._get_video_id("https://piped.video/watch?v=" + MAGIC_ID), MAGIC_ID)
|
2024-04-24 09:22:51 +00:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
unittest.main()
|