From 1fbe36629b3dbc7c93515bc044f95c0f116a4688 Mon Sep 17 00:00:00 2001 From: Adrian Calinescu Date: Sat, 12 Sep 2020 22:33:20 +0300 Subject: [PATCH 1/9] Add v3 teaser --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index f6ebea1..9ed9ac8 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,11 @@ CI build status +# BREAKING + +**destreamer v3.0** is just around the corner. Download speed improvement is astonishing and we have a never before seen photo from the design sessions:

+![desilva](https://user-images.githubusercontent.com/6472374/93003437-54a7fd00-f547-11ea-8473-e4602993e69d.jpg) + ![destreamer](assets/logo.png) _(Alternative artwork proposals are welcome! Submit one through an Issue.)_ From b6c0dfe98dd8c6b1081aea6494dc497ba60da4b1 Mon Sep 17 00:00:00 2001 From: Adrian Calinescu Date: Sat, 12 Sep 2020 22:58:51 +0300 Subject: [PATCH 2/9] Update README.md --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 9ed9ac8..dcbd12d 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,10 @@ **destreamer v3.0** is just around the corner. Download speed improvement is astonishing and we have a never before seen photo from the design sessions:

![desilva](https://user-images.githubusercontent.com/6472374/93003437-54a7fd00-f547-11ea-8473-e4602993e69d.jpg) +Help us pick a codename for the new release:

+![codename](https://user-images.githubusercontent.com/6472374/93003896-20ced680-f54b-11ea-8be1-2c14e0bd3751.png) +Comment in this thread: https://github.com/snobu/destreamer/issues/223 + ![destreamer](assets/logo.png) _(Alternative artwork proposals are welcome! Submit one through an Issue.)_ From f2b7a9ba96f2c022e28472a1fa3b16f6707c4f43 Mon Sep 17 00:00:00 2001 From: Adrian Calinescu Date: Sat, 12 Sep 2020 22:59:42 +0300 Subject: [PATCH 3/9] Add help us pick a codename --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index dcbd12d..7535ee6 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ ![desilva](https://user-images.githubusercontent.com/6472374/93003437-54a7fd00-f547-11ea-8473-e4602993e69d.jpg) Help us pick a codename for the new release:

-![codename](https://user-images.githubusercontent.com/6472374/93003896-20ced680-f54b-11ea-8be1-2c14e0bd3751.png) +![codename](https://user-images.githubusercontent.com/6472374/93003896-20ced680-f54b-11ea-8be1-2c14e0bd3751.png)

Comment in this thread: https://github.com/snobu/destreamer/issues/223 ![destreamer](assets/logo.png) From 01014df068e64e8359675bef003013c57b70f94d Mon Sep 17 00:00:00 2001 From: Adrian Calinescu Date: Thu, 17 Sep 2020 12:11:58 +0300 Subject: [PATCH 4/9] Added README section on plugging in your own browser --- README.md | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/README.md b/README.md index 7535ee6..8e93248 100644 --- a/README.md +++ b/README.md @@ -61,6 +61,33 @@ Note that destreamer won't run in an elevated (Administrator/root) shell. Runnin **WSL** (Windows Subsystem for Linux) is not supported as it can't easily pop up a browser window. It *may* work by installing an X Window server (like [Xming][xming]) and exporting the default display to it (`export DISPLAY=:0`) before running destreamer. See [this issue for more on WSL v1 and v2][wsl]. +## Can i plug in my own browser? + +Yes, yes you can. This may be useful if your main browser has some authentication plugins that are required for you to logon to your Microsoft Stream tenant. +To use your own browser for the authentication part, locate the following snippet in `src/destreamer.ts`: + +``` +const browser: puppeteer.Browser = await puppeteer.launch({ + executablePath: getPuppeteerChromiumPath(), + headless: false, + userDataDir: (argv.keepLoginCookies) ? chromeCacheFolder : undefined, + args: [ + '--disable-dev-shm-usage', + '--fast-start', + '--no-sandbox' + ] + }); +``` + +Now, change `executablePath` to reflect the path to your browser and profile (i.e. to use Microsoft Edge on Windows): +``` + executablePath: "'C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe' --profile-directory=Default", +``` + +Note that for Mac/Linux the path will look a little different but no other changes are necessary. + +You need to rebuild (`npm run build`) every time you change this configuration. + ## How to build To build destreamer clone this repository, install dependencies and run the build script - From de6ab1d8afb7b54a29e00f75276d792a779f9d5c Mon Sep 17 00:00:00 2001 From: Adrian Calinescu Date: Thu, 17 Sep 2020 12:12:54 +0300 Subject: [PATCH 5/9] Fix syntax highlight --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 8e93248..69d150c 100644 --- a/README.md +++ b/README.md @@ -66,7 +66,7 @@ Note that destreamer won't run in an elevated (Administrator/root) shell. Runnin Yes, yes you can. This may be useful if your main browser has some authentication plugins that are required for you to logon to your Microsoft Stream tenant. To use your own browser for the authentication part, locate the following snippet in `src/destreamer.ts`: -``` +```typescript const browser: puppeteer.Browser = await puppeteer.launch({ executablePath: getPuppeteerChromiumPath(), headless: false, @@ -80,7 +80,7 @@ const browser: puppeteer.Browser = await puppeteer.launch({ ``` Now, change `executablePath` to reflect the path to your browser and profile (i.e. to use Microsoft Edge on Windows): -``` +```typescript executablePath: "'C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe' --profile-directory=Default", ``` From 8848f293d7963999eab62687e99a088c990a5c38 Mon Sep 17 00:00:00 2001 From: Rohit Devmore Date: Sun, 4 Oct 2020 00:07:40 +0530 Subject: [PATCH 6/9] Update README.md made videos path clear --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 69d150c..c4c3215 100644 --- a/README.md +++ b/README.md @@ -214,7 +214,7 @@ iTerm2 on a Mac - ![screenshot](assets/screenshot-mac.png) -By default, downloads are saved under `videos/` unless specified by `-o` (output directory). +By default, downloads are saved under `videos/` ( Not a system media Videos folder ), unless specified by `-o` (output directory). ## Contributing From 389be33f746919359b0652b1ce6afb66954e553d Mon Sep 17 00:00:00 2001 From: Rohit Devmore Date: Sun, 4 Oct 2020 00:18:33 +0530 Subject: [PATCH 7/9] Update README.md made videos path clearer --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c4c3215..a47086f 100644 --- a/README.md +++ b/README.md @@ -214,7 +214,7 @@ iTerm2 on a Mac - ![screenshot](assets/screenshot-mac.png) -By default, downloads are saved under `videos/` ( Not a system media Videos folder ), unless specified by `-o` (output directory). +By default, downloads are saved under project root `Destreamer/videos/` ( Not the system media Videos folder ), unless specified by `-o` (output directory). ## Contributing From 22968f42ea4970f20962fed5ab9bb355f0f70a0a Mon Sep 17 00:00:00 2001 From: lukaarma Date: Thu, 8 Oct 2020 15:00:28 +0200 Subject: [PATCH 8/9] Misc fixes (#244) * cleared up docs * fix 401 bug for images thumbnail --- README.md | 28 ++++++++++++++++------------ src/ApiClient.ts | 15 +++++++++++++++ src/CommandLineParser.ts | 23 ++++++++++++----------- src/destreamer.ts | 2 ++ 4 files changed, 45 insertions(+), 23 deletions(-) diff --git a/README.md b/README.md index a47086f..b630624 100644 --- a/README.md +++ b/README.md @@ -108,31 +108,35 @@ 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 video urls [array] + 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}"] - --outputDirectory, -o The directory where destreamer will save your downloads [string] [default: "videos"] - --keepLoginCookies, -k Let Chromium cache identity provider cookies so you can use "Remember me" during login + --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) + --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] - --closedCaptions, --cc Check if closed captions are aviable and let the user choose which one to download (will not - ask if only one aviable) [boolean] [default: false] - --noCleanup, --nc Do not delete the downloaded video file when an FFmpeg error occurs [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) + --format Output container format (mkv, mp4, mov, anything that FFmpeg supports). [string] [default: "mkv"] - --skip Skip download if file already exists [boolean] [default: false] + --skip Skip download if file already exists. [boolean] [default: false] ``` +- both --videoUrls and --inputFile also accept Microsoft Teams Groups url so if your Organization placed the videos you are interested in a group you can copy the link and Destreamer will download all the videos it can inside it! A group url looks like this https://web.microsoftstream.com/group/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX + - Passing `--username` is optional. It's there to make logging in faster (the username field will be populated automatically on the login form). - You can use an absolute path for `-o` (output directory), for example `/mnt/videos`. diff --git a/src/ApiClient.ts b/src/ApiClient.ts index 2ca0554..a92524a 100644 --- a/src/ApiClient.ts +++ b/src/ApiClient.ts @@ -43,6 +43,11 @@ export class ApiClient { }); } + /** + * Used to initialize/retrive the active ApiClient + * + * @param session used if initializing + */ public static getInstance(session?: Session): ApiClient { if (!ApiClient.instance) { ApiClient.instance = new ApiClient(session); @@ -51,6 +56,16 @@ export class ApiClient { return ApiClient.instance; } + public setSession(session: Session): void { + if (!ApiClient.instance) { + logger.warn("Trying to update ApiCient session when it's not initialized!"); + } + + this.session = session; + + return; + } + /** * Call Microsoft Stream API. Base URL is sourced from * the session object and prepended automatically. diff --git a/src/CommandLineParser.ts b/src/CommandLineParser.ts index d682c8d..e8de514 100644 --- a/src/CommandLineParser.ts +++ b/src/CommandLineParser.ts @@ -13,12 +13,12 @@ export const argv: any = yargs.options({ username: { alias: 'u', type: 'string', - describe: 'The username used to log into Microsoft Stream (enabling this will fill in the email field for you)', + describe: 'The username used to log into Microsoft Stream (enabling this will fill in the email field for you).', demandOption: false }, videoUrls: { alias: 'i', - describe: 'List of video urls', + describe: 'List of urls to videos or Microsoft Stream groups.', type: 'array', demandOption: false }, @@ -30,7 +30,7 @@ export const argv: any = yargs.options({ }, outputDirectory: { alias: 'o', - describe: 'The directory where destreamer will save your downloads', + describe: 'The directory where destreamer will save your downloads.', type: 'string', default: 'videos', demandOption: false @@ -44,42 +44,43 @@ export const argv: any = yargs.options({ }, keepLoginCookies: { alias: 'k', - describe: 'Let Chromium cache identity provider cookies so you can use "Remember me" during login', + describe: 'Let Chromium cache identity provider cookies so you can use "Remember me" during login.\n' + + 'Must be used every subsequent time you launch Destreamer if you want to log in automatically.', type: 'boolean', default: false, demandOption: false }, noExperiments: { alias: 'x', - describe: 'Do not attempt to render video thumbnails in the console', + describe: 'Do not attempt to render video thumbnails in the console.', type: 'boolean', default: false, demandOption: false }, simulate: { alias: 's', - describe: 'Disable video download and print metadata information to the console', + describe: 'Disable video download and print metadata information to the console.', type: 'boolean', default: false, demandOption: false }, verbose: { alias: 'v', - describe: 'Print additional information to the console (use this before opening an issue on GitHub)', + describe: 'Print additional information to the console (use this before opening an issue on GitHub).', type: 'boolean', default: false, demandOption: false }, closedCaptions: { alias: 'cc', - describe: 'Check if closed captions are available and let the user choose which one to download (will not ask if only one available)', + describe: 'Check if closed captions are available and let the user choose which one to download (will not ask if only one available).', type: 'boolean', default: false, demandOption: false }, noCleanup: { alias: 'nc', - describe: 'Do not delete the downloaded video file when an FFmpeg error occurs', + describe: 'Do not delete the downloaded video file when an FFmpeg error occurs.', type: 'boolean', default: false, demandOption: false @@ -97,13 +98,13 @@ export const argv: any = yargs.options({ demandOption: false }, format: { - describe: 'Output container format (mkv, mp4, mov, anything that FFmpeg supports)', + describe: 'Output container format (mkv, mp4, mov, anything that FFmpeg supports).', type: 'string', default: 'mkv', demandOption: false }, skip: { - describe: 'Skip download if file already exists', + describe: 'Skip download if file already exists.', type: 'boolean', default: false, demandOption: false diff --git a/src/destreamer.ts b/src/destreamer.ts index e518615..805bea9 100644 --- a/src/destreamer.ts +++ b/src/destreamer.ts @@ -13,6 +13,7 @@ import cliProgress from 'cli-progress'; import fs from 'fs'; import isElevated from 'is-elevated'; import puppeteer from 'puppeteer'; +import { ApiClient } from './ApiClient'; const { FFmpegCommand, FFmpegInput, FFmpegOutput } = require('@tedconf/fessonia')(); @@ -151,6 +152,7 @@ async function downloadVideo(videoGUIDs: Array, outputDirectories: Array if (argv.keepLoginCookies && index !== 0) { logger.info('Trying to refresh token...'); session = await refreshSession('https://web.microsoftstream.com/video/' + videoGUIDs[index]); + ApiClient.getInstance().setSession(session); } const pbar: cliProgress.SingleBar = new cliProgress.SingleBar({ From 15c420333e0c9157156e17db3bf6f9c0a50f9124 Mon Sep 17 00:00:00 2001 From: lukaarma Date: Thu, 8 Oct 2020 15:02:36 +0200 Subject: [PATCH 9/9] Update report-trouble.md (#240) --- .github/ISSUE_TEMPLATE/report-trouble.md | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/.github/ISSUE_TEMPLATE/report-trouble.md b/.github/ISSUE_TEMPLATE/report-trouble.md index eb398f9..a40c725 100644 --- a/.github/ISSUE_TEMPLATE/report-trouble.md +++ b/.github/ISSUE_TEMPLATE/report-trouble.md @@ -7,6 +7,24 @@ assignees: '' --- -## PLEASE NEVER PASTE YOUR ACCESS TOKEN INTO A GITHUB ISSUE AS IT MAY CONTAIN PRIVATE INFORMATION + + +OS: + +Launch command used: + + +
+Verbose log + +``` +PASTE VERBOSE LOG HERE +``` +