Skip to content

Conversation

deldesir
Copy link
Collaborator

@deldesir deldesir commented Jan 14, 2024

🚀 Pull Request Overview:

This pull request brings following enhancements:

  • Improved error handling with detailed error messages, including HTTP status codes and reasons, in case of download failures.
  • Set appropriate progress and messages when the download process encounters errors.

These updates aim to provide users with clearer information about download failures.

📋 Checklist:

🔗 Related Issues: #89

Some testing steps (thanks @EMG70):

  • Ensure that the script is running in an environment with internet access.
  • Initiate a download task with a valid YouTube or Vimeo URL
  • Confirm that the download progresses successfully.
  • Verify that the completion message reflects the successful download.
  • Check the Task column (in Tasks view) for success or error messages. Also, check the logs for the message "Successfully downloaded" or an error if any.

@deldesir deldesir added the enhancement New feature or request label Jan 14, 2024
@deldesir deldesir requested a review from holta January 14, 2024 20:35
@deldesir deldesir self-assigned this Jan 14, 2024
@deldesir deldesir changed the title Improve error handling Improve error handling for failed downloads Jan 14, 2024
@deldesir deldesir marked this pull request as draft January 14, 2024 20:36
@holta
Copy link
Member

holta commented Jan 14, 2024

Tangentially related:

@EMG70
Copy link

EMG70 commented Jan 15, 2024

New VM created in last 30mins.
iiab-diagnostics http://sprunge.us/1ZZzoZ?en

I have downloaded few videos and some that have failed in the past ,the ones that downloaded successfully showed progress for every video in the playlist.
A new message "almost done " now appears as playlist/video is being downloaded .
The failed downloads have error messages clearly explained in Adminstartion/viewlogs
https://www.youtube.com/playlist?list=PLg2tfDG3Ww4vsiMrgcS-wiU9boyII0z4A--- success
https://www.youtube.com/playlist?list=PLg2tfDG3Ww4t14_tIrNuqyJlAGmRn5KHu ---- success
https://www.youtube.com/watch?v=1RQVkzbU2jo&list=PLg2tfDG3Ww4uBdOZ-j-znfOarR7TKGs-w -----still fails but showing reasons for failure ok in viewlogs
https://vimeo.com/channels/staffpicks/893773360 ---Actual air vimeo staff picks still fails -reasons for failure showing in viewlogs

Overall very good progress ,implementers can see reasons for failure.
Screenshot from 2024-01-15 00-54-50
Screenshot from 2024-01-15 00-54-44
Screenshot from 2024-01-15 00-54-32
Screenshot from 2024-01-15 00-36-07
Screenshot from 2024-01-15 00-32-52
Screenshot from 2024-01-15 00-32-27

@holta
Copy link
Member

holta commented Jan 15, 2024

@holta
Copy link
Member

holta commented Jan 15, 2024

@deldesir the 100 last lines of /var/log/xklb.log appear to be counterproductive here — certainly not helping anybody in this example:

https://sprunge.us/1ZZzoZ?en#n-1261

QUESTIONS:

  • How do we eliminate this pollution?
  • If absolutely necessary, does iiab-diagnostics need to grep through xklb.log — so meaningful debugging hints are highlighted — and/or spammy pollution explicitly removed?

@holta
Copy link
Member

holta commented Jan 15, 2024

100 last lines of /var/log/xklb.log

@deldesir I'm not talking about irqbalance. You're looking at Lines 1550-1649 which are off-topic.

I'm talking about the "100 last lines of /var/log/xklb.log" on Lines 1264-1363 here. See the direct link I provided earlier:

https://sprunge.us/1ZZzoZ?en#n-1261

@holta
Copy link
Member

holta commented Jan 15, 2024

I see, ffmpeg output captured when using lb dl with -vv option. I agree it's verbose.

  • Should grep -v remove specific spammy patterns from xklb.log to make it much more concise?

  • Which patterns if so?

