Download videos from Microsoft Stream with Destreamer
Tags: destreamer, powershell, prompt, git
Published: 2020-12-26 16:29:02

## Presentation
Hello everyone
In these last days I participated in some online lectures that were recorded and made available by Microsoft Stream. Many of these talks, I would like to save offline, to watch during a trip or even listen as a podcast.
There are hundreds (if not thousands) of tools that download videos from YouTube, all online, but unfortunately, none for Microsoft Stream.

It was then that I came across this repository on GitHub and decided to share it with the dev.to community. Enjoy ;)

## Prereqs
* NodeJS
* NPM
* FFMPEG
* Git

## How to build
```
$ git clone https://github.com/snobu/destreamer
$ cd destreamer
$ npm install
$ npm run build
```

## Use
> Note: If you are running the destreamer in a Windows environment, it is recommended to use the PowerShell or Prompt scripts.

For use, you can pass some parameters, all of them can be consulted with the `destreamer` (consult the platform you are using to use the correct extension)

```
$ destreamer.cmd
Options:
  --help                  Show help                                                                            [boolean]
  --version               Show version number                                                                  [boolean]
  --username, -u          The username used to log into Microsoft Stream (enabling this will fill in the email field for
                          you).                                                                                 [string]
  --videoUrls, -i         List of urls to videos or Microsoft Stream groups.                                     [array]
  --inputFile, -f         Path to text file containing URLs and optionally outDirs. See the README for more on outDirs.
                                                                                                                [string]
  --outputDirectory, -o   The directory where destreamer will save your downloads.          [string] [default: "videos"]
  --outputTemplate, -t    The template for the title. See the README for more info.
                                                                [string] [default: "{title} - {publishDate} {uniqueId}"]
  --keepLoginCookies, -k  Let Chromium cache identity provider cookies so you can use "Remember me" during login.
                          Must be used every subsequent time you launch Destreamer if you want to log in automatically.
                                                                                              [boolean] [default: false]
  --noExperiments, -x     Do not attempt to render video thumbnails in the console.           [boolean] [default: false]
  --simulate, -s          Disable video download and print metadata information to the console.
                                                                                              [boolean] [default: false]
  --verbose, -v           Print additional information to the console (use this before opening an issue on GitHub).
                                                                                              [boolean] [default: false]
  --closedCaptions, --cc  Check if closed captions are available and let the user choose which one to download (will not
                          ask if only one available).                                         [boolean] [default: false]
  --noCleanup, --nc       Do not delete the downloaded video file when an FFmpeg error occurs.[boolean] [default: false]
  --vcodec                Re-encode video track. Specify FFmpeg codec (e.g. libx265) or set to "none" to disable video.
                                                                                              [string] [default: "copy"]
  --acodec                Re-encode audio track. Specify FFmpeg codec (e.g. libopus) or set to "none" to disable audio.
                                                                                              [string] [default: "copy"]
  --format                Output container format (mkv, mp4, mov, anything that FFmpeg supports).
                                                                                               [string] [default: "mkv"]
  --skip                  Skip download if file already exists.                               [boolean] [default: false]
```

For example, I had to download some videos and make them manually it would be laborious, so I copied the links and put them in a notepad inside the installation folder.
From there, I ran the command at a Windows prompt:

```powershell
destreamer.cmd -u USER@EMAIL.COM -f links.txt -k true -x true --skip
```

`-u`: I pass the user to login to Microsoft Stream (it is still necessary to enter the password).

`-f`: It is the file that contains my links, they must be placed one per line. If you want to download a single file, just use the `-i` option and pass the direct link to the video (read the help or documentation).

`-k`: I set it to true to keep the session cookie I logged in. Thus, it is not necessary to enter the password in any of the subsequent downloads. Complete automation.

`-x`: The destreamer tool presents a brief preview of the video being downloaded. To remove this, I set this option to true. The output log is cleaner.

`--skip`: If any video fails, I can run this entire command again and this parameter will validate that the video has already been downloaded and will ignore it for download.

## Source
The complete documentation and new versions of the tool can be found in the official repository:
{% github snobu/destreamer no-readme %}