From 09ffa53a322eacaaa624ffe64447952ffd48f6ad Mon Sep 17 00:00:00 2001
From: Christian Heller <c.heller@plomlompom.de>
Date: Mon, 25 Nov 2024 00:21:18 +0100
Subject: [PATCH] Ensure thumbnail directory exists when retrieving on query.

---
 install_to_share/ytplom/misc.py | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/install_to_share/ytplom/misc.py b/install_to_share/ytplom/misc.py
index 647ad39..0c2777e 100644
--- a/install_to_share/ytplom/misc.py
+++ b/install_to_share/ytplom/misc.py
@@ -83,7 +83,7 @@ QUOTA_COST_YOUTUBE_DETAILS = QuotaCost(1)
 TIMESTAMP_FMT = '%Y-%m-%d %H:%M:%S.%f'
 LEGAL_EXTENSIONS = {'webm', 'mp4', 'mkv'}
 
-# tables to create database with
+# database stuff
 EXPECTED_DB_VERSION = 0
 SQL_DB_VERSION = SqlText('PRAGMA user_version')
 PATH_MIGRATIONS = PathStr(path_join(PATH_APP_DATA, 'migrations'))
@@ -91,7 +91,7 @@ PATH_DB_SCHEMA = PathStr(path_join(PATH_MIGRATIONS,
                                    f'init_{EXPECTED_DB_VERSION}.sql'))
 
 # other
-NAME_INSTALLER = 'install.sh'
+NAME_INSTALLER = PathStr('install.sh')
 VIDEO_FLAGS: dict[FlagName, FlagsInt] = {
   FlagName('delete'): FlagsInt(1 << 62)
 }
@@ -658,6 +658,7 @@ class TaskHandler(BaseHTTPRequestHandler):
         conn = DatabaseConnection()
 
         def collect_results(query_txt: QueryText) -> list[YoutubeVideo]:
+            _ensure_expected_dirs([PATH_THUMBNAILS])
             youtube = googleapiclient.discovery.build('youtube', 'v3',
                                                       developerKey=API_KEY)
             QuotaLog.update(conn, QUOTA_COST_YOUTUBE_SEARCH)
-- 
2.30.2