iiab / calibre-web

:books: Web app for browsing, reading and downloading eBooks stored in a Calibre database
GNU General Public License v3.0
4 stars 5 forks source link

An attempt to download [a YouTube channel] resulted in an accumulation (long list) of "unavailable videos" in Tasks, from all current and previously attempted failed downloads [why is the very same video individually downloadable?] #238

Open EMG70 opened 2 months ago

EMG70 commented 2 months ago

Describe the bug/problem An attempt to download playlists results in an accumulation of long list in Tasks " unavailable videos" from all current and previously attempts.

A clear and concise description of what the bug is. If you are asking for support, please check our Wiki if your question is already answered there.

Unavailable videos for any reason are expected to show as those that have failed for the playlist not cumulative list from previous downloads.

To Reproduce

Download Steps to reproduce the behavior:

  1. Go to 'https://www.youtube.com/@agribusinesswithwadzanaima275' name of playlist
  2. Click on 'https://www.youtube.com/watch?v=EiMFnDquvdM' failing video being added to the list of unavailable videos
  3. https://www.youtube.com/watch?v=b4RLo3tgpoA failing video being added to the list of unavailable videos
  4. Scroll down to '....'
  5. See error

Logfile SUDO IIAB-DIAGNOSTICS - https://paste.centos.org/view/10fc9a97

calibre-web.log

Add content of calibre-web.log file or the relevant error, try to reproduce your problem with "debug" log-level to get more output.

Expected behavior

Unavailable videos for any reason are expected to show as those that have failed for the playlist not cumulative list from previous downloads.

A clear and concise description of what you expected to happen.

Screenshots Screenshot from 2024-08-20 17-34-33

If applicable, add screenshots to help explain your problem.

Environment (please complete the following information):

Additional context Add any other context about the problem here. [e.g. access via reverse proxy, database background sync, special database location] This is a members only video https://www.youtube.com/watch?v=MfRdmsbs3R8 but also gets added to list of unavailable accumulative list. Screenshot from 2024-08-20 17-45-35

This video https://www.youtube.com/watch?v=EiMFnDquvdM fails to download as part of playlist https://www.youtube.com/@agribusinesswithwadzanaima275 but successfully downloaded as an individual url.(last line of screenshot) Screenshot from 2024-08-20 17-40-12

The results are however not consistent ,some individual public urls are still failing. eg https://www.youtube.com/watch?v=AT4khVKBBkg which plays well in youtube.

deldesir commented 2 months ago

Here is why: https://github.com/iiab/calibre-web/blob/486b7bbcb5b5450c81850846f771f329d3dc238b/scripts/lb-wrapper#L82 This line of code from lb-wrapper ensures, with the use of --force, to update already existed metadata for a given path as explained in https://github.com/chapmanjacobd/library/blob/main/xklb/usage.py#L570-L572

holta commented 2 months ago

@deldesir which below are most relevant? (In helping us explain — and decide what to do next!)

holta commented 2 months ago

@EMG70 just FYI @deldesir is looking into this, but it might not be easy!

Something equivalent to xklb tubeadd's --force might be needed for entire playlists — not just single videos ?

(Sorting out how xklb helps us with download errors & metadata-extract.py for entire playlists — not just single videos — likely needs work!)

EMG70 commented 2 months ago

@EMG70 just FYI @deldesir is looking into this, but it might not be easy!

Something equivalent to xklb tubeadd's --force might be needed for entire playlists — not just single videos ?

(Sorting how xklb helps us with download errors & metadata-extract.py for entire playlists — not just single videos — likely needs work!)

Thank you

holta commented 2 months ago
  1. Go to https://www.youtube.com/@agribusinesswithwadzanaima275 name of playlist

@EMG70: Were you aware that you are trying to download an entire YouTube Channel here — rather than a standard playlist?

@deldesir is investigating if this might possibly be exacerbating the problem.

  1. FWIW this particular channel contains 220 videos and 0 [zero] playlists...)

    image

  2. Whereas many YouTube channels contain playlists — e.g. https://youtube.com/@bbc has 6 tabs including "Playlists" ...

    image

Tangentially, @deldesir is being affected by IP addresses (cloud VPS IP addresses especially?) being banned / blocked by YouTube, as mentioned below...

EMG70 commented 2 months ago

Yes I was aware of her 220 agricultural videos under her channel ,unfortunately she doesn't group them by Playlist.I have downloaded same videos successfully before my calibre-web got corrupted after upgrading to 24.04 in last two weeks . It could well be the new Youtube restrictions which came up recently.

holta commented 2 months ago

@deldesir suspects the large number of videos (220 in this case) might be causing this problem?

