fix typo & sanitize video names on win32 (#205)
* fix typo & sanitize video names on win32 * add warning for invalid path
This commit is contained in:
parent
5b62c50b22
commit
a9f8b02f08
2 changed files with 10 additions and 6 deletions
|
@ -72,7 +72,7 @@ export const argv: any = yargs.options({
|
||||||
},
|
},
|
||||||
closedCaptions: {
|
closedCaptions: {
|
||||||
alias: 'cc',
|
alias: 'cc',
|
||||||
describe: 'Check if closed captions are aviable and let the user choose which one to download (will not ask if only one aviable)',
|
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',
|
type: 'boolean',
|
||||||
default: false,
|
default: false,
|
||||||
demandOption: false
|
demandOption: false
|
||||||
|
@ -183,8 +183,8 @@ function isOutputTemplateValid(argv: any): boolean {
|
||||||
while (match) {
|
while (match) {
|
||||||
if (!templateElements.includes(match[1])) {
|
if (!templateElements.includes(match[1])) {
|
||||||
logger.error(
|
logger.error(
|
||||||
`'${match[0]}' is not aviable as a template element \n` +
|
`'${match[0]}' is not available as a template element \n` +
|
||||||
`Aviable templates elements: '${templateElements.join("', '")}' \n`,
|
`Available templates elements: '${templateElements.join("', '")}' \n`,
|
||||||
{ fatal: true }
|
{ fatal: true }
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -24,14 +24,14 @@ function publishedTimeToString(date: string): string {
|
||||||
const minutes: string = dateJs.getMinutes().toString();
|
const minutes: string = dateJs.getMinutes().toString();
|
||||||
const seconds: string = dateJs.getSeconds().toString();
|
const seconds: string = dateJs.getSeconds().toString();
|
||||||
|
|
||||||
return `${hours}:${minutes}:${seconds}`;
|
return `${hours}.${minutes}.${seconds}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function isoDurationToString(time: string): string {
|
function isoDurationToString(time: string): string {
|
||||||
const duration: Duration = parseDuration(time);
|
const duration: Duration = parseDuration(time);
|
||||||
|
|
||||||
return `${duration.hours ?? '00'}:${duration.minutes ?? '00'}:${duration.seconds?.toFixed(0) ?? '00'}`;
|
return `${duration.hours ?? '00'}.${duration.minutes ?? '00'}.${duration.seconds?.toFixed(0) ?? '00'}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -152,8 +152,12 @@ export function createUniquePath(videos: Array<Video>, outDirs: Array<string>, t
|
||||||
finalTitle = `${title}.${++i}`;
|
finalTitle = `${title}.${++i}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const finalFileName = `${finalTitle}.${format}`;
|
||||||
|
const cleanFileName = sanitizeWindowsName(finalFileName, { replacement: "_" });
|
||||||
|
if (finalFileName !== cleanFileName) logger.warn(`Not a valid Windows file name: "${finalFileName}".\nReplacing invalid characters with underscores to preserve cross-platform consistency.`);
|
||||||
|
|
||||||
|
video.outPath = path.join(outDirs[index], finalFileName);
|
||||||
|
|
||||||
video.outPath = path.join(outDirs[index], finalTitle + '.' + format);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
return videos;
|
return videos;
|
||||||
|
|
Loading…
Reference in a new issue