From 1431b57a490769e622fb1e58bf9281e74f8310be Mon Sep 17 00:00:00 2001 From: iPromKnight Date: Mon, 5 Feb 2024 05:17:48 +0000 Subject: [PATCH] extension now ts --- src/node/consumer/src/lib/extension.js | 62 ----------------------- src/node/consumer/src/lib/extension.ts | 62 +++++++++++++++++++++++ src/node/consumer/src/lib/torrent.js | 2 +- src/node/consumer/src/lib/torrentFiles.js | 2 +- 4 files changed, 64 insertions(+), 64 deletions(-) delete mode 100644 src/node/consumer/src/lib/extension.js create mode 100644 src/node/consumer/src/lib/extension.ts diff --git a/src/node/consumer/src/lib/extension.js b/src/node/consumer/src/lib/extension.js deleted file mode 100644 index 6c11617..0000000 --- a/src/node/consumer/src/lib/extension.js +++ /dev/null @@ -1,62 +0,0 @@ -const VIDEO_EXTENSIONS = [ - "3g2", - "3gp", - "avi", - "flv", - "mkv", - "mk3d", - "mov", - "mp2", - "mp4", - "m4v", - "mpe", - "mpeg", - "mpg", - "mpv", - "webm", - "wmv", - "ogm", - "divx" -]; -const SUBTITLE_EXTENSIONS = [ - "aqt", - "gsub", - "jss", - "sub", - "ttxt", - "pjs", - "psb", - "rt", - "smi", - "slt", - "ssf", - "srt", - "ssa", - "ass", - "usf", - "idx", - "vtt" -]; -const DISK_EXTENSIONS = [ - "iso", - "m2ts", - "ts", - "vob" -] - -export function isVideo(filename) { - return isExtension(filename, VIDEO_EXTENSIONS); -} - -export function isSubtitle(filename) { - return isExtension(filename, SUBTITLE_EXTENSIONS); -} - -export function isDisk(filename) { - return isExtension(filename, DISK_EXTENSIONS); -} - -export function isExtension(filename, extensions) { - const extensionMatch = filename.match(/\.(\w{2,4})$/); - return extensionMatch && extensions.includes(extensionMatch[1].toLowerCase()); -} \ No newline at end of file diff --git a/src/node/consumer/src/lib/extension.ts b/src/node/consumer/src/lib/extension.ts new file mode 100644 index 0000000..937dc35 --- /dev/null +++ b/src/node/consumer/src/lib/extension.ts @@ -0,0 +1,62 @@ +const VIDEO_EXTENSIONS: string[] = [ + "3g2", + "3gp", + "avi", + "flv", + "mkv", + "mk3d", + "mov", + "mp2", + "mp4", + "m4v", + "mpe", + "mpeg", + "mpg", + "mpv", + "webm", + "wmv", + "ogm", + "divx" +]; +const SUBTITLE_EXTENSIONS: string[] = [ + "aqt", + "gsub", + "jss", + "sub", + "ttxt", + "pjs", + "psb", + "rt", + "smi", + "slt", + "ssf", + "srt", + "ssa", + "ass", + "usf", + "idx", + "vtt" +]; +const DISK_EXTENSIONS: string[] = [ + "iso", + "m2ts", + "ts", + "vob" +] + +export function isVideo(filename: string): boolean { + return isExtension(filename, VIDEO_EXTENSIONS); +} + +export function isSubtitle(filename: string): boolean { + return isExtension(filename, SUBTITLE_EXTENSIONS); +} + +export function isDisk(filename: string): boolean { + return isExtension(filename, DISK_EXTENSIONS); +} + +export function isExtension(filename: string, extensions: string[]): boolean { + const extensionMatch = filename.match(/\.(\w{2,4})$/); + return extensionMatch !== null && extensions.includes(extensionMatch[1].toLowerCase()); +} \ No newline at end of file diff --git a/src/node/consumer/src/lib/torrent.js b/src/node/consumer/src/lib/torrent.js index 4253052..3a066b3 100644 --- a/src/node/consumer/src/lib/torrent.js +++ b/src/node/consumer/src/lib/torrent.js @@ -1,7 +1,7 @@ import { decode } from 'magnet-uri'; import torrentStream from 'torrent-stream'; import { torrentConfig } from './config.js'; -import {isSubtitle, isVideo} from './extension.js'; +import {isSubtitle, isVideo} from './extension'; export async function torrentFiles(torrent, timeout) { return filesFromTorrentStream(torrent, timeout) diff --git a/src/node/consumer/src/lib/torrentFiles.js b/src/node/consumer/src/lib/torrentFiles.js index 27b8551..3a60556 100644 --- a/src/node/consumer/src/lib/torrentFiles.js +++ b/src/node/consumer/src/lib/torrentFiles.js @@ -3,7 +3,7 @@ import distance from 'jaro-winkler'; import moment from 'moment'; import { parse } from 'parse-torrent-title'; import { metadataConfig } from './config.js'; -import { isDisk } from './extension.js'; +import { isDisk } from './extension'; import { getMetadata, getImdbId, getKitsuId } from './metadata'; import { parseSeriesVideos, isPackTorrent } from './parseHelper'; import * as Promises from './promises';