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

fix YoutubeDLWrapper downloading #45

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
11 changes: 9 additions & 2 deletions twitter_video_tools/utils/youtube_dl_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,21 @@
class YoutubeDLWrapper: # pylint: disable=too-few-public-methods
"""A YoutubeDL wrapper class for supporting python embedded multi-processing"""

def _youtube_dl_download_video(self, link: str, youtube_dl_option: Optional[dict[str, str]] = None) -> None:
def _youtube_dl_download_video(
self,
link: str,
youtube_dl_option: Optional[dict[str, Union[str, int]]] = None,
) -> None:
with yt_dlp.YoutubeDL(youtube_dl_option) as youtube_dl_downloader:
youtube_dl_downloader: yt_dlp.YoutubeDL
youtube_dl_downloader.download([link])

def download(self, links: list[str], youtube_dl_option: Optional[dict[str, Union[str, int]]] = None) -> None:
arguments = [(link, youtube_dl_option) for link in links]
execute_parallel(self._youtube_dl_download_video, arguments)
if len(links) == 1:
self._youtube_dl_download_video(links[0], youtube_dl_option)
else:
execute_parallel(self._youtube_dl_download_video, arguments)


youtube_dl_wrapper = YoutubeDLWrapper() # singleton