(iiab-diagnostics' approximately 100 commands each transmit a very limited number of lines!)

@deldesir
Copy link
Collaborator Author

  • Should grep -v remove specific spammy patterns from xklb.log to make it much more concise?

Let's start by removing ffmpeg ones

  • Which patterns if so?

All lines that contain ffmpeg

@holta
Copy link
Member

holta commented Jan 15, 2024

Let's start by removing ffmpeg ones

It's an idea. Something like that definitely might be necessary in future.

But just for now, iiab-diagnostics will now collect the last 300 lines of /var/log/xklb.log towards helping us to understand the patterns first:

@holta
Copy link
Member

holta commented Jan 15, 2024

@EMG70 this PR #95 is now merged: can you confirm below?

Some testing steps (thanks @EMG70):

  • Ensure that the script is running in an environment with internet access.
  • Initiate a download task with a valid YouTube or Vimeo URL
  • Confirm that the download progresses successfully.
  • Verify that the completion message reflects the successful download.
  • Check the Task column (in Tasks view) for success or error messages. Also, check the logs for the message "Successfully downloaded" or an error if any.

@EMG70
Copy link

EMG70 commented Jan 16, 2024

PR #95 Test as per newly added instructions to Calibre-web wiki
iiab-diagnostics
http://sprunge.us/5bxTq5?en
Ensure that the script is running in an environment with internet access. ✅
Initiate a download task with a valid YouTube or Vimeo URL ✅
Confirm that the download progresses successfully.✅
Verify that the completion message reflects the successful download.✅

Check the Task column (in Tasks view) for success or error messages. Also, check the logs for the message "Successfully downloaded" or an error if any.✅
This video https://www.youtube.com/watch?v=QXQrvT23rPw still shows 500 internal server error ,status failed although it successfully downloaded.It does not have a thumbnail (Picture not available)
Screenshot from 2024-01-16 15-02-47
Screenshot from 2024-01-16 15-12-37
Screenshot from 2024-01-16 15-00-15

@EMG70
Copy link

EMG70 commented Jan 16, 2024

Log error for failed status 👍

[2024-01-16 15:02:08,974] DEBUG {cps.services.worker:91} Add Task for user: Admin - Download task for https://www.youtube.com/watch?v=QXQrvT23rPw
[2024-01-16 15:02:09,221]  INFO {cps.tasks.download:29} Starting download task for URL: https://www.youtube.com/watch?v=QXQrvT23rPw
[2024-01-16 15:02:09,221]  INFO {cps.tasks.download:38} Subprocess args: ['lb-wrapper', 'https://www.youtube.com/watch?v=QXQrvT23rPw']
[2024-01-16 15:02:28,276]  INFO {cps.editbooks:384} Requested files list: ['/library/downloads/calibre-web/Youtube/Leaf_of_Life/How_the_Sahara_Desert_is_Turning_into_a_Farmland_Oasis_-_GREENING_THE_DESERT_PROJECT_5.81M_[QXQrvT23rPw].mp4', 'https://www.youtube.com/watch?v=QXQrvT23rPw']
[2024-01-16 15:02:28,276]  INFO {cps.editbooks:390} Processing file: <_io.BufferedReader name='/library/downloads/calibre-web/Youtube/Leaf_of_Life/How_the_Sahara_Desert_is_Turning_into_a_Farmland_Oasis_-_GREENING_THE_DESERT_PROJECT_5.81M_[QXQrvT23rPw].mp4'>
[2024-01-16 15:02:28,276] DEBUG {cps.uploader:371} Temporary file: /tmp/calibre_web/2ecb7c6140e4252738fc807bb1a8aca8
[2024-01-16 15:02:28,279]  WARN {cps.uploader:98} cannot parse metadata, using default: list index out of range
[2024-01-16 15:02:28,286] DEBUG {cps.helper:543} Moving title: /tmp/calibre_web/2ecb7c6140e4252738fc807bb1a8aca8 to /library/calibre-web/Unknown/How_the_Sahara_Desert_is_Turning_into_a_Farmland_Oasis_-_GREENING_THE_DESERT_PROJECT_5.81M_[QXQr (17)/How_the_Sahara_Desert_is_Turning_into_a_Farmland_Oasis_-_GREENING_THE_DESERT_PROJECT_5.81M_[QXQr - Unknown
[2024-01-16 15:02:28,299] DEBUG {cps.services.worker:91} Add Task for user: Admin - Upload How_the_Sahara_Desert_is_Turning_into_a_Farmland_Oasis_-_GREENING_THE_DESERT_PROJECT_5.81M_[QXQrvT23rPw]
[2024-01-16 15:02:28,299] ERROR {cps:1414} Exception on /meta [GET]
Traceback (most recent call last):
  File "/usr/local/calibre-web-py3/lib/python3.11/site-packages/flask/app.py", line 2190, in wsgi_app
    response = self.full_dispatch_request()
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/calibre-web-py3/lib/python3.11/site-packages/flask/app.py", line 1486, in full_dispatch_request
    rv = self.handle_user_exception(e)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/calibre-web-py3/lib/python3.11/site-packages/flask/app.py", line 1484, in full_dispatch_request
    rv = self.dispatch_request()
         ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/calibre-web-py3/lib/python3.11/site-packages/flask/app.py", line 1469, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/calibre-web-py3/cps/editbooks.py", line 473, in meta
    if move_mediafile(requested_files, current_user_name, shelf_title):
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/calibre-web-py3/cps/editbooks.py", line 386, in move_mediafile
    requested_file = open(requested_file, "rb")
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: 'https://www.youtube.com/watch?v=QXQrvT23rPw'
[2024-01-16 15:02:28,312] ERROR {cps.tasks.download:89} Failed to send the list of requested files to http://192.168.0.15/books/meta
[2024-01-16 15:17:44,575] DEBUG {cps.services.worker:91} Add Task for user: Admin - Download task for https://www.youtube.com/watch?v=QXQrvT23rPw
[2024-01-16 15:17:44,576]  INFO {cps.tasks.download:29} Starting download task for URL: https://www.youtube.com/watch?v=QXQrvT23rPw
[2024-01-16 15:17:44,576]  INFO {cps.tasks.download:38} Subprocess args: ['lb-wrapper', 'https://www.youtube.com/watch?v=QXQrvT23rPw']
[2024-01-16 15:18:02,310]  INFO {cps.editbooks:384} Requested files list: ['/library/downloads/calibre-web/Youtube/Leaf_of_Life/How_the_Sahara_Desert_is_Turning_into_a_Farmland_Oasis_-_GREENING_THE_DESERT_PROJECT_5.81M_[QXQrvT23rPw].mp4', 'https://www.youtube.com/watch?v=QXQrvT23rPw']
[2024-01-16 15:18:02,311]  INFO {cps.editbooks:390} Processing file: <_io.BufferedReader name='/library/downloads/calibre-web/Youtube/Leaf_of_Life/How_the_Sahara_Desert_is_Turning_into_a_Farmland_Oasis_-_GREENING_THE_DESERT_PROJECT_5.81M_[QXQrvT23rPw].mp4'>
[2024-01-16 15:18:02,311] DEBUG {cps.uploader:371} Temporary file: /tmp/calibre_web/2ecb7c6140e4252738fc807bb1a8aca8
[2024-01-16 15:18:02,313]  WARN {cps.uploader:98} cannot parse metadata, using default: list index out of range
[2024-01-16 15:18:02,319] DEBUG {cps.helper:543} Moving title: /tmp/calibre_web/2ecb7c6140e4252738fc807bb1a8aca8 to /library/calibre-web/Unknown/How_the_Sahara_Desert_is_Turning_into_a_Farmland_Oasis_-_GREENING_THE_DESERT_PROJECT_5.81M_[QXQr (18)/How_the_Sahara_Desert_is_Turning_into_a_Farmland_Oasis_-_GREENING_THE_DESERT_PROJECT_5.81M_[QXQr - Unknown
[2024-01-16 15:18:02,329] DEBUG {cps.services.worker:91} Add Task for user: Admin - Upload How_the_Sahara_Desert_is_Turning_into_a_Farmland_Oasis_-_GREENING_THE_DESERT_PROJECT_5.81M_[QXQrvT23rPw]
[2024-01-16 15:18:02,330] ERROR {cps:1414} Exception on /meta [GET]
Traceback (most recent call last):
  File "/usr/local/calibre-web-py3/lib/python3.11/site-packages/flask/app.py", line 2190, in wsgi_app
    response = self.full_dispatch_request()
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/calibre-web-py3/lib/python3.11/site-packages/flask/app.py", line 1486, in full_dispatch_request
    rv = self.handle_user_exception(e)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/calibre-web-py3/lib/python3.11/site-packages/flask/app.py", line 1484, in full_dispatch_request
    rv = self.dispatch_request()
         ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/calibre-web-py3/lib/python3.11/site-packages/flask/app.py", line 1469, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/calibre-web-py3/cps/editbooks.py", line 473, in meta
    if move_mediafile(requested_files, current_user_name, shelf_title):
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/calibre-web-py3/cps/editbooks.py", line 386, in move_mediafile
    requested_file = open(requested_file, "rb")
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: 'https://www.youtube.com/watch?v=QXQrvT23rPw'
[2024-01-16 15:18:02,333] ERROR {cps.tasks.download:89} Failed to send the list of requested files to http://192.168.0.15/books/meta
[2024-01-16 15:20:28,771] DEBUG {cps.updater:329} Stable version: {'version': '0.6.22 Beta'}

@EMG70
Copy link

EMG70 commented Jan 16, 2024

Screenshot from 2024-01-16 15-35-37

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.

3 participants