Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trying to make this work, but I'm not understanding what I'm doing wrong #27

Open
digitalrorschach opened this issue Apr 12, 2021 · 7 comments

Comments

@digitalrorschach
Copy link

digitalrorschach commented Apr 12, 2021

I installed Node.JS and it's dependencies
I ran npm install

I'm trying to download a book using the CLI method, but I keep getting StatusCodeError: 404 - {"error":"Could not fetch work"}
Here is the command I ran: node cli.js -b "<9781491952016>" -c "<uhn7fxvjku8442ejdljcnn2kcueke3df>"

Here is the full output. I don't know JavaScript, so maybe this is something super simple to solve?

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














+:++:++:++:+      using stored cookies
StatusCodeError: 404 - {"error":"Could not fetch work"}
    at new StatusCodeError (D:\dev\obooks\node_modules\request-promise-core\lib\errors.js:32:15)
    at Request.plumbing.callback (D:\dev\obooks\node_modules\request-promise-core\lib\plumbing.js:104:33)
    at Request.RP$callback [as _callback] (D:\dev\obooks\node_modules\request-promise-core\lib\plumbing.js:46:31)
    at Request.self.callback (D:\dev\obooks\node_modules\request\request.js:185:22)
    at Request.emit (events.js:315:20)
    at Request.<anonymous> (D:\dev\obooks\node_modules\request\request.js:1161:10)
    at Request.emit (events.js:315:20)
    at IncomingMessage.<anonymous> (D:\dev\obooks\node_modules\request\request.js:1083:12)
    at Object.onceWrapper (events.js:421:28)
    at IncomingMessage.emit (events.js:327:22)
    at endReadableNT (internal/streams/readable.js:1327:12)
    at processTicksAndRejections (internal/process/task_queues.js:80:21) {
  statusCode: 404,
  error: { error: 'Could not fetch work' },
  options: {
    uri: 'https://learning.oreilly.com/api/v1/book/<9781491952016>',
    method: 'GET',
    followAllRedirects: true,
    resolveWithFullResponse: true,
    headers: {
      Accept: '*/*',
      'Cache-Control': 'no-cache',
      Cookie: '<uhn7oxvj9u8444ejdlj8nn2kcueke3cf>',
      Connection: 'keep-alive'
    },
    body: null,
    json: true,
    callback: [Function: RP$callback],
    transform: undefined,
    simple: true,
    transform2xxOnly: false
  },
  response: <ref *1> IncomingMessage {
    _readableState: ReadableState {
      objectMode: false,
      highWaterMark: 16384,
      buffer: BufferList { head: null, tail: null, length: 0 },
      length: 0,
      pipes: [],
      flowing: true,
      ended: true,
      endEmitted: true,
      reading: false,
      sync: false,
      needReadable: false,
      emittedReadable: false,
      readableListening: false,
      resumeScheduled: false,
      errorEmitted: false,
      emitClose: true,
      autoDestroy: false,
      destroyed: true,
      errored: null,
      closed: false,
      closeEmitted: false,
      defaultEncoding: 'utf8',
      awaitDrainWriters: null,
      multiAwaitDrain: false,
      readingMore: false,
      decoder: null,
      encoding: null,
      [Symbol(kPaused)]: false
    },
    _events: [Object: null prototype] {
      end: [Array],
      close: [Array],
      data: [Function (anonymous)],
      error: [Function (anonymous)]
    },
    _eventsCount: 4,
    _maxListeners: undefined,
    socket: null,
    httpVersionMajor: 1,
    httpVersionMinor: 1,
    httpVersion: '1.1',
    complete: true,
    headers: {
      connection: 'keep-alive',
      'content-length': '32',
      server: 'istio-envoy',
      'content-type': 'application/json',
      'strict-transport-security': 'max-age=31536000; includeSubDomains',
      'x-envoy-upstream-service-time': '98',
      etag: 'W/"20-VP1zPcsrMiwJerbVIDyOLy0If+4"',
      'x-content-type-options': 'nosniff',
      'x-powered-by': 'Express',
      'accept-ranges': 'bytes',
      date: 'Mon, 12 Apr 2021 18:04:08 GMT',
      via: '1.1 varnish',
      'x-client-ip': '45.19.192.15',
      'x-served-by': 'cache-dal21221-DAL',
      'x-cache': 'MISS',
      'x-cache-hits': '0',
      'x-timer': 'S1618250648.303722,VS0,VE359',
      vary: 'Accept, Accept-Encoding, Authorization, Cookie'
    },
    rawHeaders: [
      'Connection',
      'keep-alive',
      'Content-Length',
      '32',
      'server',
      'istio-envoy',
      'content-type',
      'application/json',
      'strict-transport-security',
      'max-age=31536000; includeSubDomains',
      'x-envoy-upstream-service-time',
      '98',
      'etag',
      'W/"20-VP1zPcsrMiwJerbVIDyOLy0If+4"',
      'x-content-type-options',
      'nosniff',
      'x-powered-by',
      'Express',
      'Accept-Ranges',
      'bytes',
      'Date',
      'Mon, 12 Apr 2021 18:04:08 GMT',
      'Via',
      '1.1 varnish',
      'X-Client-IP',
      '45.19.192.15',
      'X-Served-By',
      'cache-dal21221-DAL',
      'X-Cache',
      'MISS',
      'X-Cache-Hits',
      '0',
      'X-Timer',
      'S1618250648.303722,VS0,VE359',
      'Vary',
      'Accept, Accept-Encoding, Authorization, Cookie'
    ],
    trailers: {},
    rawTrailers: [],
    aborted: false,
    upgrade: false,
    url: '',
    method: null,
    statusCode: 404,
    statusMessage: 'Not Found',
    client: TLSSocket {
      _tlsOptions: [Object],
      _secureEstablished: true,
      _securePending: false,
      _newSessionPending: false,
      _controlReleased: true,
      secureConnecting: false,
      _SNICallback: null,
      servername: 'learning.oreilly.com',
      alpnProtocol: false,
      authorized: true,
      authorizationError: null,
      encrypted: true,
      _events: [Object: null prototype],
      _eventsCount: 8,
      connecting: false,
      _hadError: false,
      _parent: null,
      _host: 'learning.oreilly.com',
      _readableState: [ReadableState],
      _maxListeners: undefined,
      _writableState: [WritableState],
      allowHalfOpen: false,
      _sockname: null,
      _pendingData: null,
      _pendingEncoding: '',
      server: undefined,
      _server: null,
      ssl: null,
      _requestCert: true,
      _rejectUnauthorized: true,
      parser: null,
      _httpMessage: [ClientRequest],
      [Symbol(res)]: [TLSWrap],
      [Symbol(verified)]: true,
      [Symbol(pendingSession)]: null,
      [Symbol(async_id_symbol)]: 10,
      [Symbol(kHandle)]: null,
      [Symbol(kSetNoDelay)]: false,
      [Symbol(lastWriteQueueSize)]: 0,
      [Symbol(timeout)]: null,
      [Symbol(kBuffer)]: null,
      [Symbol(kBufferCb)]: null,
      [Symbol(kBufferGen)]: null,
      [Symbol(kCapture)]: false,
      [Symbol(kBytesRead)]: 614,
      [Symbol(kBytesWritten)]: 238,
      [Symbol(connect-options)]: [Object],
      [Symbol(RequestTimeout)]: undefined
    },
    _consuming: true,
    _dumped: false,
    req: ClientRequest {
      _events: [Object: null prototype],
      _eventsCount: 5,
      _maxListeners: undefined,
      outputData: [],
      outputSize: 0,
      writable: true,
      destroyed: true,
      _last: true,
      chunkedEncoding: false,
      shouldKeepAlive: true,
      _defaultKeepAlive: true,
      useChunkedEncodingByDefault: false,
      sendDate: false,
      _removedConnection: false,
      _removedContLen: false,
      _removedTE: false,
      _contentLength: null,
      _hasBody: true,
      _trailer: '',
      finished: true,
      _headerSent: true,
      socket: [TLSSocket],
      _header: 'GET /api/v1/book/%3C9781491952016%3E HTTP/1.1\r\n' +
        'Accept: */*\r\n' +
        'Cache-Control: no-cache\r\n' +
        'Cookie: <uhn7oxvj9u8444ejdlj8nn2kcueke3cf>\r\n' +
        'Connection: keep-alive\r\n' +
        'host: learning.oreilly.com\r\n' +
        'content-type: application/json\r\n' +
        'content-length: 4\r\n' +
        '\r\n',
      _keepAliveTimeout: 0,
      _onPendingData: [Function: noopPendingOutput],
      agent: [Agent],
      socketPath: undefined,
      method: 'GET',
      maxHeaderSize: undefined,
      insecureHTTPParser: undefined,
      path: '/api/v1/book/%3C9781491952016%3E',
      _ended: true,
      res: [Circular *1],
      aborted: false,
      timeoutCb: null,
      upgradeOrConnect: false,
      parser: null,
      maxHeadersCount: null,
      reusedSocket: false,
      host: 'learning.oreilly.com',
      protocol: 'https:',
      [Symbol(kCapture)]: false,
      [Symbol(kNeedDrain)]: false,
      [Symbol(corked)]: 0,
      [Symbol(kOutHeaders)]: [Object: null prototype]
    },
    request: Request {
      _events: [Object: null prototype],
      _eventsCount: 5,
      _maxListeners: undefined,
      uri: [Url],
      method: 'GET',
      followAllRedirects: true,
      resolveWithFullResponse: true,
      headers: [Object],
      body: 'null',
      readable: true,
      writable: true,
      explicitMethod: true,
      _qs: [Querystring],
      _auth: [Auth],
      _oauth: [OAuth],
      _multipart: [Multipart],
      _redirect: [Redirect],
      _tunnel: [Tunnel],
      _rp_resolve: [Function (anonymous)],
      _rp_reject: [Function (anonymous)],
      _rp_promise: [Promise [Object]],
      _rp_callbackOrig: undefined,
      callback: [Function (anonymous)],
      _rp_options: [Object],
      setHeader: [Function (anonymous)],
      hasHeader: [Function (anonymous)],
      getHeader: [Function (anonymous)],
      removeHeader: [Function (anonymous)],
      localAddress: undefined,
      pool: {},
      dests: [],
      __isRequestRequest: true,
      _callback: [Function: RP$callback],
      proxy: null,
      tunnel: true,
      setHost: true,
      originalCookieHeader: '<uhn7oxvj9u8444ejdlj8nn2kcueke3cf>',
      _disableCookies: true,
      _jar: undefined,
      port: 443,
      host: 'learning.oreilly.com',
      path: '/api/v1/book/%3C9781491952016%3E',
      _json: true,
      httpModule: [Object],
      agentClass: [Function: Agent],
      agent: [Agent],
      _started: true,
      href: 'https://learning.oreilly.com/api/v1/book/%3C9781491952016%3E',
      req: [ClientRequest],
      ntick: true,
      response: [Circular *1],
      originalHost: 'learning.oreilly.com',
      originalHostHeaderName: 'host',
      responseContent: [Circular *1],
      _destdata: true,
      _ended: true,
      _callbackCalled: true,
      [Symbol(kCapture)]: false
    },
    toJSON: [Function: responseToJSON],
    caseless: Caseless { dict: [Object] },
    body: { error: 'Could not fetch work' },
    [Symbol(kCapture)]: false,
    [Symbol(RequestTimeout)]: undefined
  }
}
@jenni
Copy link
Owner

