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

Update VideonDownloader download logic to download in parallel only when its available #46

Merged
merged 1 commit into from
Dec 4, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions twitter_video_tools/video_downloader.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from __future__ import annotations

from typing import Optional
from typing import Optional, Union

from twitter_video_tools.platform_video_downloader import \
PlatformVideoDownloader
Expand All @@ -25,9 +25,14 @@ def __init__(
self.password = password
self.platform_video_downloader = platform_video_downloader

def download_videos(self, links: list[str]) -> None:
arguments = [(link, ) for link in links]
execute_parallel(self.download_video, arguments)
def download_videos(self, links: Union[str, list[str]]) -> None:
is_parallel_downloadable = isinstance(links, list) and len(links) > 1
if is_parallel_downloadable:
arguments = [(link, ) for link in links]
execute_parallel(self.download_video, arguments)
return
link = links if isinstance(links, str) else links[0]
self.download_video(link)

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