Skip to content

Commit

Permalink
Updates sources and adds TimTruyen3s source
Browse files Browse the repository at this point in the history
- Updates domain for BaoTangTruyenTranh, GocTruyenTranh.
- Adds user-agent to BaoTangTruyenTranh, TimTruyen3s.
- Increases request timeout for all sources.
- Adds TimTruyen3s source with support for search, manga details,
chapters, and home page sections.
- Updates versions for all sources.
- Improves image handling in GocTruyenTranh and BaoTangTruyenTranh
parsers.
- Adds debug logs to BaoTangTruyenTranh.
  • Loading branch information
AlanNois committed Nov 20, 2024
1 parent ffd1d8a commit ab5095e
Show file tree
Hide file tree
Showing 16 changed files with 388 additions and 38 deletions.
10 changes: 7 additions & 3 deletions src/BaoTangTruyenTranh/BaoTangTruyenTranh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import {

import { Parser } from './BaoTangTruyenTranhParser';

const DOMAIN = 'https://baotangtruyen19.com/';
const DOMAIN = 'https://baotangtruyen21.com/';

export const isLastPage = ($: CheerioStatic): boolean => {
const pages: number[] = [];
Expand All @@ -39,7 +39,7 @@ export const isLastPage = ($: CheerioStatic): boolean => {
}

export const BaoTangTruyenTranhInfo: SourceInfo = {
version: '1.0.14',
version: '1.0.17',
name: 'BaoTangTruyenTranh',
icon: 'icon.png',
author: 'AlanNois',
Expand All @@ -66,13 +66,14 @@ export class BaoTangTruyenTranh implements ChapterProviding, MangaProviding, Sea

readonly requestManager = App.createRequestManager({
requestsPerSecond: 4,
requestTimeout: 15000,
requestTimeout: 50000,
interceptor: {
interceptRequest: async (request: Request): Promise<Request> => {
request.headers = {
...(request.headers ?? {}),
...{
'referer': DOMAIN,
'user-agent': await this.requestManager.getDefaultUserAgent()
}
}
return request;
Expand Down Expand Up @@ -160,6 +161,7 @@ export class BaoTangTruyenTranh implements ChapterProviding, MangaProviding, Sea
const url = encodeURI(searchUrl);
const $ = await this.DOMHTML(url);
const tiles = this.parser.parseSearchResults($);
console.log(tiles)
metadata = !isLastPage($) ? { page: page + 1 } : undefined;

return App.createPagedResults({
Expand Down Expand Up @@ -205,6 +207,7 @@ export class BaoTangTruyenTranh implements ChapterProviding, MangaProviding, Sea
section.items = this.parser.parseTransSection($);
break;
}
console.log(section)
sectionCallback(section);
}
}
Expand All @@ -230,6 +233,7 @@ export class BaoTangTruyenTranh implements ChapterProviding, MangaProviding, Sea
const $ = await this.DOMHTML(url);
const manga = this.parser.parseViewMore($);
metadata = !isLastPage($) ? { page: page + 1 } : undefined;
console.log(manga)

return App.createPagedResults({
results: manga,
Expand Down
6 changes: 3 additions & 3 deletions src/BaoTangTruyenTranh/BaoTangTruyenTranhParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export class Parser {
const subtitle = $(".slide-caption > a", element).first().text().trim() + ' | ' + $(".time", element).first().text().trim();
return App.createPartialSourceManga({
mangaId: String(id),
image: encodeURI(this.decodeHTMLEntity(String(image?.replace('http://', 'https://')))),
image: String(image),
title: this.decodeHTMLEntity(title),
subtitle: this.decodeHTMLEntity(subtitle),
});
Expand All @@ -115,7 +115,7 @@ export class Parser {
const subtitle = $("ul .chapter > a", element).first().text().trim().replace('Chapter ', 'Ch.') + ' | ' + $("ul .chapter > i", element).first().text().trim();
return App.createPartialSourceManga({
mangaId: String(id),
image: encodeURI(this.decodeHTMLEntity(String(image?.replace('http://', 'https://')))),
image: String(image),
title: this.decodeHTMLEntity(title),
subtitle: this.decodeHTMLEntity(subtitle),
});
Expand All @@ -131,7 +131,7 @@ export class Parser {
const subtitle = $("ul .chapter > a", element).first().text().trim().replace('Chapter ', 'Ch.') + ' | ' + $("ul .chapter > i", element).first().text().trim();
return App.createPartialSourceManga({
mangaId: String(id),
image: encodeURI(this.decodeHTMLEntity(String(image?.replace('http://', 'https://')))),
image: String(image),
title: this.decodeHTMLEntity(title),
subtitle: this.decodeHTMLEntity(subtitle),
});
Expand Down
4 changes: 2 additions & 2 deletions src/Blogtruyen/Blogtruyen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export const isLastPage = ($: CheerioStatic): boolean => {
}

export const BlogtruyenInfo: SourceInfo = {
version: '1.0.4',
version: '1.0.5',
name: 'Blogtruyen',
icon: 'icon.png',
author: 'AlanNois',
Expand All @@ -46,7 +46,7 @@ export class Blogtruyen implements SearchResultsProviding, MangaProviding, Chapt

readonly requestManager = App.createRequestManager({
requestsPerSecond: 4,
requestTimeout: 15000,
requestTimeout: 50000,
interceptor: {
interceptRequest: async (request: Request): Promise<Request> => {
request.headers = {
Expand Down
4 changes: 2 additions & 2 deletions src/CManga/CManga.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { Parser } from './CMangaParser';
const DOMAIN = 'https://cmanga03.com/';

export const CMangaInfo: SourceInfo = {
version: '1.0.7',
version: '1.0.8',
name: 'CManga',
icon: 'icon.png',
author: 'AlanNois',
Expand All @@ -48,7 +48,7 @@ export class CManga implements ChapterProviding, MangaProviding, SearchResultsPr

readonly requestManager = App.createRequestManager({
requestsPerSecond: 4,
requestTimeout: 15000,
requestTimeout: 50000,
interceptor: {
interceptRequest: async (request: Request): Promise<Request> => {
request.headers = {
Expand Down
4 changes: 2 additions & 2 deletions src/DocTruyen3Q/DocTruyen3Q.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export const isLastPage = ($: CheerioStatic): boolean => {
}

export const DocTruyen3QInfo: SourceInfo = {
version: '1.1.6',
version: '1.1.7',
name: 'DocTruyen3Q',
icon: 'icon.png',
author: 'AlanNois',
Expand All @@ -56,7 +56,7 @@ export class DocTruyen3Q implements SearchResultsProviding, MangaProviding, Chap

readonly requestManager = App.createRequestManager({
requestsPerSecond: 4,
requestTimeout: 15000,
requestTimeout: 50000,
interceptor: {
interceptRequest: async (request: Request): Promise<Request> => {
request.headers = {
Expand Down
20 changes: 10 additions & 10 deletions src/GocTruyenTranh/GocTruyenTranh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ import {

import { Parser } from './GocTruyenTranhParser';

const DOMAIN = 'https://goctruyentranhvui3.com/';
const DOMAIN = 'https://goctruyentranhvui6.com/';
const Auth = 'Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJWxINuIEhvw6BuZyDEkGluaCIsImNvbWljSWRzIjpbXSwicm9sZUlkIjpudWxsLCJncm91cElkIjpudWxsLCJhZG1pbiI6ZmFsc2UsInJhbmsiOjAsInBlcm1pc3Npb24iOltdLCJpZCI6IjAwMDA1MjYzNzAiLCJ0ZWFtIjpmYWxzZSwiaWF0IjoxNzE1NDI0NDU3LCJlbWFpbCI6Im51bGwifQ.EjYw-HvoWM6RhbNzJkp06sSh61leaPcND0gb94PlDKeTYxfxU-f6WaxINAVjVYOP0pcVcG3YmfBVb4FVEBqPxQ'

export const GocTruyenTranhInfo: SourceInfo = {
version: '1.1.6',
version: '1.1.11',
name: 'GocTruyenTranh',
icon: 'icon.png',
author: 'AlanNois',
Expand All @@ -48,7 +48,7 @@ export class GocTruyenTranh implements SearchResultsProviding, MangaProviding, C

readonly requestManager = App.createRequestManager({
requestsPerSecond: 4,
requestTimeout: 15000,
requestTimeout: 50000,
interceptor: {
interceptRequest: async (request: Request): Promise<Request> => {
request.headers = {
Expand Down Expand Up @@ -94,7 +94,7 @@ export class GocTruyenTranh implements SearchResultsProviding, MangaProviding, C

async getMangaDetails(mangaId: string): Promise<SourceManga> {
const $ = await this.DOMHTML(`${DOMAIN}truyen/${mangaId.split('::')[0]}`);
return this.parser.parseMangaDetails($, mangaId);
return this.parser.parseMangaDetails($, mangaId, DOMAIN);
}

async getChapters(mangaId: string): Promise<Chapter[]> {
Expand Down Expand Up @@ -123,7 +123,7 @@ export class GocTruyenTranh implements SearchResultsProviding, MangaProviding, C
const response = await this.requestManager.schedule(request, 1)
const json = JSON.parse(response.data as string)

pages = this.parser.parseChapterDetails(json, null)
pages = this.parser.parseChapterDetails(json, null, DOMAIN)

return App.createChapterDetails({
id: chapterId,
Expand All @@ -139,7 +139,7 @@ export class GocTruyenTranh implements SearchResultsProviding, MangaProviding, C
const tags = query.includedTags?.map(tag => tag.id) ?? [];
const url = query.title ? encodeURI(`${DOMAIN}api/comic/search?name=${query.title}`) : `${DOMAIN}api/comic/search/category?p=${page}&value=${tags[0]}`;
const json = await this.callAPI(url);
const tiles = this.parser.parseSearchResults(json);
const tiles = this.parser.parseSearchResults(json, DOMAIN);

metadata = query.title ? undefined : { page: page + 1 };

Expand Down Expand Up @@ -179,13 +179,13 @@ export class GocTruyenTranh implements SearchResultsProviding, MangaProviding, C

switch (section.id) {
case 'hot':
section.items = this.parser.parseViewMoreItems(json).slice(0, 10);
section.items = this.parser.parseViewMoreItems(json, DOMAIN).slice(0, 10);
break;
case 'new_added':
section.items = this.parser.parseViewMoreItems(json).slice(0, 10);
section.items = this.parser.parseViewMoreItems(json, DOMAIN).slice(0, 10);
break;
case 'new_updated':
section.items = this.parser.parseViewMoreItems(json).slice(0, 10);
section.items = this.parser.parseViewMoreItems(json, DOMAIN).slice(0, 10);
break;
}
sectionCallback(section);
Expand All @@ -210,7 +210,7 @@ export class GocTruyenTranh implements SearchResultsProviding, MangaProviding, C
}

const json = await this.callAPI(url);
const tiles = this.parser.parseViewMoreItems(json);
const tiles = this.parser.parseViewMoreItems(json, DOMAIN);
metadata = { page: page + 1 };
return App.createPagedResults({
results: tiles,
Expand Down
16 changes: 8 additions & 8 deletions src/GocTruyenTranh/GocTruyenTranhParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export class Parser {
return time
}

parseMangaDetails($: CheerioStatic, mangaId: string): SourceManga {
parseMangaDetails($: CheerioStatic, mangaId: string, DOMAIN: any): SourceManga {
const tags: Tag[] = [];

$('.group-content a').each((_: any, obj: any) => {
Expand All @@ -66,7 +66,7 @@ export class Parser {
break
}
})
const image = String($('.v-image > img').attr('src'));
const image = String($('.v-image > img').attr('src')?.indexOf('https') === -1 ? DOMAIN + $('.v-image > img').attr('src') : $('.v-image > img').attr('src'));
const desc = this.decodeHTMLEntity($('.v-card-text.pt-1.px-4.pb-4.text-secondary.font-weight-medium').text());
const rating = parseFloat($('.pr-3 > b').text().trim());

Expand Down Expand Up @@ -108,7 +108,7 @@ export class Parser {
return chapters;
}

parseChapterDetails(json: any, $: any): string[] {
parseChapterDetails(json: any, $: any, DOMAIN: any): string[] {
const pages: string[] = [];

if (json == null) {
Expand All @@ -119,14 +119,14 @@ export class Parser {
});
} else {
for (const img of json.result.data) {
pages.push(img);
pages.push(img.indexOf('https') === -1 ? DOMAIN + img : img);
}
}

return pages;
}

parseSearchResults(json: any): PartialSourceManga[] {
parseSearchResults(json: any, DOMAIN: any): PartialSourceManga[] {
const tiles: PartialSourceManga[] = [];
const array = json.result.data ?? json.result;
for (let obj of array) {
Expand All @@ -136,7 +136,7 @@ export class Parser {
let mangaId = `${obj.nameEn}::${obj.id}`;
tiles.push(App.createPartialSourceManga({
mangaId,
image: encodeURI(image) ?? "",
image: encodeURI(image.indexOf('https') === -1 ? DOMAIN + image : image) ?? "",
title,
subtitle
}))
Expand All @@ -145,7 +145,7 @@ export class Parser {
return tiles;
}

parseViewMoreItems(json: any): PartialSourceManga[] {
parseViewMoreItems(json: any, DOMAIN: any): PartialSourceManga[] {
const manga: PartialSourceManga[] = [];
const collectedIds: string[] = [];
for (let obj of json.result.data) {
Expand All @@ -156,7 +156,7 @@ export class Parser {
if (!collectedIds.includes(mangaId)) {
manga.push(App.createPartialSourceManga({
mangaId,
image: encodeURI(image) ?? "",
image: encodeURI(image.indexOf('https') === -1 ? DOMAIN + image : image) ?? "",
title,
subtitle,
}));
Expand Down
4 changes: 2 additions & 2 deletions src/ManhuaRock/ManhuaRock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export const isLastPage = ($: CheerioStatic): boolean => {
};

export const ManhuaRockInfo: SourceInfo = {
version: '1.0.3',
version: '1.0.4',
name: 'ManhuaRock',
icon: 'icon.png',
author: 'AlanNois',
Expand Down Expand Up @@ -73,7 +73,7 @@ export class ManhuaRock implements SearchResultsProviding, MangaProviding, Chapt
from the `App` module. */
readonly requestManager = App.createRequestManager({
requestsPerSecond: 4,
requestTimeout: 15000,
requestTimeout: 50000,
interceptor: {
interceptRequest: async (request: Request): Promise<Request> => {
request.headers = {
Expand Down
2 changes: 1 addition & 1 deletion src/NetTruyen/NetTruyen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export class NetTruyen implements SearchResultsProviding, MangaProviding, Chapte

readonly requestManager = App.createRequestManager({
requestsPerSecond: 4,
requestTimeout: 15000,
requestTimeout: 50000,
interceptor: {
interceptRequest: async (request: Request): Promise<Request> => {
request.headers = {
Expand Down
2 changes: 1 addition & 1 deletion src/NhatTruyen/NhatTruyen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export class NhatTruyen implements SearchResultsProviding, MangaProviding, Chapt

readonly requestManager = App.createRequestManager({
requestsPerSecond: 4,
requestTimeout: 15000,
requestTimeout: 50000,
interceptor: {
interceptRequest: async (request: Request): Promise<Request> => {
request.headers = {
Expand Down
Loading

0 comments on commit ab5095e

Please sign in to comment.