jenni commented Apr 13, 2021

@digitalrorschach
the values in the cli command need to go without the < and > characters, in your example it'd be:

./cli.js -b "9781491952016" -c "uhn7fxvjku8442ejdljcnn2kcueke3df"

before running that command, you have to remove the session.json if it was created before

@digitalrorschach
Copy link
Author

ok so I ran the command

node ./cli.js -b "9781491952016" -c "uhn7fxvjku8442ejdljcnn2kcueke3df"

and got this result:
` :::::::: ::: ::::::::: :::::::: :::::::: ::: ::: ::::::::
:+: :+: :+ :+: :+: :+: :+: :+: :+: :+: :+: :+: :+:
+:+ +:+ +:+ +:+ +:+ +:+ +:+ +:+ +:+ +:+ +:+
+#+ +:+ +#++:++#+ +#+ +:+ +#+ +:+ +#++:++ +#++:++#++
+#+ +#+ +#+ +#+ +#+ +#+ +#+ +#+ +#+ +#+ +#+
#+# #+# #+# #+# #+# #+# #+# #+# #+# #+# #+# #+#
######## ######### ######## ######## ### ### ########

+:++:++:++:+ using stored cookies`

And it just just stays stuck on this screen... I left it running overnight to see if it's just process something, but it's still stuck on this screen...

