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

Fix failing commands by upgrading to latest Udacity API #230

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Alameen688
Copy link

@Alameen688 Alameen688 commented Aug 6, 2022

Description

udacimak CLI commands return a connection error during usage

Fixes # (issue)

In the current version, try to authenticate using:

udacimak login

OR

udacimak settoken

You should get an error similar to:

✖ Validate Udacity authentication token via Udacity API
2022-08-05T23:19:45.084Z [error]: Failed to validate your Udacity token. Please try again. Here's the error message:
{}
✖ Fetch user information via Udacity API
2022-08-05T23:19:45.091Z [error]: Failed to get Nanodegree list with error:
{}

See full details on how to use this fix - #230 (comment)

Type of change

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • Run the following commands below and you should be able to download and render nanodegree course offline
  • udacimak settoken
  • udacimak listnd
  • udacimak download
  • udacimak render PATH_TO_DOWNLOADED_COURSE_JSON_DIRECTORY --targetdir OPTIONAL_TARGET_DIRECTORY

Configurations

  • OS: macOS
  • Node version: v16.6.1
  • npm version: 7.20.3

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

@OmarShawky1
Copy link

OmarShawky1 commented Aug 29, 2022

If I may ask, how can i compile & install your branch? Unfortunately, couldn't find a build file.

These are my trials:
Trial 1:
$ npm install git+https://github.com/Alameen688/fix-udacimak

Output: (Failure)

$ npm install git+https://github.com/Alameen688/fix-udacimak
npm WARN old lockfile
npm WARN old lockfile The package-lock.json file was created with an old version of npm,
npm WARN old lockfile so supplemental metadata must be fetched from the registry.
npm WARN old lockfile
npm WARN old lockfile This is a one-time fix-up, please be patient...
npm WARN old lockfile
npm WARN deprecated [email protected]: this library is no longer supported
npm WARN deprecated [email protected]: node-youtube-dl is deprecated. use `npm.im/youtube-dl-exec` instead.
npm WARN deprecated [email protected]: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
npm WARN deprecated [email protected]: request has been deprecated, see https://github.com/request/request/issues/3142
npm ERR! code 1
npm ERR! git dep preparation failed
npm ERR! command /home/omar/.nvm/versions/node/v16.6.1/bin/node /home/omar/.nvm/versions/node/v16.6.1/lib/node_modules/npm/bin/npm-cli.js install --force --cache=/home/omar/.npm --prefer-offline=false --prefer-online=false --offline=false --no-progress --no-save --no-audit --include=dev --include=peer --include=optional --no-package-lock-only --no-dry-run
npm ERR! node:internal/modules/cjs/loader:936
npm ERR!   throw err;
npm ERR!   ^
npm ERR!
npm ERR! Error: Cannot find module '/home/omar/.nvm/versions/node/v16.6.1/lib/node_modules/npm/bin/npm-cli.js'
npm ERR!     at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
npm ERR!     at Function.Module._load (node:internal/modules/cjs/loader:778:27)
npm ERR!     at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:79:12)
npm ERR!     at node:internal/main/run_main_module:17:47 {
npm ERR!   code: 'MODULE_NOT_FOUND',
npm ERR!   requireStack: []
npm ERR! }

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/omar/.npm/_logs/2022-08-29T13_07_59_285Z-debug.log

Node & npm versions:

$ npm -v
7.20.3

$ node --version
v16.6.1

@ChristophBurger89
Copy link

@OmarShawky1 did you manage to get it running?

@OmarShawky1
Copy link

@OmarShawky1 did you manage to get it running?

No

@Alameen688
Copy link
Author

Alameen688 commented Aug 31, 2022

Sorry for late the reply @OmarShawky1. This is how I used it.
I am also using
Node version - v16.6.1
NPM version - 7.20.3

Remove previous global installation of udacimak

npm uninstall -g udacimak

Clone the repo https://github.com/Alameen688/fix-udacimak

git clone https://github.com/Alameen688/fix-udacimak

In the terminal, navigate to the fix-udacimak project

cd fix-udacimak

Install dependencies

 npm install

Build the project

 npm run build

Install the cli globally

npm i -g .

Use udacimak
You can now use udacimak in any terminal/command line anytime without having to run all the build steps above

udacimak settoken YOUR_BEARER_TOKEN

You can test that things are okay by listing your nanodegree courses

udacimak listnd

You should be able to download courses now.

@ChristophBurger89
Copy link

Sorry for late the reply @OmarShawky1. This is how I used it. I am also using Node version - v16.6.1 NPM version - 7.20.3

Remove previous global installation of udacimak

npm uninstall -g udacimak

Clone the repo https://github.com/Alameen688/fix-udacimak

git clone https://github.com/Alameen688/fix-udacimak

In the terminal, navigate to the fix-udacimak project

cd fix-udacimak

Install dependencies

 npm install

Build the project

 npm run build

Install the cli globally

npm i -g .

Use udacimak You can now use udacimak in any terminal/command line anytime without having to run all the build steps above

udacimak settoken YOUR_BEARER_TOKEN

You can test that things are okay by listing your nanodegree courses

udacimak listnd

You should be able to download courses now.

@Alameen688 awesome! Just tested it and it works fine. Thank you!

@Alameen688
Copy link
Author

Great @ChristophBurger89. Thanks for letting me know.

@OmarShawky1
Copy link

Sorry for late the reply @OmarShawky1. This is how I used it.
I am also using
Node version - v16.6.1
NPM version - 7.20.3

Remove previous global installation of udacimak

npm uninstall -g udacimak

Clone the repo https://github.com/Alameen688/fix-udacimak

git clone https://github.com/Alameen688/fix-udacimak

In the terminal, navigate to the fix-udacimak project

cd fix-udacimak

Install dependencies

 npm install

Build the project

 npm run build

Install the cli globally

npm i -g .

Use udacimak
You can now use udacimak in any terminal/command line anytime without having to run all the build steps above

udacimak settoken YOUR_BEARER_TOKEN

You can test that things are okay by listing your nanodegree courses

udacimak listnd

You should be able to download courses now.

Sorry for the unintentional late reply, I don't have access to a device in the meantime but I shall be soon and I'll test the pull request and let you know.

Thanks in advance for the effort.

@OmarShawky1
Copy link

OmarShawky1 commented Sep 5, 2022

Hello Again,

I installed the program with no issues; However, I wasn't able to set the token successful; This is the result of $ udacimak settoken udacity.com_cookies.txt:

(node:3083) [DEP0128] DeprecationWarning: Invalid 'main' field in '/home/omar/fix-udacimak/node_modules/user-settings/package.json' of 'dots.js'. Please either fix that or report it to the module author
(Use `node --trace-deprecation ...` to show where the warning was created)
⠴ Validate Udacity authentication token via Udacity API2022-09-05T18:07:04.241Z [error]: uncaughtException: Unexpected token A in JSON at position 0
SyntaxError: Unexpected token A in JSON at position 0
    at JSON.parse (<anonymous>)
    at Request._callback (/home/omar/fix-udacimak/lib/api/fetchApiUdacityGraphql.js:53:30)
    at Request.self.callback (/home/omar/fix-udacimak/node_modules/request/request.js:185:22)
    at Request.emit (node:events:394:28)
    at Request.<anonymous> (/home/omar/fix-udacimak/node_modules/request/request.js:1161:10)
    at Request.emit (node:events:394:28)
    at IncomingMessage.<anonymous> (/home/omar/fix-udacimak/node_modules/request/request.js:1083:12)
    at Object.onceWrapper (node:events:513:28)
    at IncomingMessage.emit (node:events:406:35)
    at endReadableNT (node:internal/streams/readable:1331:12)
2022-09-05T18:07:04.242Z [error]: Uncaught Exception:
SYNTAXERROR: Unexpected token A in JSON at position 0
STACK: SyntaxError: Unexpected token A in JSON at position 0
    at JSON.parse (<anonymous>)
    at Request._callback (/home/omar/fix-udacimak/lib/api/fetchApiUdacityGraphql.js:53:30)
    at Request.self.callback (/home/omar/fix-udacimak/node_modules/request/request.js:185:22)
    at Request.emit (node:events:394:28)
    at Request.<anonymous> (/home/omar/fix-udacimak/node_modules/request/request.js:1161:10)
    at Request.emit (node:events:394:28)
    at IncomingMessage.<anonymous> (/home/omar/fix-udacimak/node_modules/request/request.js:1083:12)
    at Object.onceWrapper (node:events:513:28)
    at IncomingMessage.emit (node:events:406:35)
    at endReadableNT (node:internal/streams/readable:1331:12)

PS: I used this google chrome extension to grab the cookies:

@OmarShawky1
Copy link

OmarShawky1 commented Sep 5, 2022

Sorry for late the reply @OmarShawky1. This is how I used it. I am also using Node version - v16.6.1 NPM version - 7.20.3
Remove previous global installation of udacimak

npm uninstall -g udacimak

Clone the repo https://github.com/Alameen688/fix-udacimak

git clone https://github.com/Alameen688/fix-udacimak

In the terminal, navigate to the fix-udacimak project

cd fix-udacimak

Install dependencies

 npm install

Build the project

 npm run build

Install the cli globally

npm i -g .

Use udacimak You can now use udacimak in any terminal/command line anytime without having to run all the build steps above

udacimak settoken YOUR_BEARER_TOKEN

You can test that things are okay by listing your nanodegree courses

udacimak listnd

You should be able to download courses now.

@Alameen688 awesome! Just tested it and it works fine. Thank you!

@ChristophBurger89 Where you able to authenticate?

@Alameen688
Copy link
Author

Hello Again,

I installed the program with no issues; However, I wasn't able to set the token successful; This is the result of $ udacimak settoken udacity.com_cookies.txt:

(node:3083) [DEP0128] DeprecationWarning: Invalid 'main' field in '/home/omar/fix-udacimak/node_modules/user-settings/package.json' of 'dots.js'. Please either fix that or report it to the module author
(Use `node --trace-deprecation ...` to show where the warning was created)
⠴ Validate Udacity authentication token via Udacity API2022-09-05T18:07:04.241Z [error]: uncaughtException: Unexpected token A in JSON at position 0
SyntaxError: Unexpected token A in JSON at position 0
    at JSON.parse (<anonymous>)
    at Request._callback (/home/omar/fix-udacimak/lib/api/fetchApiUdacityGraphql.js:53:30)
    at Request.self.callback (/home/omar/fix-udacimak/node_modules/request/request.js:185:22)
    at Request.emit (node:events:394:28)
    at Request.<anonymous> (/home/omar/fix-udacimak/node_modules/request/request.js:1161:10)
    at Request.emit (node:events:394:28)
    at IncomingMessage.<anonymous> (/home/omar/fix-udacimak/node_modules/request/request.js:1083:12)
    at Object.onceWrapper (node:events:513:28)
    at IncomingMessage.emit (node:events:406:35)
    at endReadableNT (node:internal/streams/readable:1331:12)
2022-09-05T18:07:04.242Z [error]: Uncaught Exception:
SYNTAXERROR: Unexpected token A in JSON at position 0
STACK: SyntaxError: Unexpected token A in JSON at position 0
    at JSON.parse (<anonymous>)
    at Request._callback (/home/omar/fix-udacimak/lib/api/fetchApiUdacityGraphql.js:53:30)
    at Request.self.callback (/home/omar/fix-udacimak/node_modules/request/request.js:185:22)
    at Request.emit (node:events:394:28)
    at Request.<anonymous> (/home/omar/fix-udacimak/node_modules/request/request.js:1161:10)
    at Request.emit (node:events:394:28)
    at IncomingMessage.<anonymous> (/home/omar/fix-udacimak/node_modules/request/request.js:1083:12)
    at Object.onceWrapper (node:events:513:28)
    at IncomingMessage.emit (node:events:406:35)
    at endReadableNT (node:internal/streams/readable:1331:12)

PS: I used this google chrome extension to grab the cookies:

@OmarShawky1 you would need to open the udacity.com_cookies.txt file and search for _jwt.
Copy the token, it's starts with something like: eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE2NjI3Njg2MTAsImlhdCI6MTY2MDE3NjYxMCwia2lkIjoiMTAwMCI
Make sure to copy the entire text value, I covered mine in the image for security reasons.
search _jwt

then use the value in the command line

udacimak settoken eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.......and_the_rest_of_the_token_value

@OmarShawky1
Copy link

OmarShawky1 commented Sep 8, 2022

Hello Again,
I installed the program with no issues; However, I wasn't able to set the token successful; This is the result of $ udacimak settoken udacity.com_cookies.txt:

(node:3083) [DEP0128] DeprecationWarning: Invalid 'main' field in '/home/omar/fix-udacimak/node_modules/user-settings/package.json' of 'dots.js'. Please either fix that or report it to the module author
(Use `node --trace-deprecation ...` to show where the warning was created)
⠴ Validate Udacity authentication token via Udacity API2022-09-05T18:07:04.241Z [error]: uncaughtException: Unexpected token A in JSON at position 0
SyntaxError: Unexpected token A in JSON at position 0
    at JSON.parse (<anonymous>)
    at Request._callback (/home/omar/fix-udacimak/lib/api/fetchApiUdacityGraphql.js:53:30)
    at Request.self.callback (/home/omar/fix-udacimak/node_modules/request/request.js:185:22)
    at Request.emit (node:events:394:28)
    at Request.<anonymous> (/home/omar/fix-udacimak/node_modules/request/request.js:1161:10)
    at Request.emit (node:events:394:28)
    at IncomingMessage.<anonymous> (/home/omar/fix-udacimak/node_modules/request/request.js:1083:12)
    at Object.onceWrapper (node:events:513:28)
    at IncomingMessage.emit (node:events:406:35)
    at endReadableNT (node:internal/streams/readable:1331:12)
2022-09-05T18:07:04.242Z [error]: Uncaught Exception:
SYNTAXERROR: Unexpected token A in JSON at position 0
STACK: SyntaxError: Unexpected token A in JSON at position 0
    at JSON.parse (<anonymous>)
    at Request._callback (/home/omar/fix-udacimak/lib/api/fetchApiUdacityGraphql.js:53:30)
    at Request.self.callback (/home/omar/fix-udacimak/node_modules/request/request.js:185:22)
    at Request.emit (node:events:394:28)
    at Request.<anonymous> (/home/omar/fix-udacimak/node_modules/request/request.js:1161:10)
    at Request.emit (node:events:394:28)
    at IncomingMessage.<anonymous> (/home/omar/fix-udacimak/node_modules/request/request.js:1083:12)
    at Object.onceWrapper (node:events:513:28)
    at IncomingMessage.emit (node:events:406:35)
    at endReadableNT (node:internal/streams/readable:1331:12)

PS: I used this google chrome extension to grab the cookies:

@OmarShawky1 you would need to open the udacity.com_cookies.txt file and search for _jwt. Copy the token, it's starts with something like: eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE2NjI3Njg2MTAsImlhdCI6MTY2MDE3NjYxMCwia2lkIjoiMTAwMCI Make sure to copy the entire text value, I covered mine in the image for security reasons. search _jwt

then use the value in the command line

udacimak settoken eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.......and_the_rest_of_the_token_value

Hello Back @Alameen688 ; Again sorry for the delayed reply. I have tested it and it is working perfectly. Thanks to your incredible help, support and patience.

Please, Have a nice day :)

@Alameen688
Copy link
Author

No worries at all @OmarShawky1, we all have other things to do.

Happy to know it works. Thanks for letting me know.

@OmarShawky1
Copy link

A tip for the future people; Use yt-dlp instead of youtube-dl as it is quite faster (at least 100x)

$pip3 install -U yt-dlp && ln -s "$(which yt-dlp)" ~/.nvm/versions/node/v16.6.1/lib/node_modules/udacimak/node_modules/youtube-dl/bin/youtube-dl

@zhanwenchen
Copy link

Thank you! Your fix (https://github.com/Alameen688/fix-udacimak) totally worked for me!

@Ex-Communicad0
Copy link

Ex-Communicad0 commented Oct 29, 2022

@Alameen688 Bro can you please help changing the video resolution option

i tried downloadYoutube.js & other methods didn't work it downloading with quality 22 which is 720 but want to download 137+140 format which will be 1080p video + good audio m4a merge

how can i implement this to work properly? can you help me in this :-(

More info >> #122 (comment)

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

Successfully merging this pull request may close these issues.

None yet

5 participants