mirror of
https://github.com/nimbold/Firelink.git
synced 2026-08-05 08:59:05 +00:00
fix(downloads): harden add modal and retry state
Route explicit no-limit speed overrides without inheriting the global cap. Preserve dotted media titles when switching formats and drain retry gid completions through remember_gid.
This commit is contained in:
@@ -148,6 +148,38 @@ export const mediaFormatSelectorForRow = (
|
||||
return row.formats?.[row.selectedFormat]?.selector;
|
||||
};
|
||||
|
||||
export const mediaFileNameForSelectedFormat = (
|
||||
fileName: string,
|
||||
row: Pick<AddDownloadDraftRow, 'formats' | 'selectedFormat'>
|
||||
): string => {
|
||||
const selectedFormat = row.selectedFormat === undefined
|
||||
? undefined
|
||||
: row.formats?.[row.selectedFormat];
|
||||
if (!selectedFormat) return canonicalizeDownloadFileName(fileName);
|
||||
|
||||
const cleanFileName = canonicalizeDownloadFileName(fileName);
|
||||
const selectedExt = selectedFormat.ext.replace(/^\.+/, '');
|
||||
if (!selectedExt) return cleanFileName;
|
||||
|
||||
const lowerFileName = cleanFileName.toLowerCase();
|
||||
if (lowerFileName.endsWith(`.${selectedExt.toLowerCase()}`)) {
|
||||
return cleanFileName;
|
||||
}
|
||||
|
||||
const lastDot = cleanFileName.lastIndexOf('.');
|
||||
const currentExt = lastDot > 0 ? cleanFileName.slice(lastDot + 1).toLowerCase() : '';
|
||||
const knownFormatExts = new Set(
|
||||
(row.formats || [])
|
||||
.map(format => format.ext.replace(/^\.+/, '').toLowerCase())
|
||||
.filter(Boolean)
|
||||
);
|
||||
const baseName = currentExt && knownFormatExts.has(currentExt)
|
||||
? cleanFileName.slice(0, lastDot)
|
||||
: cleanFileName;
|
||||
|
||||
return canonicalizeDownloadFileName(`${baseName}.${selectedExt}`);
|
||||
};
|
||||
|
||||
export const metadataSummaryMessage = (rows: AddDownloadDraftRow[]): string => {
|
||||
if (rows.length === 0) return 'Paste one or more links.';
|
||||
|
||||
|
||||
Reference in New Issue
Block a user