Skip to content

Commit

Permalink
Merge pull request #177 from deldesir/deldesir-patch-39
Browse files Browse the repository at this point in the history
Set outtmpl externally [to avoid missing thumbnails; NOTE: archival-quality book & video titles are preserved in 2 SQLite db's]
  • Loading branch information
holta authored Jun 10, 2024
2 parents f28a0b7 + 9ad60af commit 48deb54
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion cps/uploader.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
12 changes: 11 additions & 1 deletion scripts/lb-wrapper
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,16 @@ 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#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"

PATTERNS=(
Expand Down Expand Up @@ -71,7 +81,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} --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
Expand Down

0 comments on commit 48deb54

Please sign in to comment.