Skip to content

Commit

Permalink
Throw error when video not found
Browse files Browse the repository at this point in the history
  • Loading branch information
Douile committed Sep 19, 2023
1 parent 3baf6ef commit 06ad6a8
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion friends_queue/video_queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
from .thumbnail_cache import ThumbnailCache


class VideoNotFoundException(Exception):
"""Thrown when a video was not found"""


@dataclass
class VideoQueueItem:
"""Video Queue item data"""
Expand Down Expand Up @@ -173,6 +177,7 @@ def run(self):
self._has_started = True
try:
self._do_fetch()
# pylint: disable=bare-except
except:
self._error = sys.exception()
traceback.print_exception(self._error)
Expand All @@ -182,7 +187,9 @@ def _do_fetch(self):
info = self._ytdl.extract_info(self._item.url, download=False)

if info is None:
return # TODO: handle error
raise VideoNotFoundException(
f'Unable to find a video that matches "{self._item.url}"'
)

if info.get("_type") == "playlist":
info = info.get("entries")[0]
Expand Down

0 comments on commit 06ad6a8

Please sign in to comment.