@jenni
Copy link
Owner

jenni commented Aug 29, 2021

@digitalrorschach is this solved?

@digitalrorschach
Copy link
Author

@jenni No I'm still having problems. I come by to check each month. I updated Obooks and I entered this command at CLI:

node ./cli.js -b "9781138828421" -c "n63x1sl65xb4k30hhiuim91v09iu4msh"

And I get this in return

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














+:++:++:++:+      using stored cookies
+:++:++:++:+      downloading: The Indie Game Developer Handbook
+:++:++:++:+      15 chapters to download, please wait...
(node:11532) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'map' of undefined
    at OBook.create (D:\dev\obooks\lib\OBook.js:42:45)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:11532) 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:11532) [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.
RequestError: Error: connect ETIMEDOUT 151.101.49.132:443
    at new RequestError (D:\dev\obooks\node_modules\request-promise-core\lib\errors.js:14:15)
    at Request.plumbing.callback (D:\dev\obooks\node_modules\request-promise-core\lib\plumbing.js:87:29)
    at Request.RP$callback [as _callback] (D:\dev\obooks\node_modules\request-promise-core\lib\plumbing.js:46:31)
    at self.callback (D:\dev\obooks\node_modules\request\request.js:185:22)
    at Request.emit (events.js:315:20)
    at Request.onRequestError (D:\dev\obooks\node_modules\request\request.js:881:8)
    at ClientRequest.emit (events.js:315:20)
    at TLSSocket.socketErrorListener (_http_client.js:469:9)
    at TLSSocket.emit (events.js:315:20)
    at emitErrorNT (internal/streams/destroy.js:106:8)
    at emitErrorCloseNT (internal/streams/destroy.js:74:3)
    at processTicksAndRejections (internal/process/task_queues.js:80:21) {
  cause: Error: connect ETIMEDOUT 151.101.49.132:443
      at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1146:16) {
    errno: -4039,
    code: 'ETIMEDOUT',
    syscall: 'connect',
    address: '151.101.49.132',
    port: 443
  },
  error: Error: connect ETIMEDOUT 151.101.49.132:443
      at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1146:16) {
    errno: -4039,
    code: 'ETIMEDOUT',
    syscall: 'connect',
    address: '151.101.49.132',
    port: 443
  },
  options: {
    uri: 'https://learning.oreilly.com/api/v1/book/9781138828421/chapter/xhtml/Ch03.xhtml',
    method: 'GET',
    followAllRedirects: true,
    resolveWithFullResponse: true,
    headers: {
      Accept: '*/*',
      'Cache-Control': 'no-cache',
      Cookie: 'n63x1sl56xb4k60hhiuim67v09iu4msh',
      Connection: 'keep-alive'
    },
    body: null,
    json: true,
    callback: [Function: RP$callback],
    transform: undefined,
    simple: true,
    transform2xxOnly: false
  },
  response: undefined

