Skip to content
This repository was archived by the owner on Apr 17, 2023. It is now read-only.

Commit 6d90783

Browse files
committed
Update VideoDownloader download logic
This commit changes download logic. Parallel downloading is enabled only when given link is multiple.
1 parent 7783e35 commit 6d90783

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

twitter_video_tools/video_downloader.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from __future__ import annotations
22

3-
from typing import Optional
3+
from typing import Optional, Union
44

55
from twitter_video_tools.platform_video_downloader import \
66
PlatformVideoDownloader
@@ -25,9 +25,14 @@ def __init__(
2525
self.password = password
2626
self.platform_video_downloader = platform_video_downloader
2727

28-
def download_videos(self, links: list[str]) -> None:
29-
arguments = [(link, ) for link in links]
30-
execute_parallel(self.download_video, arguments)
28+
def download_videos(self, links: Union[str, list[str]]) -> None:
29+
is_parallel_downloadable = isinstance(links, list) and len(links) > 1
30+
if is_parallel_downloadable:
31+
arguments = [(link, ) for link in links]
32+
execute_parallel(self.download_video, arguments)
33+
return
34+
link = links if isinstance(links, str) else links[0]
35+
self.download_video(link)
3136

3237
def download_video(self, link: str) -> None:
3338
if 'monsnode.com' in link:

0 commit comments

Comments
 (0)