import googleapiclient.discovery # type: ignore
from mpv import MPV # type: ignore
from yt_dlp import YoutubeDL # type: ignore
+from yt_dlp.utils import YoutubeDLError # type: ignore
# ourselves
from ytplom.db import DbConn, DbData, Hash
from ytplom.primitives import HandledException, NotFoundException
url = f'{YOUTUBE_URL_PREFIX}{video_id}'
with YoutubeDL(YT_DL_PARAMS | {'progress_hooks': [hook]}) as ydl:
self._update_status(video_id, 'preparing download')
- info = ydl.sanitize_info(ydl.extract_info(url, download=False))
- for f in info['requested_formats']:
- sizes[f[TOK_FO_ID]] = [False, 1]
- if TOK_FS_AP in f:
- sizes[f[TOK_FO_ID]] = [True, f[TOK_FS_AP]]
- ydl.download(url)
+ try:
+ info = ydl.sanitize_info(ydl.extract_info(url,
+ download=False))
+ for f in info['requested_formats']:
+ sizes[f[TOK_FO_ID]] = [False, 1]
+ if TOK_FS_AP in f:
+ sizes[f[TOK_FO_ID]] = [True, f[TOK_FS_AP]]
+ ydl.download(url)
+ except YoutubeDLError as e:
+ self._update_status(video_id, 'ERROR')
+ raise e
self._sync_db()
def start_thread(self) -> None: