markbrown4 / egghead-downloader

downloads egghead
83 stars 14 forks source link

program stops after downloading a few files #10

Open picaron opened 6 years ago

picaron commented 6 years ago

I'm getting this error:

events.js:180
    throw new errors.TypeError('ERR_INVALID_ARG_TYPE', 'listener', 'Function');
    ^

TypeError [ERR_INVALID_ARG_TYPE]: The "listener" argument must be of type Function
    at _addListener (events.js:180:11)
    at WriteStream.addListener (events.js:240:10)
    at WriteStream.close (fs.js:2302:10)
    at WriteStream.<anonymous> (/Users/pascal.chouinard/Dropbox/Videos/Egghead/egghead-downloader/src/download.coffee:78:14)
    at WriteStream.emit (events.js:164:20)
    at finishMaybe (_stream_writable.js:605:14)
    at afterWrite (_stream_writable.js:456:3)
    at onwrite (_stream_writable.js:446:7)
    at fs.js:2246:5
    at FSReqWrap.wrapper [as oncomplete] (fs.js:703:5)

@markbrown4 what version of node did you test with?

markbrown4 commented 6 years ago

Hey,

I've just tried the following with Node v8.9.0 and it seems happy. npm run download https://egghead.io/courses/optimistic-ui-updates-in-react

Which video series did you try and download?

BeKnowDo commented 6 years ago

doesn't work for me either

corysimmons commented 6 years ago

npm run download https://egghead.io/courses/up-and-running-with-redux-observable just creates an empty nested directory. Node 8.10 (I did have to update some pkgs in package.json because npm audit was crying, and I had to manually npm i request or it threw an error telling me to do so..)

your series fails too:

Fetching: https://egghead.io/courses/optimistic-ui-updates-in-react

Writing: videos/optimistic-ui-updates-in-react

All Done 🎉
hrisng commented 6 years ago

Run into the same issue as @corysimmons @markbrown4

There are two problems:

  1. request now has to be installed seperately and required explicitly in the download module. I also had to use request-promise or else it will not return the html reponse, but a Request Object, which will lead to html.includes in not a function (Edit: didn't see that you set the global request in the program file, still, doing as above somehow solve that problem)
  2. Egghead.io page for course is no longer fully server side rendered. So we can't get the lessons link. I suggest parsing the json from api instead, https://egghead.io/api/v1/series/use-types-effectively-in-typescript/lessons

Wanting to save time, so I came upon this repo. Though I'm writing my own solution now, I hope this info can be useful for you.

markbrown4 commented 6 years ago

Thanks @harrisnguyen94, you're on the right track with the missing links in the HTML response now.

If you're able to modify the script to hit the API a PR would be welcome :)

corysimmons commented 6 years ago

@harrisnguyen94 Can you open-source/gist your solution when you get something that works pretty well. It seems they update the site as fast as we can make downloader scripts. 😅

markbrown4 commented 6 years ago

@corysimmons PR's are welcome from you too 😄

hrisng commented 6 years ago

CORS, I was trigger-happy. Though I will see if I can find another way tomorrow, as I really need this. Definitely will create a PR if I can make it works.

hrisng commented 6 years ago

~A hint is that this url is still fully server side rendered https://egghead.io/lessons, and we can successfully get the link from it.~ Nevermind, it's late and I say stupid things.