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

Refactor lb-wrapper for command separation #110

Merged
merged 15 commits into from
Jan 31, 2024

Conversation

deldesir
Copy link
Collaborator

@deldesir deldesir commented Jan 25, 2024

🚀 Pull Request Overview:

This pull request modified lb-wrapper to allow separate execution of 'tubeadd' and 'dl' commands. The script now takes a command type ('tubeadd' or 'dl') as the first argument, allowing users to choose which xklb command to run. Each command is executed independently with its own set of options.

This aims to facilitate the listing of requested files once lb tubeadd is done fetching metadata.

📋 Checklist:

  • Tested the changes thoroughly.

🔗 Related Issue(s):
Issue #104

📌 Testing scenarios:
See Issue #97

cc @EMG70

PS This PR builds upon #109

@deldesir deldesir requested a review from holta January 25, 2024 22:40
@deldesir deldesir self-assigned this Jan 25, 2024
@deldesir deldesir closed this Jan 25, 2024
@deldesir deldesir force-pushed the deldesir-xklb-commands branch from ea320c2 to d98f002 Compare January 25, 2024 23:06
@deldesir deldesir reopened this Jan 25, 2024
exit 1
fi

command_type=$1
Copy link
Member

@holta holta Jan 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Personally I'd prefer these 2 right on the very top of the file, as the very first constants declared...

XKLB_CMD="$1"
URL="$2"

...to make the bash script more readable 🙏

Copy link
Member

@holta holta Jan 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or if necessary... ?

XKLB_INTERNAL_CMD="$1"
URL="$2"

And maybe preserve the original XKLB_FULL_CMD variable name alongside, to reduce confusion?

Copy link
Collaborator Author

@deldesir deldesir Jan 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

XKLB_INTERNAL_CMD="$1"
URL="$2"

Using "$1" and appending the URL at the end makes the command ugly and difficult to grasp

And maybe preserve the original XKLB_FULL_CMD variable name alongside, to reduce confusion?

We can't per the design of separating them to decouple metadata fetching and video downloading

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It sounds like you're not understanding my suggestions.

I'll try to reach you privately.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for explaining. Done.

scripts/lb-wrapper Outdated Show resolved Hide resolved
Co-authored-by: A Holt <holta@users.noreply.github.com>
@deldesir deldesir marked this pull request as draft January 25, 2024 23:44
if [ "$command_type" == "tubeadd" ]; then
XKLB_CMD="${XKLB_EXECUTABLE} tubeadd ${XKLB_DB_FILE} ${URL} ${VERBOSITY}"
elif [ "$command_type" == "dl" ]; then
FORMAT_OPTIONS="--format best --format-sort 'tbr~1000'"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Special Request: Please keep all "CONSTANTS" near the top of the bash script (this one especially should stay where it is around Line 13, with the English explanation about alternatives for OOM debugging etc!)

FORMAT_OPTIONS="--format best --format-sort 'tbr~1000'"

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

scripts/lb-wrapper Outdated Show resolved Hide resolved
Co-authored-by: A Holt <holta@users.noreply.github.com>
scripts/lb-wrapper Outdated Show resolved Hide resolved
Co-authored-by: A Holt <holta@users.noreply.github.com>
exit 1
fi

# 2024-01-21: Not needed as XKLB reports its own version# to /var/log/xklb.log
# log "Info" "xklb version: $(${XKLB_EXECUTABLE} --version)"

log "Info" "Running xklb commands: ${XKLB_FULL_CMD}"
# 2024-01-24: Not needed as we don't discard the database anymore
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please (re)delete lines 55-58 per JC suggestion (:

As was merged with PR #109 here:

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@@ -40,21 +40,30 @@ fi
# exit 1
# fi

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Validation on Lines 43-44 should definitely be restored in my opinion:

if ! command -v "${XKLB_EXECUTABLE}"; then
    log "Error" "xklb could not be found. Please install xklb and try again."

(...followed by a blank line if possible!)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@holta
Copy link
Member

holta commented Jan 26, 2024

@deldesir this is getting closer.

  1. Please remove Lines 16-18:

    (As XKLB_FULL_CMD is definitely no longer a "constant" — xklb_full_cmd is now a variable that should clearly be set [within if / else] to one-value-or-another.)

  2. Please clarify where lb-wrapper is invoked and how that will need to be revised.

scripts/lb-wrapper Outdated Show resolved Hide resolved
@holta holta marked this pull request as ready for review January 26, 2024 04:20
@holta
Copy link
Member

holta commented Jan 26, 2024

  1. @EMG70 please install all 4 PR's together:

    ...onto a fresh Multipass VM running Ubuntu 24.04 (latest pre-release).

  2. Then please Test Scenarios 1., 2. and 3. especially (from Testing scenarios for multimedia downloads using iiab/calibre-web [TDD, Gherkin Stories] #97, screenshot below!) Do not expect 4. and 5. to work well just yet!

Screenshot_20240126-114201~2

@holta holta changed the title Refactor lb-wrapper for command separation Refactor lb-wrapper for command separation Jan 26, 2024
@holta holta added the enhancement New feature or request label Jan 26, 2024
Acts as a mechanism to synchronize with the 2 download cycles (2 mentions of downloading each)
@holta
Copy link
Member

holta commented Jan 31, 2024

Thank you @EMG70 and @deldesir for careful TDD (focused testing) over the past week.

Looking to the future now with these PRs are others:

@holta holta merged commit 00c31e1 into iiab:master Jan 31, 2024
@deldesir deldesir deleted the deldesir-xklb-commands branch July 1, 2024 21:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants