refactor: extract shared interfaces to src/types.ts
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
fbcf3935d0
commit
424b312551
65
src/main.ts
65
src/main.ts
@ -5,6 +5,7 @@ import { spawn, ChildProcess, execSync, exec, spawnSync } from 'child_process';
|
|||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import { autoUpdater } from 'electron-updater';
|
import { autoUpdater } from 'electron-updater';
|
||||||
import { compareUpdateVersions, isNewerUpdateVersion, normalizeUpdateVersion } from './update-version-utils';
|
import { compareUpdateVersions, isNewerUpdateVersion, normalizeUpdateVersion } from './update-version-utils';
|
||||||
|
import { CustomClip, MergeGroupItem, MergeGroup, QueueItem, DownloadProgress, DownloadResult } from './types';
|
||||||
|
|
||||||
// ==========================================
|
// ==========================================
|
||||||
// CONFIG & CONSTANTS
|
// CONFIG & CONSTANTS
|
||||||
@ -156,57 +157,6 @@ interface VOD {
|
|||||||
stream_id: string;
|
stream_id: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface CustomClip {
|
|
||||||
startSec: number;
|
|
||||||
durationSec: number;
|
|
||||||
startPart: number;
|
|
||||||
filenameFormat: 'simple' | 'timestamp' | 'template';
|
|
||||||
filenameTemplate?: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface MergeGroupItem {
|
|
||||||
url: string;
|
|
||||||
title: string;
|
|
||||||
date: string;
|
|
||||||
streamer: string;
|
|
||||||
duration_str: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface MergeGroup {
|
|
||||||
items: MergeGroupItem[];
|
|
||||||
mergePhase: 'downloading' | 'merging' | 'splitting' | 'cleanup' | 'done';
|
|
||||||
currentItemIndex: number;
|
|
||||||
downloadedFiles: Record<number, string>;
|
|
||||||
mergedFile?: string;
|
|
||||||
splitFiles?: string[];
|
|
||||||
totalDurationSec?: number;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface QueueItem {
|
|
||||||
id: string;
|
|
||||||
title: string;
|
|
||||||
url: string;
|
|
||||||
date: string;
|
|
||||||
streamer: string;
|
|
||||||
duration_str: string;
|
|
||||||
status: 'pending' | 'downloading' | 'paused' | 'completed' | 'error';
|
|
||||||
progress: number;
|
|
||||||
currentPart?: number;
|
|
||||||
totalParts?: number;
|
|
||||||
speed?: string;
|
|
||||||
eta?: string;
|
|
||||||
downloadedBytes?: number;
|
|
||||||
totalBytes?: number;
|
|
||||||
last_error?: string;
|
|
||||||
customClip?: CustomClip;
|
|
||||||
mergeGroup?: MergeGroup;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface DownloadResult {
|
|
||||||
success: boolean;
|
|
||||||
error?: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface PreflightChecks {
|
interface PreflightChecks {
|
||||||
internet: boolean;
|
internet: boolean;
|
||||||
streamlink: boolean;
|
streamlink: boolean;
|
||||||
@ -223,19 +173,6 @@ interface PreflightResult {
|
|||||||
timestamp: string;
|
timestamp: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface DownloadProgress {
|
|
||||||
id: string;
|
|
||||||
progress: number;
|
|
||||||
speed: string;
|
|
||||||
speedBytesPerSec?: number;
|
|
||||||
eta: string;
|
|
||||||
status: string;
|
|
||||||
currentPart?: number;
|
|
||||||
totalParts?: number;
|
|
||||||
downloadedBytes?: number;
|
|
||||||
totalBytes?: number;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface VideoInfo {
|
interface VideoInfo {
|
||||||
duration: number;
|
duration: number;
|
||||||
width: number;
|
width: number;
|
||||||
|
|||||||
@ -1,62 +1,7 @@
|
|||||||
import { contextBridge, ipcRenderer } from 'electron';
|
import { contextBridge, ipcRenderer } from 'electron';
|
||||||
|
import { CustomClip, MergeGroupItem, MergeGroup, QueueItem, DownloadProgress } from './types';
|
||||||
|
|
||||||
// Types
|
// Types
|
||||||
interface CustomClip {
|
|
||||||
startSec: number;
|
|
||||||
durationSec: number;
|
|
||||||
startPart: number;
|
|
||||||
filenameFormat: 'simple' | 'timestamp' | 'template';
|
|
||||||
filenameTemplate?: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface MergeGroupItem {
|
|
||||||
url: string;
|
|
||||||
title: string;
|
|
||||||
date: string;
|
|
||||||
streamer: string;
|
|
||||||
duration_str: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface MergeGroup {
|
|
||||||
items: MergeGroupItem[];
|
|
||||||
mergePhase: 'downloading' | 'merging' | 'splitting' | 'cleanup' | 'done';
|
|
||||||
currentItemIndex: number;
|
|
||||||
downloadedFiles: Record<number, string>;
|
|
||||||
mergedFile?: string;
|
|
||||||
splitFiles?: string[];
|
|
||||||
totalDurationSec?: number;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface QueueItem {
|
|
||||||
id: string;
|
|
||||||
title: string;
|
|
||||||
url: string;
|
|
||||||
date: string;
|
|
||||||
streamer: string;
|
|
||||||
duration_str: string;
|
|
||||||
status: 'pending' | 'downloading' | 'paused' | 'completed' | 'error';
|
|
||||||
progress: number;
|
|
||||||
currentPart?: number;
|
|
||||||
totalParts?: number;
|
|
||||||
speed?: string;
|
|
||||||
eta?: string;
|
|
||||||
customClip?: CustomClip;
|
|
||||||
mergeGroup?: MergeGroup;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface DownloadProgress {
|
|
||||||
id: string;
|
|
||||||
progress: number;
|
|
||||||
speed: string;
|
|
||||||
speedBytesPerSec?: number;
|
|
||||||
eta: string;
|
|
||||||
status: string;
|
|
||||||
currentPart?: number;
|
|
||||||
totalParts?: number;
|
|
||||||
downloadedBytes?: number;
|
|
||||||
totalBytes?: number;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface RuntimeMetricsSnapshot {
|
interface RuntimeMetricsSnapshot {
|
||||||
cacheHits: number;
|
cacheHits: number;
|
||||||
cacheMisses: number;
|
cacheMisses: number;
|
||||||
|
|||||||
63
src/types.ts
Normal file
63
src/types.ts
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
export interface CustomClip {
|
||||||
|
startSec: number;
|
||||||
|
durationSec: number;
|
||||||
|
startPart: number;
|
||||||
|
filenameFormat: 'simple' | 'timestamp' | 'template';
|
||||||
|
filenameTemplate?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface MergeGroupItem {
|
||||||
|
url: string;
|
||||||
|
title: string;
|
||||||
|
date: string;
|
||||||
|
streamer: string;
|
||||||
|
duration_str: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface MergeGroup {
|
||||||
|
items: MergeGroupItem[];
|
||||||
|
mergePhase: 'downloading' | 'merging' | 'splitting' | 'cleanup' | 'done';
|
||||||
|
currentItemIndex: number;
|
||||||
|
downloadedFiles: Record<number, string>;
|
||||||
|
mergedFile?: string;
|
||||||
|
splitFiles?: string[];
|
||||||
|
totalDurationSec?: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface QueueItem {
|
||||||
|
id: string;
|
||||||
|
title: string;
|
||||||
|
url: string;
|
||||||
|
date: string;
|
||||||
|
streamer: string;
|
||||||
|
duration_str: string;
|
||||||
|
status: 'pending' | 'downloading' | 'paused' | 'completed' | 'error';
|
||||||
|
progress: number;
|
||||||
|
currentPart?: number;
|
||||||
|
totalParts?: number;
|
||||||
|
speed?: string;
|
||||||
|
eta?: string;
|
||||||
|
downloadedBytes?: number;
|
||||||
|
totalBytes?: number;
|
||||||
|
last_error?: string;
|
||||||
|
customClip?: CustomClip;
|
||||||
|
mergeGroup?: MergeGroup;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface DownloadProgress {
|
||||||
|
id: string;
|
||||||
|
progress: number;
|
||||||
|
speed: string;
|
||||||
|
speedBytesPerSec?: number;
|
||||||
|
eta: string;
|
||||||
|
status: string;
|
||||||
|
currentPart?: number;
|
||||||
|
totalParts?: number;
|
||||||
|
downloadedBytes?: number;
|
||||||
|
totalBytes?: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface DownloadResult {
|
||||||
|
success: boolean;
|
||||||
|
error?: string;
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user