@jenni
Copy link
Owner

jenni commented Oct 12, 2021

@digitalrorschach please pull the latest changes and try downloading the book again... it has worked on my end. also make sure that your subscription to O'Reilly is active at the moment of downloading the book.

@digitalrorschach
Copy link
Author

@jenni Ok I will pull and try to download again

@digitalrorschach
Copy link
Author

@jenni I pulled the latest changes today and varified my subscription and I get error

Error: Cannot find module 'commander'
Require stack:
- D:\dev\obooks\cli.js
�[90m    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15)�[39m
�[90m    at Function.Module._load (internal/modules/cjs/loader.js:725:27)�[39m
�[90m    at Module.require (internal/modules/cjs/loader.js:952:19)�[39m
�[90m    at require (internal/modules/cjs/helpers.js:88:18)�[39m
    at Object.<anonymous> (D:\dev\obooks\cli.js:3:17)
�[90m    at Module._compile (internal/modules/cjs/loader.js:1063:30)�[39m
�[90m    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)�[39m
�[90m    at Module.load (internal/modules/cjs/loader.js:928:32)�[39m
�[90m    at Function.Module._load (internal/modules/cjs/loader.js:769:14)�[39m
�[90m    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)�[39m {
  code: �[32m'MODULE_NOT_FOUND'�[39m,
  requireStack: [ �[32m'D:\\dev\\obooks\\cli.js'�[39m ]
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants