2020-08-09 09:40:46 +00:00
|
|
|
import pytest
|
|
|
|
|
2024-04-25 05:31:52 +00:00
|
|
|
from twitchdl.utils import parse_clip_identifier, parse_video_identifier
|
2020-08-09 09:40:46 +00:00
|
|
|
|
|
|
|
TEST_VIDEO_PATTERNS = [
|
|
|
|
("702689313", "702689313"),
|
|
|
|
("702689313", "https://twitch.tv/videos/702689313"),
|
|
|
|
("702689313", "https://www.twitch.tv/videos/702689313"),
|
2024-04-25 05:31:52 +00:00
|
|
|
("702689313", "https://m.twitch.tv/videos/702689313"),
|
2020-08-09 09:40:46 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
TEST_CLIP_PATTERNS = {
|
|
|
|
("AbrasivePlayfulMangoMau5", "AbrasivePlayfulMangoMau5"),
|
|
|
|
("AbrasivePlayfulMangoMau5", "https://clips.twitch.tv/AbrasivePlayfulMangoMau5"),
|
|
|
|
("AbrasivePlayfulMangoMau5", "https://www.twitch.tv/dracul1nx/clip/AbrasivePlayfulMangoMau5"),
|
2024-04-25 05:31:52 +00:00
|
|
|
("AbrasivePlayfulMangoMau5", "https://m.twitch.tv/dracul1nx/clip/AbrasivePlayfulMangoMau5"),
|
2020-08-09 09:40:46 +00:00
|
|
|
("AbrasivePlayfulMangoMau5", "https://twitch.tv/dracul1nx/clip/AbrasivePlayfulMangoMau5"),
|
|
|
|
("HungryProudRadicchioDoggo", "HungryProudRadicchioDoggo"),
|
|
|
|
("HungryProudRadicchioDoggo", "https://clips.twitch.tv/HungryProudRadicchioDoggo"),
|
|
|
|
("HungryProudRadicchioDoggo", "https://www.twitch.tv/bananasaurus_rex/clip/HungryProudRadicchioDoggo?filter=clips&range=7d&sort=time"),
|
2024-04-25 05:31:52 +00:00
|
|
|
("HungryProudRadicchioDoggo", "https://m.twitch.tv/bananasaurus_rex/clip/HungryProudRadicchioDoggo?filter=clips&range=7d&sort=time"),
|
2020-08-09 09:40:46 +00:00
|
|
|
("HungryProudRadicchioDoggo", "https://twitch.tv/bananasaurus_rex/clip/HungryProudRadicchioDoggo?filter=clips&range=7d&sort=time"),
|
2021-02-12 13:47:51 +00:00
|
|
|
("GloriousColdbloodedTortoiseRuleFive-E017utJ4DZmHVpfQ", "GloriousColdbloodedTortoiseRuleFive-E017utJ4DZmHVpfQ"),
|
|
|
|
("GloriousColdbloodedTortoiseRuleFive-E017utJ4DZmHVpfQ", "https://twitch.tv/dracul1nx/clip/GloriousColdbloodedTortoiseRuleFive-E017utJ4DZmHVpfQ"),
|
|
|
|
("GloriousColdbloodedTortoiseRuleFive-E017utJ4DZmHVpfQ", "https://twitch.tv/dracul1nx/clip/GloriousColdbloodedTortoiseRuleFive-E017utJ4DZmHVpfQ?filter=clips&range=7d&sort=time"),
|
|
|
|
("GloriousColdbloodedTortoiseRuleFive-E017utJ4DZmHVpfQ", "https://www.twitch.tv/dracul1nx/clip/GloriousColdbloodedTortoiseRuleFive-E017utJ4DZmHVpfQ?filter=clips&range=7d&sort=time"),
|
2024-04-25 05:31:52 +00:00
|
|
|
("GloriousColdbloodedTortoiseRuleFive-E017utJ4DZmHVpfQ", "https://m.twitch.tv/dracul1nx/clip/GloriousColdbloodedTortoiseRuleFive-E017utJ4DZmHVpfQ?filter=clips&range=7d&sort=time"),
|
2020-08-09 09:40:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.parametrize("expected,input", TEST_VIDEO_PATTERNS)
|
2024-04-25 05:31:52 +00:00
|
|
|
def test_video_patterns(expected: str, input: str):
|
2021-02-15 13:33:25 +00:00
|
|
|
assert parse_video_identifier(input) == expected
|
2020-08-09 09:40:46 +00:00
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.parametrize("expected,input", TEST_CLIP_PATTERNS)
|
2024-04-25 05:31:52 +00:00
|
|
|
def test_clip_patterns(expected: str, input: str):
|
2021-02-15 13:33:25 +00:00
|
|
|
assert parse_clip_identifier(input) == expected
|