Skip to content

Commit 68d5ea5

Browse files
committed
add video-search from url case
1 parent 301a2e0 commit 68d5ea5

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

youtool/commands/video_search.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ def execute(cls: Self, **kwargs) -> str:
6666
Raises:
6767
Exception: If neither ids, urls, nor input_file_path is provided.
6868
"""
69-
ids = kwargs.get("ids")
70-
urls = kwargs.get("urls")
69+
ids = kwargs.get("ids", [])
70+
urls = kwargs.get("urls", [])
7171
input_file_path = kwargs.get("input_file_path")
7272
output_file_path = kwargs.get("output_file_path")
7373
api_key = kwargs.get("api_key")
@@ -89,13 +89,12 @@ def execute(cls: Self, **kwargs) -> str:
8989

9090
youtube = YouTube([api_key], disable_ipv6=True)
9191

92-
videos_infos = []
93-
94-
if ids:
95-
videos_infos += list(youtube.videos_infos(ids))
9692
if urls:
97-
# TODO: add get videos_infos using urls to youtool
98-
raise NotImplementedError("videos_infos by url not implemented yet")
93+
ids += [cls.video_id_from_url(url) for url in urls]
94+
95+
# Remove duplicated
96+
ids = list(set(ids))
97+
videos_infos = list(youtube.videos_infos([_id for _id in ids if _id]))
9998

10099
return cls.data_to_csv(
101100
data=[

0 commit comments

Comments
 (0)