From fc2a0b99b06797184ea278d302d5cf1a29d1eca1 Mon Sep 17 00:00:00 2001 From: Blondel MONDESIR Date: Sun, 9 Jun 2024 20:55:30 -0400 Subject: [PATCH 1/6] Set outtmpl externally --- scripts/lb-wrapper | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/lb-wrapper b/scripts/lb-wrapper index abc102f879..1e7e2ce6ca 100755 --- a/scripts/lb-wrapper +++ b/scripts/lb-wrapper @@ -6,6 +6,7 @@ URL_OR_SEARCH_TERM="$2" LOG_FILE="/var/log/xklb.log" XKLB_DB_FILE="/library/calibre-web/xklb-metadata.db" TMP_DOWNLOADS_DIR="/library/downloads/calibre-web" +OUTTMPL="%(extractor_key,extractor)s/%(uploader,uploader_id)s/%(title).170B_%(view_count)3.2D_[%(id).64B].%(ext)s" VERBOSITY="-vv" PATTERNS=( @@ -71,7 +72,7 @@ log "Info" "Using yt-dlp $(yt-dlp --version)" if [[ $XKLB_INTERNAL_CMD == "tubeadd" ]]; then xklb_full_cmd="lb tubeadd ${XKLB_DB_FILE} ${URL_OR_SEARCH_TERM} --force ${VERBOSITY}" elif [[ $XKLB_INTERNAL_CMD == "dl" ]]; then - xklb_full_cmd="lb dl ${XKLB_DB_FILE} --prefix ${TMP_DOWNLOADS_DIR} --video --search ${URL_OR_SEARCH_TERM} ${FORMAT_OPTIONS} --write-thumbnail --subs ${VERBOSITY}" + xklb_full_cmd="lb dl ${XKLB_DB_FILE} --prefix ${TMP_DOWNLOADS_DIR} --video --search ${URL_OR_SEARCH_TERM} ${FORMAT_OPTIONS} --write-thumbnail --subs -o ${OUTTMPL} ${VERBOSITY}" elif [[ $XKLB_INTERNAL_CMD == "search" ]]; then xklb_full_cmd="lb search ${XKLB_DB_FILE} ${URL_OR_SEARCH_TERM}" else From 0ef1e8dd28776245ec30ce63941180e73a8519ba Mon Sep 17 00:00:00 2001 From: Blondel MONDESIR Date: Sun, 9 Jun 2024 21:20:10 -0400 Subject: [PATCH 2/6] Restore thumbnail identification based on filename --- cps/uploader.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cps/uploader.py b/cps/uploader.py index 2e5fd02928..c35b99fc71 100644 --- a/cps/uploader.py +++ b/cps/uploader.py @@ -274,7 +274,7 @@ def video_metadata(tmp_file_path, original_file_name, original_file_extension): # FYI yt_dlp uses YouTube and Vimeo "extractors" -- among ~1810 websites it can scrape: # https://github.com/yt-dlp/yt-dlp/blob/master/supportedsites.md # https://github.com/yt-dlp/yt-dlp/tree/master/yt_dlp/extractor - if file.lower().endswith(('.webp', '.jpg', '.png', '.gif')) and os.path.splitext(file)[0] == video_id: + if file.lower().endswith(('.webp', '.jpg', '.png', '.gif')) and os.path.splitext(file)[0] == os.path.splitext(os.path.basename(row['path']))[0]: cover_file_path = os.path.join(os.path.dirname(row['path']), file) break else: From 5b28ab125e499f5fc7b3a8867e4e1536ef390921 Mon Sep 17 00:00:00 2001 From: Blondel MONDESIR Date: Sun, 9 Jun 2024 22:32:09 -0400 Subject: [PATCH 3/6] Set OUTTMPL to use TMP_DOWNLOADS_DIR --- scripts/lb-wrapper | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/lb-wrapper b/scripts/lb-wrapper index 1e7e2ce6ca..f1ad4967e5 100755 --- a/scripts/lb-wrapper +++ b/scripts/lb-wrapper @@ -6,7 +6,7 @@ URL_OR_SEARCH_TERM="$2" LOG_FILE="/var/log/xklb.log" XKLB_DB_FILE="/library/calibre-web/xklb-metadata.db" TMP_DOWNLOADS_DIR="/library/downloads/calibre-web" -OUTTMPL="%(extractor_key,extractor)s/%(uploader,uploader_id)s/%(title).170B_%(view_count)3.2D_[%(id).64B].%(ext)s" +OUTTMPL="'${TMP_DOWNLOADS_DIR}/%(extractor_key,extractor)s/%(uploader,uploader_id)s/%(title).170B_%(view_count)3.2D_[%(id).64B].%(ext)s'" VERBOSITY="-vv" PATTERNS=( @@ -72,7 +72,7 @@ log "Info" "Using yt-dlp $(yt-dlp --version)" if [[ $XKLB_INTERNAL_CMD == "tubeadd" ]]; then xklb_full_cmd="lb tubeadd ${XKLB_DB_FILE} ${URL_OR_SEARCH_TERM} --force ${VERBOSITY}" elif [[ $XKLB_INTERNAL_CMD == "dl" ]]; then - xklb_full_cmd="lb dl ${XKLB_DB_FILE} --prefix ${TMP_DOWNLOADS_DIR} --video --search ${URL_OR_SEARCH_TERM} ${FORMAT_OPTIONS} --write-thumbnail --subs -o ${OUTTMPL} ${VERBOSITY}" + xklb_full_cmd="lb dl ${XKLB_DB_FILE} --video --search ${URL_OR_SEARCH_TERM} ${FORMAT_OPTIONS} --write-thumbnail --subs -o ${OUTTMPL} ${VERBOSITY}" elif [[ $XKLB_INTERNAL_CMD == "search" ]]; then xklb_full_cmd="lb search ${XKLB_DB_FILE} ${URL_OR_SEARCH_TERM}" else From 397b8c2283547fbdc857efa74b44d4fd08a4e9d0 Mon Sep 17 00:00:00 2001 From: Blondel MONDESIR Date: Mon, 10 Jun 2024 06:26:06 -0400 Subject: [PATCH 4/6] Add explanatory comments Co-authored-by: A Holt --- scripts/lb-wrapper | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scripts/lb-wrapper b/scripts/lb-wrapper index f1ad4967e5..12c1bc6f07 100755 --- a/scripts/lb-wrapper +++ b/scripts/lb-wrapper @@ -6,6 +6,9 @@ URL_OR_SEARCH_TERM="$2" LOG_FILE="/var/log/xklb.log" XKLB_DB_FILE="/library/calibre-web/xklb-metadata.db" TMP_DOWNLOADS_DIR="/library/downloads/calibre-web" +# outtmpl explanation: +# https://github.com/yt-dlp/yt-dlp#output-template +# https://github.com/chapmanjacobd/library/blob/e682ac20f5dcc4fa94238b57931f4705b9515059/xklb/createdb/tube_backend.py#L508-L523 OUTTMPL="'${TMP_DOWNLOADS_DIR}/%(extractor_key,extractor)s/%(uploader,uploader_id)s/%(title).170B_%(view_count)3.2D_[%(id).64B].%(ext)s'" VERBOSITY="-vv" From e0c6c8f6610f899009d786247e93a8e91af31840 Mon Sep 17 00:00:00 2001 From: Blondel MONDESIR Date: Mon, 10 Jun 2024 09:38:14 -0400 Subject: [PATCH 5/6] Add explanatory comment Co-authored-by: A Holt --- scripts/lb-wrapper | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/lb-wrapper b/scripts/lb-wrapper index 12c1bc6f07..4177a1ff04 100755 --- a/scripts/lb-wrapper +++ b/scripts/lb-wrapper @@ -8,6 +8,7 @@ XKLB_DB_FILE="/library/calibre-web/xklb-metadata.db" TMP_DOWNLOADS_DIR="/library/downloads/calibre-web" # outtmpl explanation: # https://github.com/yt-dlp/yt-dlp#output-template +# https://github.com/chapmanjacobd/library/blob/e682ac20f5dcc4fa94238b57931f4705b9515059/xklb/createdb/tube_backend.py#L385-L388 # https://github.com/chapmanjacobd/library/blob/e682ac20f5dcc4fa94238b57931f4705b9515059/xklb/createdb/tube_backend.py#L508-L523 OUTTMPL="'${TMP_DOWNLOADS_DIR}/%(extractor_key,extractor)s/%(uploader,uploader_id)s/%(title).170B_%(view_count)3.2D_[%(id).64B].%(ext)s'" VERBOSITY="-vv" From 9ad60af55b5742fd4a6b57e7b4db3ba83ec4b2fd Mon Sep 17 00:00:00 2001 From: Blondel MONDESIR Date: Mon, 10 Jun 2024 11:51:25 -0400 Subject: [PATCH 6/6] Explain absolute path with tree --- scripts/lb-wrapper | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/scripts/lb-wrapper b/scripts/lb-wrapper index 4177a1ff04..b42c93793c 100755 --- a/scripts/lb-wrapper +++ b/scripts/lb-wrapper @@ -10,6 +10,11 @@ TMP_DOWNLOADS_DIR="/library/downloads/calibre-web" # https://github.com/yt-dlp/yt-dlp#output-template # https://github.com/chapmanjacobd/library/blob/e682ac20f5dcc4fa94238b57931f4705b9515059/xklb/createdb/tube_backend.py#L385-L388 # https://github.com/chapmanjacobd/library/blob/e682ac20f5dcc4fa94238b57931f4705b9515059/xklb/createdb/tube_backend.py#L508-L523 +# /library/downloads/calibre-web/ (TMP_DOWNLOADS_DIR) +# └── Youtube (extractor) +# └── TED-Ed (uploader_id) +# ├── How does an air conditioner actually work? - Anna Rothschild_224.59k_[6sSDXurPX-s].mp4 ([video file] title + view_count + video_id + extension) +# └── How does an air conditioner actually work? - Anna Rothschild_224.59k_[6sSDXurPX-s].webp ([thumbnail] title + view_count + video_id + extension) OUTTMPL="'${TMP_DOWNLOADS_DIR}/%(extractor_key,extractor)s/%(uploader,uploader_id)s/%(title).170B_%(view_count)3.2D_[%(id).64B].%(ext)s'" VERBOSITY="-vv"