Restore and persist the package-based link collector with progressive metadata, bounded high-volume updates, safe hydration, visible selection, and complete localization. Harden download controls, snapshot ordering, history pagination, statistics recovery, settings saves, backup imports, notification persistence, and Windows storage races with regression coverage.
173 lines
6.3 KiB
TypeScript
173 lines
6.3 KiB
TypeScript
import path from "node:path";
|
|
import os from "node:os";
|
|
import { AppSettings } from "../shared/types";
|
|
import { getProviderUsageDayKey } from "../shared/provider-daily-limits";
|
|
import packageJson from "../../package.json";
|
|
import { resolveRuntimeAppVersion } from "./app-version";
|
|
|
|
export const APP_NAME = "Multi Debrid Downloader";
|
|
export const APP_VERSION: string = resolveRuntimeAppVersion(packageJson.version);
|
|
export const API_BASE_URL = "https://api.real-debrid.com/rest/1.0";
|
|
|
|
export const DCRYPT_UPLOAD_URL = "https://dcrypt.it/decrypt/upload";
|
|
export const DCRYPT_PASTE_URL = "https://dcrypt.it/decrypt/paste";
|
|
export const DLC_SERVICE_URL = "https://service.jdownloader.org/dlcrypt/service.php?srcType=dlc&destType=pylo&data={KEY}";
|
|
export const DLC_AES_KEY = Buffer.from("cb99b5cbc24db398", "utf8");
|
|
export const DLC_AES_IV = Buffer.from("9bc24cb995cb8db3", "utf8");
|
|
|
|
export const REQUEST_RETRIES = 3;
|
|
export const CHUNK_SIZE = 512 * 1024;
|
|
|
|
export const WRITE_BUFFER_SIZE = 512 * 1024;
|
|
export const WRITE_FLUSH_TIMEOUT_MS = 2000;
|
|
export const ALLOCATION_UNIT_SIZE = 4096;
|
|
export const STREAM_HIGH_WATER_MARK = 512 * 1024;
|
|
export const DISK_BUSY_THRESHOLD_MS = 300;
|
|
export const DISK_BUSY_STATUS_THRESHOLD_MS = 500;
|
|
|
|
export const SAMPLE_DIR_NAMES = new Set(["sample", "samples"]);
|
|
export const SAMPLE_VIDEO_EXTENSIONS = new Set([".mkv", ".mp4", ".avi", ".mov", ".wmv", ".m4v", ".ts", ".m2ts", ".webm"]);
|
|
export const LINK_ARTIFACT_EXTENSIONS = new Set([".url", ".webloc", ".dlc", ".rsdf", ".ccf"]);
|
|
export const SAMPLE_TOKEN_RE = /(^|[._\-\s])sample([._\-\s]|$)/i;
|
|
|
|
export const ARCHIVE_TEMP_EXTENSIONS = new Set([".rar", ".zip", ".7z", ".tmp", ".part", ".tar", ".gz", ".bz2", ".xz", ".rev"]);
|
|
export const RAR_SPLIT_RE = /\.r\d{2,3}$/i;
|
|
|
|
export const MAX_MANIFEST_FILE_BYTES = 5 * 1024 * 1024;
|
|
export const MAX_LINK_ARTIFACT_BYTES = 256 * 1024;
|
|
export const SPEED_WINDOW_SECONDS = 1;
|
|
export const CLIPBOARD_POLL_INTERVAL_MS = 2000;
|
|
|
|
export const DEFAULT_UPDATE_REPO = "Sucukdeluxe/Multi-Debrid-Downloader";
|
|
export const ONLINE_BACKUP_API_URL = "https://downloader.24-music.de/backup-api";
|
|
|
|
export function defaultSettings(): AppSettings {
|
|
const baseDir = path.join(os.homedir(), "Desktop", "Multi-Debrid-Downloader");
|
|
return {
|
|
language: "en",
|
|
token: "",
|
|
realDebridUseWebLogin: false,
|
|
realDebridApiTokens: "",
|
|
realDebridWebAccountIds: [],
|
|
realDebridDisabledAccountIds: [],
|
|
realDebridAccountDailyLimitBytes: {},
|
|
realDebridAccountDailyUsageBytes: {},
|
|
realDebridAccountTotalUsageBytes: {},
|
|
megaLogin: "",
|
|
megaPassword: "",
|
|
megaCredentials: "",
|
|
megaDebridApiCredentials: "",
|
|
megaDebridWebCredentials: "",
|
|
megaDebridApiEnabled: false,
|
|
megaDebridWebEnabled: false,
|
|
megaDebridPreferApi: true,
|
|
bestToken: "",
|
|
bestDebridUseWebLogin: false,
|
|
allDebridToken: "",
|
|
allDebridUseWebLogin: false,
|
|
deepbridApiKey: "",
|
|
ddownloadLogin: "",
|
|
ddownloadPassword: "",
|
|
oneFichierApiKey: "",
|
|
debridLinkApiKeys: "",
|
|
debridLinkDisabledKeyIds: [],
|
|
linkSnappyLogin: "",
|
|
linkSnappyPassword: "",
|
|
archivePasswordList: "",
|
|
rememberToken: true,
|
|
providerOrder: ["realdebrid", "megadebrid-api", "bestdebrid"],
|
|
providerPrimary: "realdebrid",
|
|
providerSecondary: "megadebrid-api",
|
|
providerTertiary: "bestdebrid",
|
|
autoProviderFallback: true,
|
|
outputDir: baseDir,
|
|
packageName: "",
|
|
autoExtract: true,
|
|
autoRename4sf4sj: false,
|
|
keepGermanAudioOnly: false,
|
|
germanAudioMode: "tag",
|
|
extractDir: path.join(baseDir, "_entpackt"),
|
|
collectMkvToLibrary: false,
|
|
mkvLibraryDir: path.join(baseDir, "_mkv"),
|
|
createExtractSubfolder: true,
|
|
hybridExtract: true,
|
|
cleanupMode: "none",
|
|
extractConflictMode: "overwrite",
|
|
removeLinkFilesAfterExtract: false,
|
|
removeSamplesAfterExtract: false,
|
|
enableIntegrityCheck: true,
|
|
autoResumeOnStart: true,
|
|
autoReconnect: false,
|
|
reconnectWaitSeconds: 45,
|
|
completedCleanupPolicy: "never",
|
|
maxParallel: 4,
|
|
maxParallelExtract: 2,
|
|
retryLimit: 0,
|
|
speedLimitEnabled: false,
|
|
speedLimitKbps: 0,
|
|
speedLimitMode: "global",
|
|
updateRepo: DEFAULT_UPDATE_REPO,
|
|
autoUpdateCheck: true,
|
|
clipboardWatch: false,
|
|
minimizeToTray: false,
|
|
theme: "dark" as const,
|
|
themePreference: "dark" as const,
|
|
logStorageLocation: "appdata",
|
|
collapseNewPackages: true,
|
|
animatePackageDisclosure: true,
|
|
historyRetentionMode: "permanent",
|
|
historyMaxEntries: 500,
|
|
historyMaxAgeDays: 0,
|
|
accountListShowDetailedDebridLinkKeys: false,
|
|
autoSortPackagesByProgress: false,
|
|
autoSkipExtracted: false,
|
|
hideExtractedItems: true,
|
|
confirmDeleteSelection: true,
|
|
backupIncludeDownloads: false,
|
|
backupIncludeRemoteDiagnostics: false,
|
|
notifyUrl: "",
|
|
notifyMention: "",
|
|
notifyOnPackageCompleted: false,
|
|
notifyOnPackageFailed: false,
|
|
notifyOnRunFinished: false,
|
|
notifyPackageSuccessMode: "digest",
|
|
notifyOnRemainingBelow: false,
|
|
notifyRemainingThresholdGb: 50,
|
|
notifyOnDownloadStall: false,
|
|
notifyStallAfterSeconds: 90,
|
|
notifyStallCooldownMinutes: 10,
|
|
notifyOnDownloadRecovery: true,
|
|
totalDownloadedAllTime: 0,
|
|
totalCompletedFilesAllTime: 0,
|
|
totalRuntimeAllTimeMs: 0,
|
|
bandwidthSchedules: [],
|
|
columnOrder: ["name", "size", "progress", "hoster", "account", "prio", "status", "speed", "availability"],
|
|
columnOrderVersion: 3,
|
|
extractCpuPriority: "high",
|
|
autoExtractWhenStopped: true,
|
|
disabledProviders: [],
|
|
hosterRouting: {},
|
|
providerDailyLimitBytes: {},
|
|
providerDailyUsageBytes: {},
|
|
providerTotalUsageBytes: {},
|
|
debridLinkApiKeyDailyLimitBytes: {},
|
|
debridLinkApiKeyDailyUsageBytes: {},
|
|
debridLinkApiKeyTotalUsageBytes: {},
|
|
megaDebridDisabledAccountIds: [],
|
|
megaDebridApiDisabledAccountIds: [],
|
|
megaDebridWebDisabledAccountIds: [],
|
|
megaDebridAccountDailyLimitBytes: {},
|
|
megaDebridAccountDailyUsageBytes: {},
|
|
megaDebridAccountTotalUsageBytes: {},
|
|
debridAccountStatuses: {},
|
|
providerDailyUsageDay: getProviderUsageDayKey(),
|
|
dailyStartEnabled: false,
|
|
dailyStartMinuteOfDay: 0,
|
|
dailyStartFirstLocalDate: "",
|
|
dailyStartLastHandledLocalDate: "",
|
|
dailyStartPendingLocalDate: "",
|
|
dailyStartLastOutcome: "",
|
|
scheduledStartEpochMs: 0
|
|
};
|
|
}
|