Skip to content
This repository was archived by the owner on Nov 20, 2021. It is now read-only.

Commit e2150c2

Browse files
committed
Fix typos and make it working again
1 parent 6ef9877 commit e2150c2

File tree

3 files changed

+24
-65
lines changed

3 files changed

+24
-65
lines changed

‎src/CatManga/CatManga.ts

+2-16
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const BASE = "https://catmanga.org"
1515

1616
export const CatMangaInfo: SourceInfo = {
1717
icon: "icon.png",
18-
version: "1.2.3",
18+
version: "1.2.4",
1919
name: "CatManga",
2020
author: "PythonCoderAS",
2121
authorWebsite: "https://github.com/PythonCoderAS",
@@ -40,16 +40,6 @@ export class CatManga extends Source {
4040

4141
async getHomePageSections(sectionCallback: (section: HomeSection) => void): Promise<void> {
4242
const $ = await this.getHomePageData()
43-
sectionCallback(createHomeSection({
44-
id: "featured",
45-
title: "Featured",
46-
items: this.parser.parseFeatured($, BASE)
47-
}))
48-
sectionCallback(createHomeSection({
49-
id: "latest",
50-
title: "Latest",
51-
items: this.getLatest($)
52-
}))
5343
sectionCallback(createHomeSection({
5444
id: "all",
5545
items: (await this.getWebsiteMangaDirectory(null)).results,
@@ -66,13 +56,9 @@ export class CatManga extends Source {
6656
return this.cheerio.load(response.data);
6757
}
6858

69-
getLatest($: CheerioStatic){
70-
return this.parser.parseTileList($, "latestChapterListView", "latestChapterView");
71-
}
72-
7359
async getWebsiteMangaDirectory(metadata: any): Promise<PagedResults> {
7460
return createPagedResults({
75-
results: this.parser.parseTileList(await this.getHomePageData(), "allseries")
61+
results: this.parser.parseHomeTiles(await this.getHomePageData(), BASE)
7662
});
7763
}
7864

‎src/CatManga/CatMangaParser.ts

+21-48
Original file line numberDiff line numberDiff line change
@@ -8,55 +8,28 @@ export class CatMangaParser {
88
})
99
}
1010

11-
parseTileList($: CheerioStatic, className: string, className2: string | null = null) {
12-
if (className2 === null){
13-
className2 = className;
14-
}
15-
const mangaTiles: MangaTile[] = [];
16-
$(`div[class^=${className}_grid] *[class^=${className2}_element]`).map((index, element) => {
17-
const linkId = element.attribs["href"];
18-
if (linkId) {
19-
const tile: MangaTile = {
20-
id: linkId.replace(`/series/`, "").split("/")[0],
21-
title: createIconText({
22-
text: this.decodeHTMLEntity($("p", element).first().text().trim())
23-
}),
24-
image: $("img", element).attr("src") || ""
25-
}
26-
if ($("p", element).length > 1){
27-
tile.primaryText = createIconText({
28-
text: this.decodeHTMLEntity($("p", element).last().text().trim())
29-
});
30-
}
31-
mangaTiles.push(createMangaTile(tile));
32-
}
33-
})
34-
return mangaTiles;
35-
}
36-
37-
parseFeatured($: CheerioStatic, base: string){
38-
const seen: string[] = [];
11+
parseHomeTiles($: CheerioStatic, base: string){
3912
const mangaTiles: MangaTile[] = [];
40-
$("ul.slider li.slide").map((index, element) => {
41-
const link = $("a", element);
42-
const linkId = link.attr("href")
43-
if (linkId){
44-
const id = linkId.replace(`/series/`, "").split("/")[0];
45-
if (!seen.includes(id)){
46-
seen.push(id);
47-
mangaTiles.push(createMangaTile({
48-
id: id,
49-
title: createIconText({
50-
text: this.decodeHTMLEntity($("h1", element).first().text().trim())
51-
}),
52-
image: base + $("img", element).attr("src") || "",
53-
primaryText: createIconText({
54-
text: this.decodeHTMLEntity($("div p", $("a", element).parent()).first().text().trim())
55-
})
56-
}))
13+
const json = JSON.parse($("script#__NEXT_DATA__").html() || "{}");
14+
if (json) {
15+
const props = json.props;
16+
if (props) {
17+
const pageProps = props.pageProps;
18+
if (pageProps) {
19+
const series = pageProps.series;
20+
for (let i = 0; i < series.length; i++) {
21+
const item = series[i];
22+
mangaTiles.push(createMangaTile({
23+
id: item.series_id,
24+
image: item.cover_art.source,
25+
title: createIconText({
26+
text: this.decodeHTMLEntity(item.title)
27+
})
28+
}))
29+
}
5730
}
5831
}
59-
})
32+
}
6033
return mangaTiles;
6134
}
6235

@@ -138,7 +111,7 @@ export class CatMangaParser {
138111
const pageProps = props.pageProps;
139112
if (pageProps){
140113
const series = pageProps.series;
141-
if (series && series.genres && (series.genres.length || 0) > 0 && series.title && series.decription && series.status && series.cover_art && series.conver_art.source){
114+
if (series && series.genres && (series.genres.length || 0) > 0 && series.title && series.description && series.status && series.cover_art && series.cover_art.source){
142115
let titles = [series.title]
143116
const covers = [];
144117
const tags = []
@@ -189,7 +162,7 @@ export class CatMangaParser {
189162
}
190163
}
191164
}
192-
return this.parseMangaFallback($, mangaId);
165+
throw new Error("Bug!")
193166
}
194167

195168
parseMangaFallback($: CheerioStatic, mangaId: string) {

‎src/tests/DankeFurs.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ describe("DankeFurs Tests", function () {
5757

5858
it("Testing search", async () => {
5959
let testSearch = createSearchRequest({
60-
title: "kazu",
60+
title: "Crossdressing",
6161
});
6262

6363
let search = await wrapper.searchRequest(source, testSearch);

0 commit comments

Comments
 (0)