Files
MoonTVPlus/src/lib/book.types.ts
T
2026-05-20 01:40:42 +08:00

272 lines
5.6 KiB
TypeScript

export interface BookSourceCapabilities {
searchSupported: boolean;
catalogSupported: boolean;
searchMode: 'opds' | 'template' | 'legado' | 'disabled';
catalogMode: 'navigation' | 'acquisition' | 'flat' | 'legado' | 'disabled';
acquisitionTypes: string[];
lastCheckedAt?: number;
lastError?: string;
}
export interface LegadoRuleSearch {
bookList?: string;
name?: string;
author?: string;
intro?: string;
coverUrl?: string;
bookUrl?: string;
kind?: string;
lastChapter?: string;
checkKeyWord?: string;
wordCount?: string;
}
export type LegadoRuleExplore = LegadoRuleSearch;
export interface LegadoRuleBookInfo {
init?: string;
name?: string;
author?: string;
intro?: string;
coverUrl?: string;
tocUrl?: string;
kind?: string;
lastChapter?: string;
wordCount?: string;
}
export interface LegadoRuleToc {
chapterList?: string;
chapterName?: string;
chapterUrl?: string;
isVip?: string;
isPay?: string;
nextTocUrl?: string;
updateTime?: string;
wordCount?: string;
chapterInfo?: string;
}
export interface LegadoRuleContent {
content?: string;
nextContentUrl?: string;
imageStyle?: string;
sourceRegex?: string;
replaceRegex?: string;
payAction?: string;
}
export interface LegadoBookSourceRule {
bookSourceName?: string;
bookSourceUrl?: string;
bookSourceGroup?: string;
bookSourceType?: number;
customButton?: boolean | unknown;
eventListener?: boolean | unknown;
variable?: string | Record<string, unknown>;
loginUi?: string | unknown;
concurrentRate?: string | number;
respondTime?: number;
lastUpdateTime?: string | number;
enabled?: boolean;
enabledCookieJar?: boolean;
enabledExplore?: boolean;
exploreUrl?: string;
header?: string | Record<string, string>;
jsLib?: string;
loginUrl?: string;
searchUrl?: string;
bookInfoUrl?: string;
bookInfoInit?: string;
bookUrlPattern?: string;
tocUrl?: string;
chapterUrl?: string;
ruleSearch?: LegadoRuleSearch;
ruleExplore?: LegadoRuleExplore;
ruleBookInfo?: LegadoRuleBookInfo;
ruleToc?: LegadoRuleToc;
ruleContent?: LegadoRuleContent;
ruleReview?: unknown;
customOrder?: number;
weight?: number;
}
export interface BookSource {
id: string;
name: string;
type?: 'opds' | 'legado';
url: string;
enabled?: boolean;
authMode?: 'none' | 'basic' | 'header';
username?: string;
password?: string;
headerName?: string;
headerValue?: string;
searchTemplate?: string;
preferFormat?: Array<'epub' | 'pdf'>;
language?: string;
legado?: LegadoBookSourceRule;
capabilities?: BookSourceCapabilities;
}
export interface BookAcquisitionLink {
rel: string;
type: string;
href: string;
title?: string;
isIndirect?: boolean;
}
export interface BookNavLink {
title: string;
href: string;
rel?: string;
type?: string;
}
export interface BookListItem {
id: string;
sourceId: string;
sourceName: string;
title: string;
author?: string;
cover?: string;
summary?: string;
language?: string;
published?: string;
updated?: string;
tags?: string[];
detailHref?: string;
acquisitionLinks: BookAcquisitionLink[];
}
export interface BookDetail extends BookListItem {
publisher?: string;
identifier?: string;
series?: string;
categories?: string[];
navigation?: BookNavLink[];
}
export interface BookCatalogResult {
sourceId: string;
sourceName: string;
title: string;
subtitle?: string;
href: string;
entries: BookListItem[];
navigation: BookNavLink[];
nextHref?: string;
previousHref?: string;
}
export interface BookSearchFailure {
sourceId: string;
sourceName: string;
error: string;
}
export interface BookSearchResult {
results: BookListItem[];
failedSources: BookSearchFailure[];
}
export interface BookLocator {
type: 'epub-cfi' | 'pdf-page' | 'href' | 'chapter';
value: string;
href?: string;
chapterTitle?: string;
}
export interface BookShelfItem {
sourceId: string;
sourceName: string;
bookId: string;
title: string;
author?: string;
cover?: string;
format?: 'epub' | 'pdf' | 'chapters';
detailHref?: string;
acquisitionHref?: string;
progressPercent?: number;
lastReadTime?: number;
lastLocatorType?: BookLocator['type'];
lastLocatorValue?: string;
lastChapterTitle?: string;
saveTime: number;
}
export interface BookReadRecord {
sourceId: string;
sourceName: string;
bookId: string;
title: string;
author?: string;
cover?: string;
format: 'epub' | 'pdf' | 'chapters';
detailHref?: string;
acquisitionHref?: string;
locator: BookLocator;
progressPercent: number;
chapterTitle?: string;
chapterHref?: string;
saveTime: number;
}
export interface BookTtsVoice {
name: string;
shortName: string;
locale: string;
gender?: string;
displayName: string;
}
export interface BookTtsBoundary {
offset: number;
duration: number;
text: string;
}
export interface BookTtsProgress {
sourceId: string;
bookId: string;
chapterHref: string;
chapterTitle?: string;
chunkIndex: number;
charOffset: number;
currentTimeSec?: number;
voice: string;
rate: string;
pitch: string;
volume: string;
saveTime: number;
}
export interface BookReadManifest {
book: BookDetail;
format: 'epub' | 'pdf' | 'chapters';
fileUrl?: string;
chaptersUrl?: string;
acquisitionHref?: string;
cacheKey?: string;
coverUrl?: string;
lastRecord?: BookReadRecord | null;
}
export interface BookChapter {
id: string;
title: string;
href: string;
order: number;
}
export interface BookChapterContent {
id: string;
title: string;
href: string;
content: string;
nextHref?: string;
previousHref?: string;
}