import { HttpClient } from "@angular/common/http"; import { Injectable } from "@angular/core"; import { BehaviorSubject, Observable, map } from "rxjs"; import { MangalibParserService } from "./parsers/rulib/mangalib.parser.service"; import { IRulibChapterResult } from "./parsers/rulib/rulib.chapter.dto"; import { IRulibChaptersResult } from "./parsers/rulib/rulib.chapters.dto"; import { IRulibDetailResult } from "./parsers/rulib/rulib.detail.dto"; import { Datum, IRulibSearchResult } from "./parsers/rulib/rulib.search.dto"; @Injectable({ providedIn: "root" }) export class SearchService { private itemsTerm = new BehaviorSubject([]); currentItemsTerm = this.itemsTerm.asObservable(); constructor( private parser: MangalibParserService, private http: HttpClient, ) {} search(query: string): Observable { return this.parser.searchManga(query).pipe( map((data) => { return data; }), ); } getDetails(slug_url: string): Observable { return this.parser.getDetails(slug_url).pipe( map((data) => { return data; }), ); } getChapters(url: string): Observable { return this.parser.getChapters(url).pipe( map((data) => { return data; }), ); } getChapter(url: string, chapter: string, volume: string): Observable { return this.parser.getChapter(url, chapter, volume).pipe( map((data) => { return data; }), ); } getImageServer() { return this.parser.imageServer; } getImageData(imageUrl: string): Observable { return this.http.get(imageUrl, { responseType: "arraybuffer" }).pipe( map((arrayBuffer: ArrayBuffer) => { return new Uint8Array(arrayBuffer); }), ); } }