Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set outtmpl externally [to avoid missing thumbnails; NOTE: archival-quality book & video titles are preserved in 2 SQLite db's] #177

Merged
merged 6 commits into from
Jun 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
deldesir marked this conversation as resolved.
Show resolved Hide resolved
# 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'"
holta marked this conversation as resolved.
Show resolved Hide resolved
holta marked this conversation as resolved.
Show resolved Hide resolved
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