Regardless whether or not contained in a standard playlist.

deldesir commented 2 months ago

Yes, the number of videos might trigger a restriction. 220 videos were processed to get their metadata extracted so 100 of them could be downloaded. Tests with single videos downloaded in another VM in another location went through without a problem.

EMG70 commented 2 months ago

Thank you ,I think that explains it .This said calibre-web /server was built circa March 2024, probably before the 100 video limit was implemented ,so explains why i initially managed. I guess things changed when i ran sudo iiab-update-f.

holta commented 2 months ago

@EMG70 can you please retest, on a completely clean/fresh VM? @deldesir too should investigate & test wherever he can help shed light, as I just tried "Download to IIAB" with https://www.youtube.com/@agribusinesswithwadzanaima275 and the 220 videos are downloading perfectly so far... (100% success with the first 10 videos anyway!)

image

EMG70 commented 2 months ago

Will do

holta commented 2 months ago

Will do

Thanks! FYI @EMG70 33 videos (of 220) downloaded successfully over about 30min, so I cut it off by running systemctl restart calibre-web

PS I could have run rm /library/calibre-web/xklb-metadata.db to force the remaining ~187 videos not to try again — which will likely to happen the next time "Download to IIAB" is attempted! ASIDE: In future, this kind of canceling of stale downloading jobs (might!) be done automatically by something like... ?

EMG70 commented 2 months ago

Tested with a new VM ,100 videos successfully downloaded from the channel https://www.youtube.com/@agribusinesswithwadzanaima275. Screenshot from 2024-08-29 12-26-18

calibre-web.log

holta commented 2 months ago

@deldesir should (speculate!) as to the true root cause:

What really changed since a week ago, to cause this to start working again?

holta commented 2 months ago

@EMG70 when exactly did you try downloading "up to 300 videos" instead of "up to 100 videos" ?

(Thanks for clarifying, just in case this happens to be related!)

holta commented 2 months ago

@EMG70 when exactly did you try downloading "up to 300 videos" instead of "up to 100 videos" ?

@EMG70 is the timeline/summary below accurate, to help us all understand?

holta commented 2 months ago

@deldesir please help us understand what could have caused most of 100 videos to fail to download (Unavailable Video(s):) on 2024-08-20 (this issue #238 !)

holta commented 2 months ago

@deldesir please help @EMG70 & all of us deepen our intuition as to what might-or-might-not have been happening to cause this last week!

@EMG70 asks:

This accumulation of failed videos [ Unavailable Video(s): ] was also happening on a VM last week when i tried same channel,probably meaning something changed on latest script ?

deldesir commented 2 months ago

@deldesir please help us understand what could have caused most of 100 videos to fail to download (Unavailable Video(s):) on 2024-08-20 (this issue #238 !)

Since reproducibility of the issue is not possible anymore and the log doesn't contain an error relevant to the failures, I am afraid we'll have to rely on untested assumptions.

What I know is at the time of the bug, yt-dlp 2024.08.06 and xklb 2.9.026 were in use.

holta commented 2 months ago

at the time of the bug, yt-dlp 2024.08.06 and xklb 2.9.026 were in use.

Ok! xklb 2.9.026 could easily be tested to check if that might be the cause?

As outlined in https://github.com/iiab/calibre-web/wiki#xklb-and-yt-dlp-backend-integration — everyone should do this regularly to keep assumptions grounded in reality:

To revert to a prior version, e.g. 2.9.026:

pipx install --force xklb==2.9.026

holta commented 2 months ago

To revert to a prior version, e.g. 2.9.026:

pipx install --force xklb==2.9.026

Much safer method below! (as wiki doc explains)

pipx uninstall xklb
pipx install xklb==2.9.026
deldesir commented 2 months ago

Tested with xklb 2.9.026 without a problem. Might be related to xklb-metadata.db being corrupted at the time. image

EMG70 commented 2 months ago

Thanks all .Probably off topic,Am i right in saying one can edit code in /usr/local/calibre-web-py3/cps/constants.py if they really need to download more than 100 videos ? as on screenshot below: IMG_4833

holta commented 2 months ago

/usr/local/calibre-web-py3/cps/constants.py

Yes this is off-topic :smile:

But of course feel free to try! And if YouTube eventually blocks your IP address (e.g. #243 or similar), or you run into any other problems, definitely let us know!

RECAP: @EMG70 modified MAX_VIDEOS_PER_DOWNLOAD = 100 to MAX_VIDEOS_PER_DOWNLOAD = 300 in the past... and everyone is free to try doing similar...

https://github.com/iiab/calibre-web/blob/486b7bbcb5b5450c81850846f771f329d3dc238b/cps/constants.py#L51-L52