feat: initial version of reader

This commit is contained in:
2024-07-06 00:53:46 +03:00
parent 2660aef473
commit 55e729422b
12 changed files with 283 additions and 9 deletions

View File

@@ -2,6 +2,8 @@ import { HttpClient } from "@angular/common/http";
import { Injectable } from "@angular/core";
import { Observable, catchError, map, throwError } from "rxjs";
import { ESiteUrls } from "../urls";
import { IRulibChapterResult } from "./rulib.chapter.dto";
import { IRulibChaptersResult } from "./rulib.chapters.dto";
import { IRulibDetailResult } from "./rulib.detail.dto";
import { IRulibSearchResult } from "./rulib.search.dto";
@@ -13,6 +15,10 @@ export class LibSocialParserService {
private readonly url = ESiteUrls.LIB_SOCIAL;
constructor(private readonly http: HttpClient) {}
get imageServer() {
return "https://img33.imgslib.link";
}
searchManga(query: string): Observable<IRulibSearchResult> {
return this.http
.get(`${this.url}/api/manga?fields[]=rate_avg&fields[]=rate&q=${query}&site_id[]=1`)
@@ -40,4 +46,24 @@ export class LibSocialParserService {
}),
);
}
getChapters(url: string): Observable<IRulibChaptersResult> {
return this.http.get(`${this.url}/api/manga/${url}/chapters`).pipe(
map((data) => {
return data as IRulibChaptersResult;
}),
catchError((error) => {
return throwError(() => `Now found ${error}`);
}),
);
}
getChapter(url: string, chapter: string, volume: string): Observable<IRulibChapterResult> {
return this.http
.get(`${this.url}/api/manga/${url}/chapter?number=${chapter}&volume=${volume}`)
.pipe(
map((data) => data as IRulibChapterResult),
catchError((error) => throwError(() => `Now found ${error}`)),
);
}
}