snobu / destreamer

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

401 Unauthorized #342

Closed cstaykov closed 3 years ago

cstaykov commented 3 years ago

OS: MacOS 11.1

Launch command used: ./destreamer.sh -i https://web.microsoftstream.com/video/[redacted] -v

Issue: Despite being able to access the link manually and play the video, destreamer gets a 401 error when it tries to download it. I signed in successfully and it has a cookie that works for the account that can access the video, but it still gets 401. I've been using destreamer for 2 months about 10 videos/week, on the same account. This is the first day I have issues, and I can't even download videos I downloaded a few days ago successfully. Any chance microsoft has detected this tool and somehow restricted its access?

Verbose log ``` (base) chris@Chriss-MacBook-Pro destreamer % ./destreamer.sh -i https://web.microsoftstream.com/video/[redacted] -v [VERBOSE] Using ffmpeg version 4.3.2 Copyright (c) 2000-2021 the FFmpeg developers Access token still good for 57 minutes. [VERBOSE] Session and API info API Gateway URL: https://cact-1.api.microsoftstream.com/api/ API Gateway version: 1.4-private Parsing video/group urls [VERBOSE] List of GUIDs and corresponding output directory https://web.microsoftstream.com/video/[redacted] => videos Fetching videos info... Downloading Video: SYDE522_Lecture_DeepNets_AE [VERBOSE] Extra video info Video m3u8 playlist URL: https://cact-1.api.microsoftstream.com/api/videos/manifest?api-version=1.0&playbackurl=https://streamcact1su011.azureedge.net/a77edce3-26ac-49a3-bc1e-b79fe9ff18d0/v.ism/manifest(format=m3u8-aapl) Video tumbnail URL: https://cact-1-content.api.microsoftstream.com/api/thumbnails/1/51508b09-ad88-49c6-baa1-e27f0a7a67dc/MS0yY3J3bnFpeW13bnphNmJnbmdoZTZ4c3FkZV8xXzMyMHgxODAucG5n?validTill=2021-03-17T00%3a00%3a00.0000000Z&aadUserOId=85e11cf0-50ca-4b77-9c57-7e55d626f4b2&encoding=base64&api-version=1.4-private&signature=5CqfTjoJ63HalHpZ880sWrs%2b9T3TWOiHGArhBIUtvVc%3d Video subtitle URL (may not exist): undefined Video total chunks: 85.65 Spawning ffmpeg with access token and HLS URL. This may take a few seconds... [WARNING] Got HTTP code 401. Retrying request... [WARNING] Here is the error message: Buffer(0) [Uint8Array] [] [WARNING] We called this URL: https://cact-1.api.microsoftstream.com/api/https://cact-1-content.api.microsoftstream.com/api/thumbnails/1/51508b09-ad88-49c6-baa1-e27f0a7a67dc/MS0yY3J3bnFpeW13bnphNmJnbmdoZTZ4c3FkZV8xXzMyMHgxODAucG5n?validTill=2021-03-17T00%3a00%3a00.0000000Z&aadUserOId=85e11cf0-50ca-4b77-9c57-7e55d626f4b2&encoding=base64&api-version=1.4-private&signature=5CqfTjoJ63HalHpZ880sWrs%2b9T3TWOiHGArhBIUtvVc%3d [ERROR] Error: Request failed with status code 401 at createError (/Users/chris/Extras/destreamer/node_modules/axios/lib/core/createError.js:16:15) at settle (/Users/chris/Extras/destreamer/node_modules/axios/lib/core/settle.js:17:12) at IncomingMessage.handleStreamEnd (/Users/chris/Extras/destreamer/node_modules/axios/lib/adapters/http.js:260:11) at IncomingMessage.emit (node:events:388:22) at endReadableNT (node:internal/streams/readable:1305:12) at processTicksAndRejections (node:internal/process/task_queues:80:21) ```
SurienDG commented 3 years ago

Same I get this error on Windows 10 as well

BoldizsarP commented 3 years ago

Same here windows 10 worked fine yesterday

SurienDG commented 3 years ago

@snobu Any ideas on what changed? Where exactly is the ms api you used for this project defined?

BoldizsarP commented 3 years ago

@snobu Any ideas on what changed? Where exactly is the ms api you used for this project defined? You can kinda force it, with a number of safety retries it seems. I am using the scipt in a python project, and I just try to download it a number of times if it fails. I think this some internal sever error from ms

SurienDG commented 3 years ago

Okay after a little bit of playing around with this I figured out what is causing the problem. The api request for the thumbnail is invalid now. So I guess until this gets fixed use the -x flag.

So instead write: ./destreamer.sh -i https://web.microsoftstream.com/video/[redacted] -x

If you open up developer tools on the Microsoft streams website (where you were viewing the video online) you'll see that in the browser console all the thumbnail 401 errors are still occurring. So this is not a problem with this tool but rather a Microsoft problem. So till that gets resolved I recommend downloading videos using -x flag

BoldizsarP commented 3 years ago

Okay after a little bit of playing around with this I figured out what is causing the problem. The api request for the thumbnail is invalid now. So I guess until this gets fixed use the -x flag.

So instead write: ./destreamer.sh -i https://web.microsoftstream.com/video/[redacted] -x

If you open up developer tools on the Microsoft streams website (where you were viewing the video online) you'll see that in the browser console all the thumbnail 401 errors are still occurring. So this is not a problem with this tool but rather a Microsoft problem. So till that gets resolved I recommend downloading videos using -x flag

I already started 30 dockers with 50 retries hardcoded, but I will chec it out :D

cstaykov commented 3 years ago

Okay after a little bit of playing around with this I figured out what is causing the problem. The api request for the thumbnail is invalid now. So I guess until this gets fixed use the -x flag.

So instead write: ./destreamer.sh -i https://web.microsoftstream.com/video/[redacted] -x

Good catch! Thank you for noticing that. Definitely an issue on MS's side, not with this tool. I'll use -x until it's resolved. Note to anyone reading that the --cc option also isn't working for me. MS seems to be having issues serving subtitles and thumbnails.