Files
beStream/src/types/index.ts
2025-12-14 18:45:49 +01:00

241 lines
4.6 KiB
TypeScript

// YTS API Types
export interface Movie {
id: number;
url: string;
imdb_code: string;
title: string;
title_english: string;
title_long: string;
slug: string;
year: number;
rating: number;
runtime: number;
genres: string[];
summary: string;
description_full: string;
synopsis: string;
yt_trailer_code: string;
language: string;
mpa_rating: string;
background_image: string;
background_image_original: string;
small_cover_image: string;
medium_cover_image: string;
large_cover_image: string;
state: string;
torrents: Torrent[];
date_uploaded: string;
date_uploaded_unix: number;
}
export interface MovieDetails extends Movie {
download_count: number;
like_count: number;
description_intro: string;
cast?: CastMember[];
images?: MovieImages;
}
export interface Torrent {
url: string;
hash: string;
quality: string;
type: string;
is_repack: string;
video_codec: string;
bit_depth: string;
audio_channels: string;
seeds: number;
peers: number;
size: string;
size_bytes: number;
date_uploaded: string;
date_uploaded_unix: number;
}
export interface CastMember {
name: string;
character_name: string;
url_small_image: string;
imdb_code: string;
}
export interface MovieImages {
background_image: string;
background_image_original: string;
small_cover_image: string;
medium_cover_image: string;
large_cover_image: string;
}
export interface ParentalGuide {
type: string;
parental_guide_text: string;
}
// API Response Types
export interface ApiResponse<T> {
status: string;
status_message: string;
data: T;
}
export interface ListMoviesData {
movie_count: number;
limit: number;
page_number: number;
movies: Movie[];
}
export interface MovieDetailsData {
movie: MovieDetails;
}
export interface MovieSuggestionsData {
movie_count: number;
movies: Movie[];
}
export interface ParentalGuidesData {
parental_guides: ParentalGuide[];
}
// API Request Types
export interface ListMoviesParams {
limit?: number;
page?: number;
quality?: '480p' | '720p' | '1080p' | '1080p.x265' | '2160p' | '3D';
minimum_rating?: number;
query_term?: string;
genre?: string;
sort_by?: 'title' | 'year' | 'rating' | 'peers' | 'seeds' | 'download_count' | 'like_count' | 'date_added';
order_by?: 'desc' | 'asc';
with_rt_ratings?: boolean;
}
export interface MovieDetailsParams {
movie_id?: number;
imdb_id?: string;
with_images?: boolean;
with_cast?: boolean;
}
// App State Types
export interface WatchlistItem {
id: number;
movieId: number;
movie: Movie;
addedAt: Date;
}
export interface HistoryItem {
id: number;
movieId: number;
movie: Movie;
watchedAt: Date;
progress: number;
duration: number;
completed: boolean;
}
export interface DownloadItem {
id: string;
movieId: number;
movie: Movie;
torrent: Torrent;
progress: number;
downloadSpeed: number;
uploadSpeed: number;
peers: number;
status: 'queued' | 'downloading' | 'paused' | 'completed' | 'error';
filePath?: string;
startedAt: Date;
completedAt?: Date;
error?: string;
}
export interface Subtitle {
id: string;
language: string;
languageName: string;
url: string;
format: string;
}
export interface AppSettings {
preferredQuality: string;
preferredLanguage: string;
autoPlay: boolean;
notifications: boolean;
downloadPath: string;
maxConcurrentDownloads: number;
theme: 'dark' | 'light' | 'system';
}
// Torrent Types
export interface TorrentInfo {
infoHash: string;
magnetURI: string;
name: string;
progress: number;
downloadSpeed: number;
uploadSpeed: number;
numPeers: number;
downloaded: number;
uploaded: number;
length: number;
ready: boolean;
files: TorrentFile[];
}
export interface TorrentFile {
name: string;
path: string;
length: number;
progress: number;
selected: boolean;
}
// Genre list
export const GENRES = [
'Action',
'Adventure',
'Animation',
'Biography',
'Comedy',
'Crime',
'Documentary',
'Drama',
'Family',
'Fantasy',
'Film-Noir',
'History',
'Horror',
'Music',
'Musical',
'Mystery',
'Romance',
'Sci-Fi',
'Short',
'Sport',
'Thriller',
'War',
'Western',
] as const;
export type Genre = typeof GENRES[number];
// Tracker list for magnet links
export const TRACKERS = [
'udp://open.demonii.com:1337/announce',
'udp://tracker.openbittorrent.com:80',
'udp://tracker.coppersurfer.tk:6969',
'udp://glotorrents.pw:6969/announce',
'udp://tracker.opentrackr.org:1337/announce',
'udp://torrent.gresille.org:80/announce',
'udp://p4p.arenabg.com:1337',
'udp://tracker.leechers-paradise.org:6969',
];