snobu / destreamer

Save Microsoft Stream videos for offline enjoyment.
MIT License
2.37k stars 438 forks source link

(node:5580) UnhandledPromiseRejectionWarning: TimeoutError: Navigation Timeout Exceeded: 30000ms exceeded #18

Closed FraH90 closed 4 years ago

FraH90 commented 4 years ago

So, it was working for me till I updated the script with your latest version; i updated because sometimes it worked, other times it didn't (very strange) so I tried to update; I did npm install, npm run -s build, and added --no-sandbox to arguments, just like I did the first time I installed it.

Now, it gives me this: Launching headless Chrome to perform the OpenID Connect dance... Navigating to STS login page... We are logged in. Sorry, i mean "you". (node:5580) UnhandledPromiseRejectionWarning: TimeoutError: Navigation Timeout Exceeded: 30000ms exceeded at C:\Users\xxx\Desktop\destreamer-dev\node_modules\puppeteer\lib\LifecycleWatcher.js:142:21 -- ASYNC -- at Frame.<anonymous> (C:\Users\xxx\Desktop\destreamer-dev\node_modules\puppeteer\lib\helper.js:111:15) at Page.goto (C:\Users\xxx\Desktop\destreamer-dev\node_modules\puppeteer\lib\Page.js:674:49) at Page.<anonymous> (C:\Users\xxx\Desktop\destreamer-dev\node_modules\puppeteer\lib\helper.js:112:23) at rentVideoForLater (C:\Users\xxx\Desktop\destreamer-dev\destreamer.js:72:20) (node:5580) 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:5580) [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.

I've also tried to reinstall everything, with the old version of the script (I had it zipped), but nothing ;( Please help me, I'm using your script to download the videos of my class :(

PS if you need the logs you can tell me where to find them (I'm not pratical of nodejs)

snobu commented 4 years ago

I can't seem to reproduce this on either Node 8 / 10 / 12 or 13. Does the browser window navigate to the video URL after logging in?

klenium commented 4 years ago

Same happened for me. A new video was just recorded in a MS Teams meeting. After it finished, the video was available in Stream to play in real browser, but the script failed to download it. I waited like one hour, tried it again and I could download it. Maybe in the background there is some conversion?

klenium commented 4 years ago

Does the browser window navigate to the video URL after logging in?

Yes. In this test-managed-browser, we can't watch the video, because this type of browser is not supported by Stream. However, in other videos I could see the actual video for about 0.1 seconds. In the case the error occurred, I didn't see any part of the video.

snobu commented 4 years ago

Can you navigate to this URL

https://use2-2.api.microsoftstream.com/api/videos/THE_GUID_OF_YOUR_VIDEO/?api-version=1.3-private

and check if playbackUrls being returned in the JSON response has an entry with this mime type?

"mimeType": "application/vnd.apple.mpegurl"

Login to Microsoft Stream first in your browser of choice.

FraH90 commented 4 years ago

Does the browser window navigate to the video URL after logging in?

Yes. In this test-managed-browser, we can't watch the video, because this type of browser is not supported by Stream. However, in other videos I could see the actual video for about 0.1 seconds. In the case the error occurred, I didn't see any part of the video.

I was saying the same exact thing. When the software was working right, you could watch a preview of the video, for 1 second; but when you have that error, the preview doesn't show. Don't know if it can help knowing this behaviour.

PS: I've tried many and many times, without doing things differently... the last time for me it worked! But I swear, I've not done anything differently, and it was the same link

klenium commented 4 years ago
https://use2-2.api.microsoftstream.com/api/videos/THE_GUID_OF_YOUR_VIDEO/?api-version=1.3-private

That returns a 401 error.

... for all video IDs that I could download some hours earlier. But for an invalid ID, it prints a valid JSON error message.

Dam98 commented 4 years ago

Can you navigate to this URL

https://use2-2.api.microsoftstream.com/api/videos/THE_GUID_OF_YOUR_VIDEO/?api-version=1.3-private

and check if playbackUrls being returned in the JSON response has an entry with this mime type?

"mimeType": "application/vnd.apple.mpegurl"

Login to Microsoft Stream first in your browser of choice.

{ "error": { "code": "InvalidUrlId", "message": "The URL resource id is invalid." } }

klenium commented 4 years ago

@Dam98 You have to replace THE_GUID_OF_YOUR_VIDEO in that URL to the real value.

FraH90 commented 4 years ago

Same for me. For the videos that I'm not able to download it gives a 401 error

FraH90 commented 4 years ago

I can't seem to reproduce this on either Node 8 / 10 / 12 or 13. Does the browser window navigate to the video URL after logging in?

Ok, I have news on the bug: I can confirm that it is totally random. It doesn't happen always now, but just with some videos: the strange thing is that after I've get the error, if I try again with the same video another time, it will work! But it's annoying, cause you need to login everytime, and moreover sometimes you need to try two or three more times to make it work.

However, thanks for your beautiful work, I really appreciate it and hope it will be improved by the community.

snobu commented 4 years ago

We're changing the way we fetch the Media Services video URL in this PR. There's real hope things are going to get way more stable right after since this time around the implementation is deterministic (API call) rather than parsing the DOM (which is what we do now).

lukaarma commented 4 years ago

This issue seems almost resolved on my fork thanks to a change in the way puppeteer waits for the video page to load, we'll see if it's resolved for everyone after #20 will be merged in the repo

snobu commented 4 years ago

This should be fixed now (don't forget to git pull, and transpile). Just reopen if you still see this problem.