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: {
|
||||
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',
|
||||
default: false,
|
||||
demandOption: false
|
||||
|
@ -183,8 +183,8 @@ function isOutputTemplateValid(argv: any): boolean {
|
|||
while (match) {
|
||||
if (!templateElements.includes(match[1])) {
|
||||
logger.error(
|
||||
`'${match[0]}' is not aviable as a template element \n` +
|
||||
`Aviable templates elements: '${templateElements.join("', '")}' \n`,
|
||||
`'${match[0]}' is not available as a template element \n` +
|
||||
`Available templates elements: '${templateElements.join("', '")}' \n`,
|
||||
{ fatal: true }
|
||||
);
|
||||
|
||||
|
|
|
@ -24,14 +24,14 @@ function publishedTimeToString(date: string): string {
|
|||
const minutes: string = dateJs.getMinutes().toString();
|
||||
const seconds: string = dateJs.getSeconds().toString();
|
||||
|
||||
return `${hours}:${minutes}:${seconds}`;
|
||||
return `${hours}.${minutes}.${seconds}`;
|
||||
}
|
||||
|
||||
|
||||
function isoDurationToString(time: string): string {
|
||||
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}`;
|
||||
}
|
||||
|
||||
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;
|
||||
|
|
Loading…
Reference in a new issue