2024-10-18 02:10:58 +02:00
|
|
|
import IManga from './interfaces/IManga';
|
|
|
|
import { getData } from '../App';
|
|
|
|
|
2024-10-22 18:51:34 +02:00
|
|
|
export default class Manga
|
2024-10-18 02:10:58 +02:00
|
|
|
{
|
2024-10-20 20:12:27 +02:00
|
|
|
static async GetAllManga(apiUri: string): Promise<IManga[]> {
|
2024-10-20 20:16:32 +02:00
|
|
|
//console.info("Getting all Manga");
|
2024-10-20 20:12:27 +02:00
|
|
|
return getData(`${apiUri}/v2/Mangas`)
|
2024-10-18 02:10:58 +02:00
|
|
|
.then((json) => {
|
2024-10-20 20:16:32 +02:00
|
|
|
//console.info("Got all Manga");
|
2024-10-19 19:52:28 +02:00
|
|
|
const ret = json as IManga[];
|
2024-10-20 20:12:27 +02:00
|
|
|
//console.debug(ret);
|
2024-10-19 19:52:28 +02:00
|
|
|
return (ret);
|
2024-10-18 02:10:58 +02:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2024-10-20 20:12:27 +02:00
|
|
|
static async SearchManga(apiUri: string, name: string): Promise<IManga[]> {
|
2024-10-20 20:16:32 +02:00
|
|
|
//console.info(`Getting Manga ${name} from all Connectors`);
|
2024-10-20 20:12:27 +02:00
|
|
|
return await getData(`${apiUri}/v2/Manga/Search?title=${name}`)
|
2024-10-18 02:10:58 +02:00
|
|
|
.then((json) => {
|
2024-10-20 20:16:32 +02:00
|
|
|
//console.info(`Got Manga ${name}`);
|
2024-10-19 19:52:28 +02:00
|
|
|
const ret = json as IManga[];
|
2024-10-20 20:12:27 +02:00
|
|
|
//console.debug(ret);
|
2024-10-19 19:52:28 +02:00
|
|
|
return (ret);
|
2024-10-18 02:10:58 +02:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2024-10-20 20:12:27 +02:00
|
|
|
static async GetMangaById(apiUri: string, internalId: string): Promise<IManga> {
|
2024-10-20 20:16:32 +02:00
|
|
|
//console.info(`Getting Manga ${internalId}`);
|
2024-10-20 20:12:27 +02:00
|
|
|
return await getData(`${apiUri}/v2/Manga/${internalId}`)
|
2024-10-18 02:10:58 +02:00
|
|
|
.then((json) => {
|
2024-10-20 20:16:32 +02:00
|
|
|
//console.info(`Got Manga ${internalId}`);
|
2024-10-19 19:52:28 +02:00
|
|
|
const ret = json as IManga;
|
2024-10-20 20:12:27 +02:00
|
|
|
//console.debug(ret);
|
2024-10-19 19:52:28 +02:00
|
|
|
return (ret);
|
2024-10-18 02:10:58 +02:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2024-10-20 20:12:27 +02:00
|
|
|
static async GetMangaByIds(apiUri: string, internalIds: string[]): Promise<IManga[]> {
|
2024-10-20 20:16:32 +02:00
|
|
|
//console.debug(`Getting Mangas ${internalIds.join(",")}`);
|
2024-10-20 20:12:27 +02:00
|
|
|
return await getData(`${apiUri}/v2/Manga?mangaIds=${internalIds.join(",")}`)
|
2024-10-18 02:10:58 +02:00
|
|
|
.then((json) => {
|
2024-10-20 20:16:32 +02:00
|
|
|
//console.debug(`Got Manga ${internalIds.join(",")}`);
|
2024-10-19 19:52:28 +02:00
|
|
|
const ret = json as IManga[];
|
2024-10-20 20:12:27 +02:00
|
|
|
//console.debug(ret);
|
2024-10-19 19:52:28 +02:00
|
|
|
return (ret);
|
2024-10-18 02:10:58 +02:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2024-10-31 21:40:01 +01:00
|
|
|
static GetMangaCoverUrl(apiUri: string, internalId: string, ref: HTMLElement): string {
|
2024-10-20 20:16:32 +02:00
|
|
|
//console.debug(`Getting Manga Cover-Url ${internalId}`);
|
2024-10-31 21:59:41 +01:00
|
|
|
return `${apiUri}/v2/Manga/${internalId}/Cover?dimensions=${ref.clientWidth*1.5}x${ref.clientHeight*1.5}`;
|
2024-10-18 02:10:58 +02:00
|
|
|
}
|
|
|
|
}
|