Skip to content

Commit

Permalink
chore(api): rename status update to status hook
Browse files Browse the repository at this point in the history
Signed-off-by: Jordan Shatford <[email protected]>
  • Loading branch information
jordanshatford committed Sep 1, 2023
1 parent ca81bfe commit 1672525
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
10 changes: 5 additions & 5 deletions apps/api/app/utils/managers.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
class AudioDownloadManager:
def __init__(
self, output_dir: str,
announcer: Callable[[DownloadStatusUpdate], None],
status_hook: Callable[[DownloadStatusUpdate], None],
):
self._announcer = announcer
self._status_hook = status_hook
self._downloads: dict[str, YoutubeDownloadThread] = {}
self._output_dir = output_dir

Expand All @@ -44,7 +44,7 @@ def get_all_videos(self) -> list[VideoWithOptions]:
return [d.video for d in self._downloads.values()]

def send_status_update(self, update: DownloadStatusUpdate) -> None:
self._announcer(update)
self._status_hook(update)


class Session:
Expand All @@ -53,7 +53,7 @@ def __init__(self, id: str, session_dir: str):
self._output_dir = os.path.join(session_dir, id)
self._last_use = datetime.now()
self.download_manager = AudioDownloadManager(
self._output_dir, announcer=self._status_update,
self._output_dir, self._status_hook,
)
self.status_queue: Queue[DownloadStatusUpdate] = Queue()

Expand All @@ -70,7 +70,7 @@ def cleanup(self):
except FileNotFoundError:
pass

def _status_update(self, update: DownloadStatusUpdate):
def _status_hook(self, update: DownloadStatusUpdate):
self.status_queue.put(update)


Expand Down
6 changes: 3 additions & 3 deletions apps/api/app/utils/threads.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,11 @@ def __init__(
self,
video: VideoWithOptions,
output_directory: str,
status_update: Callable[[DownloadStatusUpdate], None],
status_hook: Callable[[DownloadStatusUpdate], None],
):
self.video = video
self._output_directory = output_directory
self._status_update = status_update
self._status_hook = status_hook
self.status = DownloadStatus(state=DownloadState.WAITING)

YOUTUBE_DL_OPTIONS = {
Expand Down Expand Up @@ -151,7 +151,7 @@ def run(self):

def _handle_status_update(self, update: DownloadStatus) -> None:
self.status = update
self._status_update(
self._status_hook(
DownloadStatusUpdate(
id=self.video.id, **update.dict(),
),
Expand Down

1 comment on commit 1672525

@vercel
Copy link

@vercel vercel bot commented on 1672525 Sep 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.