chapmanjacobd / library

80+ CLI tools to build, browse, and blend your media library: an index for your archive.
BSD 3-Clause "New" or "Revised" License
355 stars 9 forks source link

Too many values to unpack #21

Closed deldesir closed 9 months ago

deldesir commented 9 months ago

Describe the bug When attempting to use the lb dl command with the provided arguments and configuration, an error occurs during the parsing of the --extractor-config argument. The specific error message is: "argument --extractor-config/-extractor-config: Could not parse argument "['format=bestvideo[height<=720][vcodec=vp9]+bestaudio/best[height<=720][vcodec=vp9]']" as k1=1 k2=2 format too many values to unpack (expected 2)."

To Reproduce

  1. Execute the following command in the terminal:
    lb tubeadd test.db https://youtu.be/WcLlpWmEpQ8  --verbose && \
    lb dl test.db --prefix /home/user/Downloads --extractor-config "writethumbnail=True" \
        --extractor-config "format=bestvideo[height<=720][vcodec=vp9]+bestaudio/best[height<=720][vcodec=vp9]" --video https://youtu.be/WcLlpWmEpQ8 --verbose

Expected behavior The lb dl command should execute without errors, utilizing the specified video URL and extractor configurations, and initiate the download process.

Screenshots N/A

Desktop:

Additional context It seems that the issue is related to the parsing of the --extractor-config argument, specifically with the provided configuration string "['format=bestvideo[height<=720][vcodec=vp9]+bestaudio/best[height<=720][vcodec=vp9]'." The error suggests that there is an unexpected number of values to unpack during the parsing process, though it's technically 2.

Here is the actual log:

library v2.2.165
['/usr/local/bin/lb', 'dl', '/var/tmp/test.db', '--video', 'https://youtu.be/WcLlpWmEpQ8', '--extractor-config', 'writethumbnail=True', '--extractor-config', 'format=bestvideo[height<=720][vcodec=vp9]+bestaudio/best[height<=720][vcodec=vp9]', '--verbose']
usage: library download [--prefix /home/user/Downloads] [--safe] [--subs] [--auto-subs] [--small] DATABASE --video | --audio | --photos

    Files will be saved to <lb download prefix>/<extractor>/. If prefix is not specified the current working directory will be used

    By default things will download in a random order

        library download dl.db --prefix ~/output/path/root/

    Limit downloads to a specified playlist URLs or substring

        library download dl.db https://www.youtube.com/c/BlenderFoundation/videos

    Maximizing the variety of subdomains

        library download photos.db --photos --image --sort "ROW_NUMBER() OVER ( PARTITION BY SUBSTR(m.path, INSTR(m.path, '//') + 2, INSTR( SUBSTR(m.path, INSTR(m.path, '//') + 2), '/') - 1) )"

    Print list of queued up downloads

        library download --print

    Print list of saved playlists

        library playlists dl.db -p a

    Print download queue groups

        library download-status audio.db
        ╒════════════╤══════════════════╤════════════════════╤══════════╕
        │ extractor_key     │ duration         │   never_downloaded │   errors │
        ╞════════════╪══════════════════╪════════════════════╪══════════╡
        │ Soundcloud │                  │                 10 │        0 │
        ├────────────┼──────────────────┼────────────────────┼──────────┤
        │ Youtube    │ 10 days, 4 hours │                  1 │     2555 │
        │            │ and 20 minutes   │                    │          │
        ├────────────┼──────────────────┼────────────────────┼──────────┤
        │ Youtube    │ 7.68 minutes     │                 99 │        1 │
        ╘════════════╧══════════════════╧════════════════════╧══════════╛
library download: error: argument --extractor-config/-extractor-config: Could not parse argument "['format=bestvideo[height<=720][vcodec=vp9]+bestaudio/best[height<=720][vcodec=vp9]']" as k1=1 k2=2 format too many values to unpack (expected 2)
chapmanjacobd commented 9 months ago

ah yeah sorry about that

This should work starting from v2.2.167:

--extractor-config "writethumbnail=True format=bestvideo[height<=720][vcodec=vp9]+bestaudio/best[height<=720][vcodec=vp9]"

Let me know if you experience any other bugs

thx

chapmanjacobd commented 9 months ago

With v2.2.170 it should be possible to do:

lb dl test.db --video --prefix /home/user/Downloads \
    --write-thumbnail \
    --format='bestvideo[height<=720][vcodec=vp9]+bestaudio/best[height<=720][vcodec=vp9]'

Or use any other yt-dlp option directly instead of going through --extractor-config within the --audio and --video download modes.

However, there are some option conflicts. Only the unknown options are passed to yt-dlp. For example, -f will be read into xklb first (a shortcut for --force) before being passed to yt-dlp. You should be pretty safe using the long options or just keep using --extractor-config.

If an option can't be read by either xklb nor yt-dlp then it will show up as an no such option: error.

also closes #10