1
0
mirror of https://github.com/snobu/destreamer.git synced 2026-02-04 06:08:23 +00:00

Fix auto rename for duplicate video titles (#118)

* Fix `makeUniqueTitle` was not working with (custom) output format
* Add option to skip already existing files
* Update README to include --skip option

Co-authored-by: molikuner <molikuner@gmail.com>
This commit is contained in:
molikuner
2020-05-06 09:28:17 +02:00
committed by GitHub
parent 94b6da7fae
commit 3a8ed600ac
4 changed files with 28 additions and 12 deletions

View File

@@ -4,6 +4,7 @@ import { execSync } from 'child_process';
import colors from 'colors';
import fs from 'fs';
import path from 'path';
import { argv } from './CommandLineParser';
function sanitizeUrls(urls: string[]) {
const rex = new RegExp(/(?:https:\/\/)?.*\/video\/[a-z0-9]{8}-(?:[a-z0-9]{4}\-){3}[a-z0-9]{12}$/, 'i');
@@ -126,7 +127,7 @@ export function makeUniqueTitle(title: string, outDir: string) {
let ntitle = title;
let k = 0;
while (fs.existsSync(outDir + path.sep + ntitle + '.mp4'))
while (!argv.skip && fs.existsSync(outDir + path.sep + ntitle + '.' + argv.format))
ntitle = title + ' - ' + (++k).toString();
return ntitle;