-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Jordan Shatford <[email protected]>
- Loading branch information
1 parent
39ccd7f
commit 9ff2dae
Showing
10 changed files
with
55 additions
and
52 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
from typing import Callable | ||
|
||
from ..models import DownloadStatusUpdate | ||
from ..models import VideoWithOptions | ||
from ..models import VideoWithOptionsAndStatus | ||
from .threads import YoutubeDownloadThread | ||
|
||
|
||
class AudioDownloadManager: | ||
def __init__( | ||
self, output_dir: str, | ||
status_hook: Callable[[DownloadStatusUpdate], None], | ||
): | ||
self._status_hook = status_hook | ||
self._downloads: dict[str, YoutubeDownloadThread] = {} | ||
self._output_dir = output_dir | ||
|
||
def __contains__(self, video_id: str) -> bool: | ||
return video_id in self._downloads | ||
|
||
def add(self, video: VideoWithOptions) -> None: | ||
if video.id not in self._downloads: | ||
download = YoutubeDownloadThread( | ||
video, self._output_dir, self.send_status_update, | ||
) | ||
self._downloads[video.id] = download | ||
download.start() | ||
|
||
def remove(self, video_id: str) -> None: | ||
if video_id in self._downloads: | ||
self._downloads[video_id].remove() | ||
self._downloads.pop(video_id, None) | ||
|
||
def get(self, video_id: str) -> YoutubeDownloadThread | None: | ||
return self._downloads.get(video_id, None) | ||
|
||
def get_all_videos(self) -> list[VideoWithOptionsAndStatus]: | ||
return [ | ||
VideoWithOptionsAndStatus(**d.video.dict(), status=d.status) | ||
for d in self._downloads.values() | ||
] | ||
|
||
def send_status_update(self, update: DownloadStatusUpdate) -> None: | ||
self._status_hook(update) |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9ff2dae
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
youtube-audio-downloader – ./
youtubeaudiodownloader.vercel.app
utubedownloader.vercel.app
yt-downloading.vercel.app
ytdownloading.vercel.app
youtube-audio-downloader-jordanshatford.vercel.app
youtbedownloader.vercel.app
youtube-downloading.vercel.app
youtubedownloading.vercel.app
youtube-audio-downloader-git-main-jordanshatford.vercel.app