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

Log progress while downloading #26

Closed deldesir closed 8 months ago

deldesir commented 8 months ago

Is your feature request related to a problem? Please describe. When using lb tubeadd and lb dl with --verbose option, I wished yt_dlp output weren't supressed. This makes it difficult to track the progress of video downloads.

Describe the solution you'd like I would like the ability to see the progress of video downloads. This could be achieved by allowing an option to display the download progress logs during execution.

Describe alternatives you've considered I have considered manually modifying tube_backend.py to enable yt_dlp output

   "default_opts": {
    ...
    "quiet": False,
    "noprogress": False,
    "skip_download": False,
    ...
    }

but a built-in option to control log visibility during execution would be more convenient and user-friendly.

Additional context Having a real-time progress indicator for downloads would make it easier to monitor the status of ongoing downloads.

chapmanjacobd commented 8 months ago

The default logging is minimal so that novel errors are obvious.

You can run with -v, -vv, -vvv, or -vvvv for more verbose logging.

ie. lb dl -vvv or lb dl --verbose --verbose --verbose

You can use the lb download-status command.

holta commented 8 months ago

You can use the lb download-status command.

Interesting. And lb download_status with underscore appears to be equivalent:

https://github.com/chapmanjacobd/library/blob/0c08fd4814aebbc087284543c266f28c207cadd4/xklb/lb.py#L41

Just FYI --help or -h output below (if I'm reading it correctly!) suggests this is not for ongoing monitoring of granular details e.g. during the download of large/individual videos.

(Not a walk in the park to parse animation-like text output of things like rsync --info=progress2 of course ;-)

But we'll find a way eventually! ๐Ÿ’ฏ

root@box:~# lb download-status -h
usage: library download-status DATABASE

    Print download queue groups

        library download-status video.db
        โ•’โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•คโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•คโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•คโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ••
        โ”‚ extractor_key      โ”‚ duration         โ”‚   never_downloaded โ”‚   errors โ”‚
        โ•žโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•ชโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•ชโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•ชโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•ก
        โ”‚ Youtube     โ”‚ 3 hours and 2.07 โ”‚                 76 โ”‚        0 โ”‚
        โ”‚             โ”‚ minutes          โ”‚                    โ”‚          โ”‚
        โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
        โ”‚ Dailymotion โ”‚                  โ”‚                 53 โ”‚        0 โ”‚
        โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
        โ”‚ Youtube     โ”‚ 1 day, 18 hours  โ”‚                 30 โ”‚        0 โ”‚
        โ”‚             โ”‚ and 6 minutes    โ”‚                    โ”‚          โ”‚
        โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
        โ”‚ Dailymotion โ”‚                  โ”‚                186 โ”‚      198 โ”‚
        โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
        โ”‚ Youtube     โ”‚ 1 hour and 52.18 โ”‚                  1 โ”‚        0 โ”‚
        โ”‚             โ”‚ minutes          โ”‚                    โ”‚          โ”‚
        โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
        โ”‚ Vimeo       โ”‚                  โ”‚                253 โ”‚       49 โ”‚
        โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
        โ”‚ Youtube     โ”‚ 2 years, 4       โ”‚              51676 โ”‚      197 โ”‚
        โ”‚             โ”‚ months, 15 days  โ”‚                    โ”‚          โ”‚
        โ”‚             โ”‚ and 6 hours      โ”‚                    โ”‚          โ”‚
        โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
        โ”‚ Youtube     โ”‚ 4 months, 23     โ”‚               2686 โ”‚        7 โ”‚
        โ”‚             โ”‚ days, 19 hours   โ”‚                    โ”‚          โ”‚
        โ”‚             โ”‚ and 33 minutes   โ”‚                    โ”‚          โ”‚
        โ•˜โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•งโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•งโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•งโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•›

    Simulate --safe flag

        library download-status video.db --safe

positional arguments:
  database

options:
  -h, --help            show this help message and exit
  --cols [COLS ...], -cols [COLS ...], -col [COLS ...]
                        Include a column when printing (default: None)
  --safe, -safe         Skip generic URLs (default: False)
  --retry-delay RETRY_DELAY, -r RETRY_DELAY
                        Must be specified in SQLITE Modifiers format: N hours, days, months, or years
                        (default: 14 days)
  -v, --verbose
chapmanjacobd commented 8 months ago

Yes, xklb prioritizes interactive and experimental use.

Perhaps you could query the SQLITE database directly to see if any recoverable, unrecoverable errors occurred during the previous download attempt.

holta commented 8 months ago

Perhaps you could query the SQLITE database directly to see if any recoverable, unrecoverable errors occurred

Excellent Suggestion, Thanks! ๐Ÿ‘Œ

Context:

deldesir commented 8 months ago

Yes, xklb prioritizes interactive and experimental use.

Perhaps you could query the SQLITE database directly to see if any recoverable, unrecoverable errors occurred during the previous download attempt.

Thanks @chapmanjacobd. I will implement your suggestion. I think it will help.

chapmanjacobd commented 8 months ago

Thanks for opening this issue. I realize now that log.debug("\n".join(ydl_full_log)) was commented out. I've pushed up a new version v2.3.001 which will print the full yt-dlp log with four levels of verbosity or more -vvvv. I hope that will help with what you are trying to do.

I also added a quick scan of the downloaded media file to check that the download was not interrupted. If it was then you should see "Media check failed" in the SQLITE database. If that happens when you run lb dl again it should resume from the last byte written. You will need to set the retry time to something small like 1 second lb dl --retry-delay '1 second'

The default is to retry after two weeks because most recoverable errors are not transient errors but take time to resolve [account inactivity, copyright trolls, geofencing / IP block, etc]).

holta commented 8 months ago

You will need to set the retry time to something small like 1 second lb dl --retry-delay '1 second'

The default is to retry after two weeks because most recoverable errors are not transient errors but take time to resolve [account inactivity, copyright trolls, geofencing, etc]).

Critical & vital logistics, Thanks for explaining!

Background: In practice, most Internet-in-a-Box implementers are not professional curriculum designers and so try to provision all content (for their school, clinic, church, prison, family, etc) within a single weekend โ€” and often lose patience (declaring victory!) within ~24h maximum. ๐Ÿ˜‰

chapmanjacobd commented 8 months ago

I should clarify that yt-dlp will retry on network and similar transient errors by default so any mid-download interruption is likely the result of getting IP-blocked by the site that is hosting the video. Retrying after 20 minutes or one hour would likely be a better strategy than immediately retrying but many video site IP blocks last longer than a day.