mirror of
https://github.com/nimbold/Firelink.git
synced 2026-08-24 09:46:29 +00:00
feat(downloads): add dedicated Torrent category
This commit is contained in:
+14
-1
@@ -417,7 +417,11 @@ export const initMediaDomains = async () => {
|
||||
}
|
||||
};
|
||||
|
||||
export const categoryForFileName = (fileName: string): DownloadCategory => {
|
||||
export const categoryForFileName = (
|
||||
fileName: string,
|
||||
isTorrent = false
|
||||
): DownloadCategory => {
|
||||
if (isTorrent || fileName.trim().toLowerCase().endsWith('.torrent')) return 'Torrents';
|
||||
const ext = fileName.split('.').pop()?.toLowerCase() || '';
|
||||
if (['mp4', 'mkv', 'avi', 'mov', 'wmv', 'flv', 'webm', 'm4v', 'mpeg', 'mpg', '3gp', 'ts', 'vob'].includes(ext)) return 'Movies';
|
||||
if (['mp3', 'wav', 'aac', 'flac', 'ogg', 'm4a', 'wma', 'alac', 'ape', 'mid', 'midi'].includes(ext)) return 'Musics';
|
||||
@@ -428,6 +432,15 @@ export const categoryForFileName = (fileName: string): DownloadCategory => {
|
||||
return 'Other';
|
||||
};
|
||||
|
||||
export const categoryForDownload = (
|
||||
fileName: string,
|
||||
isTorrent: boolean,
|
||||
existingCategory?: DownloadCategory
|
||||
): DownloadCategory => {
|
||||
if (isTorrent && existingCategory === 'Other') return existingCategory;
|
||||
return categoryForFileName(fileName, isTorrent);
|
||||
};
|
||||
|
||||
export const fileNameFromUrl = (rawUrl: string): string => {
|
||||
try {
|
||||
const url = new URL(rawUrl);
|
||||
|
||||
Reference in New Issue
Block a user