feat: extend target parsing to support recommendation URLs
This commit is contained in:
parent
f7374d2088
commit
c56c54d35d
@ -77,6 +77,8 @@ def build_video_page_url(aweme_id: str) -> str:
|
|||||||
|
|
||||||
def parse_target_input(value: str, source: str) -> ResolvedTarget:
|
def parse_target_input(value: str, source: str) -> ResolvedTarget:
|
||||||
normalized = value.strip()
|
normalized = value.strip()
|
||||||
|
if is_recommendation_url(normalized):
|
||||||
|
return ResolvedTarget(kind="recommendation", value=normalized, source=source)
|
||||||
if is_creator_url(normalized):
|
if is_creator_url(normalized):
|
||||||
return ResolvedTarget(kind="creator", value=normalized, source=source)
|
return ResolvedTarget(kind="creator", value=normalized, source=source)
|
||||||
if is_video_url(normalized):
|
if is_video_url(normalized):
|
||||||
|
|||||||
@ -144,6 +144,13 @@ class DouyinModuleTests(unittest.TestCase):
|
|||||||
self.assertTrue(module.is_aweme_id("7619989983668240802"))
|
self.assertTrue(module.is_aweme_id("7619989983668240802"))
|
||||||
self.assertFalse(module.is_aweme_id("not-an-aweme-id"))
|
self.assertFalse(module.is_aweme_id("not-an-aweme-id"))
|
||||||
|
|
||||||
|
def test_parse_target_input_classifies_recommendation_url(self) -> None:
|
||||||
|
module = importlib.import_module("Douyin")
|
||||||
|
target = module.parse_target_input("https://www.douyin.com/", source="manual")
|
||||||
|
self.assertEqual(target.kind, "recommendation")
|
||||||
|
self.assertEqual(target.value, "https://www.douyin.com/")
|
||||||
|
self.assertEqual(target.source, "manual")
|
||||||
|
|
||||||
def test_parse_target_input_classifies_creator_url(self) -> None:
|
def test_parse_target_input_classifies_creator_url(self) -> None:
|
||||||
module = importlib.import_module("Douyin")
|
module = importlib.import_module("Douyin")
|
||||||
target = module.parse_target_input(
|
target = module.parse_target_input(
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user