
* Input url list: Fix bad Windows behavior * Minor output fix * Fix all download issues - downloads are synchronous again - fix progress bar (fix #39) - nuke fluent and switch to a bug-free ffmpeg module (fessonia) * Move destreamer process events to a new file, we may add more in the future, lets give them their own space * Destreamer: Release packages and builder script ETA when? :P * Clean up * Implement yargs checks and add --videoUrlsFile option * Refactor error handling - Human readable - No magic numbers * Handle mkdir error - remove reduntant message * gitignore: don't add hidden files * Implement --outputDirectories This gives us more flexibility on where to save videos ..especially if your videos have all the same name <.< * Rename utils -> Utils * Fix tests don't import yargs on files other than main * Create scripts directory * Update make_release path * Fix typo * Create CONTRIBUTING.md Co-authored-by: kylon <kylonux@gmail.com>
67 lines
2.6 KiB
TypeScript
67 lines
2.6 KiB
TypeScript
import { parseVideoUrls } from '../src/Utils';
|
|
import puppeteer from 'puppeteer';
|
|
import assert from 'assert';
|
|
import tmp from 'tmp';
|
|
import fs from 'fs';
|
|
|
|
let browser: any;
|
|
let page: any;
|
|
|
|
before(async () => {
|
|
browser = await puppeteer.launch({
|
|
headless: true,
|
|
args: ['--disable-dev-shm-usage']
|
|
});
|
|
page = await browser.newPage();
|
|
});
|
|
|
|
describe('Puppeteer', () => {
|
|
it('should grab GitHub page title', async () => {
|
|
await page.goto("https://github.com/", { waitUntil: 'networkidle2' });
|
|
let pageTitle = await page.title();
|
|
assert.equal(true, pageTitle.includes('GitHub'));
|
|
|
|
}).timeout(15000); // yeah, this may take a while...
|
|
});
|
|
|
|
after(async () => {
|
|
await browser.close();
|
|
});
|
|
|
|
|
|
describe('Destreamer', () => {
|
|
it('should parse and sanitize URL list from file', () => {
|
|
const testIn: string[] = [
|
|
"https://web.microsoftstream.com/video/xxxxxxxx-zzzz-hhhh-rrrr-dddddddddddd",
|
|
"https://web.microsoftstream.com/video/xxxxxxxx-zzzz-hhhh-rrrr-dddddddddddd?",
|
|
"https://web.microsoftstream.com/video/xxxxxxxx-zzzz-hhhh-rrrr-dddddddddddd&",
|
|
"",
|
|
"https://web.microsoftstream.com/video/xxxxxxxx-zzzz-hhhh-rrrr-dddddddddddd?a=b&c",
|
|
"https://web.microsoftstream.com/video/xxxxxxxx-zzzz-hhhh-rrrr-dddddddddddd?a",
|
|
"https://web.microsoftstream.com/video/xxxxxxxx-zzzz-hhhh-rrrr-dddddddddd",
|
|
"https://web.microsoftstream.com/video/xxxxxx-zzzz-hhhh-rrrr-dddddddddddd",
|
|
""
|
|
];
|
|
const expectedOut: string[] = [
|
|
"https://web.microsoftstream.com/video/xxxxxxxx-zzzz-hhhh-rrrr-dddddddddddd",
|
|
"https://web.microsoftstream.com/video/xxxxxxxx-zzzz-hhhh-rrrr-dddddddddddd",
|
|
"https://web.microsoftstream.com/video/xxxxxxxx-zzzz-hhhh-rrrr-dddddddddddd?a=b&c",
|
|
"https://web.microsoftstream.com/video/xxxxxxxx-zzzz-hhhh-rrrr-dddddddddddd?a"
|
|
];
|
|
const tmpFile = tmp.fileSync({ postfix: '.txt' });
|
|
let testOut: string[];
|
|
|
|
fs.writeFileSync(tmpFile.fd, testIn.join('\r\n'));
|
|
|
|
testOut = parseVideoUrls([tmpFile.name])!;
|
|
if (testOut.length !== expectedOut.length)
|
|
assert.strictEqual(testOut, expectedOut, "URL list not sanitized");
|
|
|
|
for (let i=0, l=testOut.length; i<l; ++i) {
|
|
if (testOut[i] !== expectedOut[i])
|
|
assert.strictEqual(testOut[i], expectedOut[i], "URL not sanitized");
|
|
}
|
|
|
|
assert.ok("sanitizeUrls ok");
|
|
});
|
|
});
|