snobu / destreamer

Save Microsoft Stream videos for offline enjoyment.
MIT License
2.36k stars 440 forks source link

Feature request: Save login in chronium for headless server. #236

Closed paniniham closed 3 years ago

paniniham commented 3 years ago

First, I just wanna say thank you snobu and other contributive devs for this amazing project. I can't live a day without this because Microsoft Stream doesn't allow faster playback while my lectures are at an unbearable speed. Secondly, I am currently running this on my Mac right now, I have a server but its only output is CLI. Is there any way I can save my login like modern browsers and transfer the build to my server? Once again thank you <3

lukaarma commented 3 years ago

Unfortunately puppeteer can't read desktop mode cookies when running in headless mode for some reason, so you can't just transfer you desktop cookies to a CLI server... I mean you could try to tranfer everythin as is on the server and launch it if you saved your cookies since it doesn't really need a desktop chromium so if it doesn't crash because there is no X-server it could run in theory

Let me know if I need to retype this to be more clear since it seems quite confusing :P

paniniham commented 3 years ago

I feel embarrassing for having to ask for more clearance...I am an IT student too but you seem to be doing so well lol :) What you are trying to say is that I need a way to save the cookies and transfer the build to my server so I don't have to login again? I would apreciate any help or any source to start Thank you <3

lukaarma commented 3 years ago

You don't have to be embarrassed when asking for help/clearance! It shows that you want to know mode :)

Anyway I'll make a complete response tomorrow as I'm logging off, the bed awaits me :D

paniniham commented 3 years ago

I look forward to your response and thank you for your dedication.

lukaarma commented 3 years ago

You are using the '-k' option when launching, right?

paniniham commented 3 years ago

I have to say very dumbly that I have just now seen that option (FORGIVE MY BLINDED DUMB EYES)...then it solves the situation of saving logins on my Mac but is there something I should do or just copy the build to my server for only CLI operations?

lukaarma commented 3 years ago

The problem with a cli only runtime is that chromium normally launch in desktop mode so I don't know if it will outright crash or what.

What you can try is run Destreamer on your Mac with the -k option and tell yes when asked to remember login, then copy the whole destreamer folder over to the server and try to run it. Probably this won't work since it may crash for the missing X-server or puppeteer wont read the cookies for the login, but if you are lucky enough it might work

Try it and let me know! :D

paniniham commented 3 years ago

[WARNING] Access token has expired!

Launching headless Chrome to perform the OpenID Connect dance...

[ERROR] Error: Failed to launch the browser process! spawn /destreamer/node_modules/puppeteer/.local-chromium/linux-722234/chrome-linux/chrome ENOENT

TROUBLESHOOTING: https://github.com/puppeteer/puppeteer/blob/master/docs/troubleshooting.md

at onClose (/destreamer/node_modules/puppeteer/lib/Launcher.js:750:14)
at ChildProcess.helper.addEventListener.error (/destreamer/node_modules/puppeteer/lib/Launcher.js:741:65)
at ChildProcess.emit (events.js:198:13)
at Process.ChildProcess._handle.onexit (internal/child_process.js:246:12)
at onErrorNT (internal/child_process.js:415:16)
at process._tickCallback (internal/process/next_tick.js:63:19)
at Function.Module.runMain (internal/modules/cjs/loader.js:834:11)
at startup (internal/bootstrap/node.js:283:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3)

I got this error, I am not sure if it's because of xserver on the CLI or the fact that mine is a raspberry pi 4 and does not support the web browser to begin with. Feel free to ask me to do anything and thank you so much for your help so far.

lukaarma commented 3 years ago

you should delete the destreamer/node_module directory and run npm i then build and run again destreamer. The rasp is an arm64 architecture, your mac I'm not sure so with this procedure you will make sure that all the binaries are for the correct platform

paniniham commented 3 years ago

image This is when i grab the files with npm i image This is when i tries to run the build. Feel free to give me some suggestions. Note: When i try to run the build with root user, it wont allow me so I used a regular user with the command chmod +x destreamer.sh to make it executable.

lukaarma commented 3 years ago

mhhhh...there's one more thing that we could try:

If this fails I'm out of ideas and probably your best solution is to just install a light X-server if you want it to run on the Raspberry Pi, sorry :/

paniniham commented 3 years ago

Thank you for your suggestions, yes the option -k has always been used since you told me, I was just testing to see if I can't launch it was it because of the token And the changes to the .ts file did not resolve it. It was built successfully but it still did not work. None the less, it is still my fault for trying to deploy it on a headless server. Thank you for making the program, to begin with, it is a lifesaver for my academic life. <3 And I will continue to use it on my Mac none the less

lukaarma commented 3 years ago

I'm sorry that we could not solve this issue. Maybe in a galaxy far far away we will be also CLI only but I sincerely doubt it :/

Ayanmullick commented 3 years ago

@lukaarma, I'm facing the same error. The Chromium instance being downloaded has extension installation disabled and one isn't able to enable it using flags either.

Screenshot ![image](https://user-images.githubusercontent.com/17693249/103101505-7f413180-45dd-11eb-940a-f97a32ab4c22.png)

Could destreamer launch the default browser on the machine instead of the downloaded Chromium?

lukaarma commented 3 years ago

Sure you can take a look here For now it's the only way and it's a bit annoying, I'm sorry

Ayanmullick commented 3 years ago

Thank you for your response, @lukaarma. I couldn't get it to work. After adding the path and rebuilding it doesn't prompt for login.😞

lukaarma commented 3 years ago

Does it give you any error when you launch it? Can you provide a screenshot of the lines of code you modified please?

@snobu we have to create a more friendly way to let user plug in their browser

Ayanmullick commented 3 years ago

@lukaarma, I changed the executable path, as pointed in the document.

Screenshot ![image](https://user-images.githubusercontent.com/17693249/103159438-041f7d00-478f-11eb-94a8-8d9bb25a2f1b.png)

Looks like it's failing to launch Edge.

Screenshot ![image](https://user-images.githubusercontent.com/17693249/103159361-26fd6180-478e-11eb-80ac-d2deb609973e.png)
lukaarma commented 3 years ago

You have to escape the backslashes like this \\ or use / as a separator for the executable path @Ayanmullick

Ayanmullick commented 3 years ago

Thanks for pointing out, @lukaarma. I get a similar compliance error when launching Edge without a Profile. And the same Git error when launching with a profile.

Code screenshot ![image](https://user-images.githubusercontent.com/17693249/103159829-ae999f00-4793-11eb-98ec-b978c5eef319.png)

"C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedge.exe" --profile-directory="Profile 1" works fine from the Run prompt.