Skip to content

Commit ba24e63

Browse files
authored
Merge pull request #2297 from MD-Shabrez/update-wetriedtls-parser
Update wetriedtls.com parser
2 parents 9094767 + d5aa6c3 commit ba24e63

File tree

3 files changed

+25
-6
lines changed

3 files changed

+25
-6
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,8 @@
9393
{ "name": "X-Xadro"},
9494
{ "name": "Yomafil"},
9595
{ "name": "Varun Patkar", "email": "[email protected]" },
96-
{ "name": "Peter Kaufman", "email": "[email protected]" }
96+
{ "name": "Peter Kaufman", "email": "[email protected]" },
97+
{ "name": "MD Shabrez" }
9798
],
9899
"license": "GPL-3.0-only",
99100
"bugs": {

plugin/js/parsers/WetriedTlsParser.js

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ class WetriedTlsParser extends Parser {
66
constructor() {
77
super();
88
this.minimumThrottle = 2000;
9+
this.chaptersSourceTitleMap = new Map();
910
}
1011

1112
async getChapterUrls() {
@@ -21,10 +22,12 @@ class WetriedTlsParser extends Parser {
2122
const seriesUrl =
2223
"https://wetriedtls.com/series/" + chapter.series.series_slug;
2324

24-
return {
25+
const mapObj = {
2526
sourceUrl: `${seriesUrl}/${chapter.chapter_slug}`,
2627
title: chapter.chapter_title,
2728
};
29+
this.chaptersSourceTitleMap.set(mapObj.sourceUrl, mapObj.title);
30+
return mapObj;
2831
});
2932

3033
return chapters;
@@ -50,7 +53,6 @@ class WetriedTlsParser extends Parser {
5053

5154
this.id = novelData.id;
5255
this.title = novelData.title;
53-
this.author = novelData.author;
5456
this.thumbnail = novelData.thumbnail;
5557
this.description = novelData.description;
5658
return;
@@ -80,7 +82,9 @@ class WetriedTlsParser extends Parser {
8082
([type, data]) =>
8183
type === 1 &&
8284
typeof data === "string" &&
83-
/<p>|<div>|<br>|<\/?strong>/.test(data) && // looks like HTML
85+
/<p\b[^>]*>|<div\b[^>]*>|<br\b[^>]*>|<\/?strong\b[^>]*>/i.test(
86+
data
87+
) && // looks like HTML
8488
data.length > 1000 // avoid short status chunks
8589
);
8690

@@ -104,8 +108,17 @@ class WetriedTlsParser extends Parser {
104108
return this.title.trim();
105109
}
106110

107-
extractAuthor() {
108-
return this.author;
111+
extractAuthor(dom) {
112+
if (!dom) return super.extractAuthor(dom);
113+
114+
const authorLabel = Array.from(
115+
dom.querySelectorAll("span.text-muted-foreground")
116+
).find((el) => el.innerText.trim() === "Author");
117+
const authorValue = authorLabel?.parentElement?.querySelector(
118+
":scope span:last-child"
119+
);
120+
121+
return authorValue?.innerText || super.extractAuthor(dom);
109122
}
110123

111124
extractDescription() {
@@ -115,4 +128,8 @@ class WetriedTlsParser extends Parser {
115128
findCoverImageUrl() {
116129
return this.thumbnail;
117130
}
131+
132+
findChapterTitle(dom) {
133+
return this.chaptersSourceTitleMap.get(dom.baseURI);
134+
}
118135
}

readme.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -803,6 +803,7 @@ Don't forget to give the project a star! Thanks again!
803803
<li>Yomafil</li>
804804
<li>Varun Patkar</li>
805805
<li>Peter Kaufman</li>
806+
<li>MD Shabrez</li>
806807
</ul>
807808
</details>
808809

0 commit comments

Comments
 (0)