1
1
mirror of https://github.com/neosubhamoy/neodlp.git synced 2026-02-04 17:42:22 +05:30

refactor: separated download functions

This commit is contained in:
2025-11-16 23:11:17 +05:30
Verified
parent 6028037e74
commit 45cfdc00de
8 changed files with 1231 additions and 1173 deletions

View File

@@ -3,20 +3,38 @@ import { DownloadConfiguration } from '@/types/settings';
import { RawVideoInfo } from '@/types/video';
import { createContext, useContext } from 'react';
export interface FetchVideoMetadataParams {
url: string;
formatId?: string;
playlistIndex?: string;
selectedSubtitles?: string | null;
resumeState?: DownloadState;
downloadConfig?: DownloadConfiguration;
};
export interface StartDownloadParams {
url: string;
selectedFormat: string;
downloadConfig: DownloadConfiguration;
selectedSubtitles?: string | null;
resumeState?: DownloadState;
playlistItems?: string;
};
interface AppContextType {
fetchVideoMetadata: (url: string, formatId?: string, playlistIndex?: string, selectedSubtitles?: string | null, resumeState?: DownloadState, downloadConfig?: DownloadConfiguration) => Promise<RawVideoInfo | null>;
startDownload: (url: string, selectedFormat: string, downloadConfig: DownloadConfiguration, selectedSubtitles?: string | null, resumeState?: DownloadState, playlistItems?: string) => Promise<void>;
pauseDownload: (state: DownloadState) => Promise<void>;
resumeDownload: (state: DownloadState) => Promise<void>;
cancelDownload: (state: DownloadState) => Promise<void>;
fetchVideoMetadata: (params: FetchVideoMetadataParams) => Promise<RawVideoInfo | null>;
startDownload: (params: StartDownloadParams) => Promise<void>;
pauseDownload: (state: DownloadState) => Promise<void>;
resumeDownload: (state: DownloadState) => Promise<void>;
cancelDownload: (state: DownloadState) => Promise<void>;
}
export const AppContext = createContext<AppContextType>({
fetchVideoMetadata: async () => (null),
startDownload: async () => {},
pauseDownload: async () => {},
resumeDownload: async () => {},
cancelDownload: async () => {}
fetchVideoMetadata: async () => (null),
startDownload: async () => {},
pauseDownload: async () => {},
resumeDownload: async () => {},
cancelDownload: async () => {}
});
export const useAppContext = () => useContext(AppContext);