jenni / obooks

O'Books :books::sparkles: Download books from O'Reilly | Safaribooks
121 stars 20 forks source link

Handle O'Reilly 500 error while downloading chapters #21

Open jenni opened 3 years ago

jenni commented 3 years ago

Handle 500 error when downloading a chapter and O'Reilly goes unavailable.

claviola commented 1 year ago

I've stumbled upon a similar issue with an image that seems to not exist: (book ID is 9781492077206)


          ::::::::  ::: :::::::::   ::::::::   ::::::::  :::    ::: ::::::::
        :+:    :+: :+  :+:    :+: :+:    :+: :+:    :+: :+:   :+: :+:    :+:
       +:+    +:+     +:+    +:+ +:+    +:+ +:+    +:+ +:+  +:+  +:+
      +#+    +:+     +#++:++#+  +#+    +:+ +#+    +:+ +#++:++   +#++:++#++
     +#+    +#+     +#+    +#+ +#+    +#+ +#+    +#+ +#+  +#+         +#+
    #+#    #+#     #+#    #+# #+#    #+# #+#    #+# #+#   #+# #+#    #+#
    ########      #########   ########   ########  ###    ### ########

+:++:++:++:+      using stored cookies
+:++:++:++:+      downloading: Learning Go
+:++:++:++:+      22 chapters to download, this can take a while...
+:++:++:++:+      done downloading chapter: Praise for Learning Go
+:++:++:++:+      done downloading chapter: Learning Go
+:++:++:++:+      done downloading chapter: Learning Go
+:++:++:++:+      done downloading chapter: Preface
(node:1) UnhandledPromiseRejectionWarning: Error: Image loading error - 500. URL: https://learning.oreilly.com/library/view/learning-go/9781492077206/assets/lego_0103.png
    at Request._callback (/usr/app/node_modules/image-downloader/index.js:60:15)
    at Request.self.callback (/usr/app/node_modules/request/request.js:185:22)
    at Request.emit (events.js:314:20)
    at Request.<anonymous> (/usr/app/node_modules/request/request.js:1161:10)
    at Request.emit (events.js:314:20)
    at IncomingMessage.<anonymous> (/usr/app/node_modules/request/request.js:1083:12)
    at Object.onceWrapper (events.js:420:28)
    at IncomingMessage.emit (events.js:326:22)
    at endReadableNT (_stream_readable.js:1241:12)
    at processTicksAndRejections (internal/process/task_queues.js:84:21)
(node:1) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:1) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

(This is using the docker image.) is there a way to just ignore the error and continue?

MrMauricioLeite commented 4 months ago

Just got the exact same issue using the docker. Unsure if I'm doing something wrong or if I'm missing a flag that enables v2 api endpoint (merged in the past)


          ::::::::  ::: :::::::::   ::::::::   ::::::::  :::    ::: :::::::: 
        :+:    :+: :+  :+:    :+: :+:    :+: :+:    :+: :+:   :+: :+:    :+: 
       +:+    +:+     +:+    +:+ +:+    +:+ +:+    +:+ +:+  +:+  +:+         
      +#+    +:+     +#++:++#+  +#+    +:+ +#+    +:+ +#++:++   +#++:++#++   
     +#+    +#+     +#+    +#+ +#+    +#+ +#+    +#+ +#+  +#+         +#+    
    #+#    #+#     #+#    #+# #+#    #+# #+#    #+# #+#   #+# #+#    #+#     
    ########      #########   ########   ########  ###    ### ########       

+:++:++:++:+      using stored cookies
+:++:++:++:+      downloading: Essential Math for Data Science
+:++:++:++:+      17 chapters to download, this can take a while...
+:++:++:++:+      done downloading chapter: Praise for Essential Math for Data Science
+:++:++:++:+      done downloading chapter: Essential Math for Data Science
+:++:++:++:+      done downloading chapter: Essential Math for Data Science
+:++:++:++:+      done downloading chapter: Preface
(node:1) UnhandledPromiseRejectionWarning: Error: Image loading error - 500. URL: https://learning.oreilly.com/library/view/essential-math-for/9781098102920/assets/emds_0101.png
    at Request._callback (/usr/app/node_modules/image-downloader/index.js:60:15)
    at Request.self.callback (/usr/app/node_modules/request/request.js:185:22)
    at Request.emit (events.js:314:20)
    at Request.<anonymous> (/usr/app/node_modules/request/request.js:1161:10)
    at Request.emit (events.js:314:20)
    at IncomingMessage.<anonymous> (/usr/app/node_modules/request/request.js:1083:12)
    at Object.onceWrapper (events.js:420:28)
    at IncomingMessage.emit (events.js:326:22)
    at endReadableNT (_stream_readable.js:1241:12)
    at processTicksAndRejections (internal/process/task_queues.js:84:21)
(node:1) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:1) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Anything I'm missing here?