Merge branch 'tokencache' of https://github.com/snobu/destreamer into tokencache
This commit is contained in:
commit
65847cb29d
6 changed files with 16 additions and 7 deletions
1
destreamer.cmd
Normal file
1
destreamer.cmd
Normal file
|
@ -0,0 +1 @@
|
||||||
|
node.exe build\src\destreamer.js %*
|
1
destreamer.ps1
Normal file
1
destreamer.ps1
Normal file
|
@ -0,0 +1 @@
|
||||||
|
node.exe build\src\destreamer.js $args
|
1
destreamer.sh
Normal file
1
destreamer.sh
Normal file
|
@ -0,0 +1 @@
|
||||||
|
node build/src/destreamer.js "$@"
|
|
@ -17,7 +17,7 @@ function durationToTotalChunks(duration: string) {
|
||||||
const mins = durationObj['minutes'] ?? 0;
|
const mins = durationObj['minutes'] ?? 0;
|
||||||
const secs = Math.ceil(durationObj['seconds'] ?? 0);
|
const secs = Math.ceil(durationObj['seconds'] ?? 0);
|
||||||
|
|
||||||
return hrs * 1000 + mins * 100 + secs;
|
return (hrs * 60) + mins + (secs / 60);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -137,5 +137,5 @@ export function ffmpegTimemarkToChunk(timemark: string) {
|
||||||
const mins = parseInt(timeVals[1]);
|
const mins = parseInt(timeVals[1]);
|
||||||
const secs = parseInt(timeVals[2]);
|
const secs = parseInt(timeVals[2]);
|
||||||
|
|
||||||
return hrs * 1000 + mins * 100 + secs;
|
return (hrs * 60) + mins + (secs / 60);
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,6 +15,7 @@ import isElevated from 'is-elevated';
|
||||||
import puppeteer from 'puppeteer';
|
import puppeteer from 'puppeteer';
|
||||||
import colors from 'colors';
|
import colors from 'colors';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
|
import fs from 'fs';
|
||||||
import sanitize from 'sanitize-filename';
|
import sanitize from 'sanitize-filename';
|
||||||
import cliProgress from 'cli-progress';
|
import cliProgress from 'cli-progress';
|
||||||
|
|
||||||
|
@ -148,7 +149,6 @@ async function downloadVideo(videoUrls: string[], outputDirectories: string[], s
|
||||||
const outDirsIdxInc = outputDirectories.length > 1 ? 1:0;
|
const outDirsIdxInc = outputDirectories.length > 1 ? 1:0;
|
||||||
for (let i=0, j=0, l=metadata.length; i<l; ++i, j+=outDirsIdxInc) {
|
for (let i=0, j=0, l=metadata.length; i<l; ++i, j+=outDirsIdxInc) {
|
||||||
const video = metadata[i];
|
const video = metadata[i];
|
||||||
let previousChunks = 0;
|
|
||||||
const pbar = new cliProgress.SingleBar({
|
const pbar = new cliProgress.SingleBar({
|
||||||
barCompleteChar: '\u2588',
|
barCompleteChar: '\u2588',
|
||||||
barIncompleteChar: '\u2591',
|
barIncompleteChar: '\u2591',
|
||||||
|
@ -186,23 +186,29 @@ async function downloadVideo(videoUrls: string[], outputDirectories: string[], s
|
||||||
// set events
|
// set events
|
||||||
ffmpegCmd.on('update', (data: any) => {
|
ffmpegCmd.on('update', (data: any) => {
|
||||||
const currentChunks = ffmpegTimemarkToChunk(data.out_time);
|
const currentChunks = ffmpegTimemarkToChunk(data.out_time);
|
||||||
const incChunk = currentChunks - previousChunks;
|
|
||||||
|
|
||||||
pbar.increment(incChunk, {
|
pbar.update(currentChunks, {
|
||||||
speed: data.bitrate
|
speed: data.bitrate
|
||||||
});
|
});
|
||||||
|
|
||||||
previousChunks = currentChunks;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
ffmpegCmd.on('error', (error: any) => {
|
ffmpegCmd.on('error', (error: any) => {
|
||||||
pbar.stop();
|
pbar.stop();
|
||||||
|
|
||||||
|
try {
|
||||||
|
fs.unlinkSync(outputPath);
|
||||||
|
} catch (e) {}
|
||||||
|
|
||||||
console.log(`\nffmpeg returned an error: ${error.message}`);
|
console.log(`\nffmpeg returned an error: ${error.message}`);
|
||||||
process.exit(ERROR_CODE.UNK_FFMPEG_ERROR);
|
process.exit(ERROR_CODE.UNK_FFMPEG_ERROR);
|
||||||
});
|
});
|
||||||
|
|
||||||
process.on('SIGINT', () => {
|
process.on('SIGINT', () => {
|
||||||
pbar.stop();
|
pbar.stop();
|
||||||
|
|
||||||
|
try {
|
||||||
|
fs.unlinkSync(outputPath);
|
||||||
|
} catch (e) {}
|
||||||
});
|
});
|
||||||
|
|
||||||
// let the magic begin...
|
// let the magic begin...
|
||||||
|
|
Loading…
Reference in a new issue