2024-10-18 02:10:58 +02:00
|
|
|
import IManga from './interfaces/IManga';
|
|
|
|
import { getData } from '../App';
|
|
|
|
|
|
|
|
export class Manga
|
|
|
|
{
|
|
|
|
static async GetAllManga(): Promise<IManga[]> {
|
2024-10-19 21:08:11 +02:00
|
|
|
console.info("Getting all Manga");
|
2024-10-18 02:10:58 +02:00
|
|
|
return getData("http://127.0.0.1:6531/v2/Mangas")
|
|
|
|
.then((json) => {
|
2024-10-19 21:08:11 +02:00
|
|
|
console.info("Got all Manga");
|
2024-10-19 19:52:28 +02:00
|
|
|
const ret = json as IManga[];
|
|
|
|
console.debug(ret);
|
|
|
|
return (ret);
|
2024-10-18 02:10:58 +02:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
static async SearchManga(name: string): Promise<IManga[]> {
|
2024-10-19 21:08:11 +02:00
|
|
|
console.info(`Getting Manga ${name} from all Connectors`);
|
2024-10-18 02:10:58 +02:00
|
|
|
return await getData(`http://127.0.0.1:6531/v2/Manga/Search?title=${name}`)
|
|
|
|
.then((json) => {
|
2024-10-19 21:08:11 +02:00
|
|
|
console.info(`Got Manga ${name}`);
|
2024-10-19 19:52:28 +02:00
|
|
|
const ret = json as IManga[];
|
|
|
|
console.debug(ret);
|
|
|
|
return (ret);
|
2024-10-18 02:10:58 +02:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
static async GetMangaById(internalId: string): Promise<IManga> {
|
2024-10-19 21:08:11 +02:00
|
|
|
console.info(`Getting Manga ${internalId}`);
|
2024-10-18 02:10:58 +02:00
|
|
|
return await getData(`http://127.0.0.1:6531/v2/Manga/${internalId}`)
|
|
|
|
.then((json) => {
|
2024-10-19 21:08:11 +02:00
|
|
|
console.info(`Got Manga ${internalId}`);
|
2024-10-19 19:52:28 +02:00
|
|
|
const ret = json as IManga;
|
|
|
|
console.debug(ret);
|
|
|
|
return (ret);
|
2024-10-18 02:10:58 +02:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
static async GetMangaByIds(internalIds: string[]): Promise<IManga[]> {
|
|
|
|
console.debug(`Getting Mangas ${internalIds.join(",")}`);
|
2024-10-20 02:08:44 +02:00
|
|
|
return await getData(`http://127.0.0.1:6531/v2/Manga?mangaIds=${internalIds.join(",")}`)
|
2024-10-18 02:10:58 +02:00
|
|
|
.then((json) => {
|
|
|
|
console.debug(`Got Manga ${internalIds.join(",")}`);
|
2024-10-19 19:52:28 +02:00
|
|
|
const ret = json as IManga[];
|
|
|
|
console.debug(ret);
|
|
|
|
return (ret);
|
2024-10-18 02:10:58 +02:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2024-10-18 19:43:13 +02:00
|
|
|
static GetMangaCoverUrl(internalId: string): string {
|
2024-10-18 02:10:58 +02:00
|
|
|
console.debug(`Getting Manga Cover-Url ${internalId}`);
|
2024-10-18 19:43:13 +02:00
|
|
|
return `http://127.0.0.1:6531/v2/Manga/${internalId}/Cover`;
|
2024-10-18 02:10:58 +02:00
|
|
|
}
|
|
|
|
}
|