Skip to content

Commit fc1663c

Browse files
authored
fix(novelarrow): Fetch Complete Summary (#2256)
1 parent 144c421 commit fc1663c

1 file changed

Lines changed: 11 additions & 27 deletions

File tree

plugins/english/novelarrow.ts

Lines changed: 11 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class NovelArrow implements Plugin.PluginBase {
88
name = 'Novel Arrow';
99
icon = 'src/en/novelarrow/icon.png';
1010
site = 'https://novelarrow.com/';
11-
version = '1.0.0';
11+
version = '1.0.1';
1212

1313
async popularNovels(page: number) {
1414
const url = `${this.site}novels/latest?page=${page}`;
@@ -42,9 +42,7 @@ class NovelArrow implements Plugin.PluginBase {
4242
const novelId = novelPath.replace('novel/', '').replace(/^\//, '');
4343

4444
// Collect genres
45-
let genres =
46-
$('meta[name="og:novel:genre"]').attr('content') ||
47-
$('meta[property="og:novel:genre"]').attr('content');
45+
let genres = $('meta[name="og:novel:genre"], meta[property="og:novel:genre"]').attr('content');
4846

4947
if (!genres) {
5048
const genreList: string[] = [];
@@ -55,33 +53,19 @@ class NovelArrow implements Plugin.PluginBase {
5553
genres = genreList.join(', ');
5654
}
5755

58-
// Attempt to get the full summary from the JSON stream if the meta tag is truncated
59-
let fullSummary =
60-
$('meta[name="description"]').attr('content') ||
61-
$('meta[property="og:description"]').attr('content');
62-
const summaryMatch = result.match(/\\?"description\\?":\\?"(.*?)\\?"/);
63-
if (summaryMatch && summaryMatch[1].length > (fullSummary?.length || 0)) {
64-
fullSummary = summaryMatch[1].replace(/\\n/g, '\n').replace(/\\"/g, '"');
65-
}
56+
// Get the full summary from the paragraphs inside class .site-reading-copy
57+
const fullSummary = $('.site-reading-copy p')
58+
.map((i, el) => $(el).text().trim())
59+
.get()
60+
.join('\n\n') || $('.site-reading-copy').text().trim();
6661

6762
const novel: Plugin.SourceNovel = {
6863
path: novelPath,
69-
name:
70-
$('meta[name="og:novel:novel_name"]').attr('content') ||
71-
$('meta[property="og:novel:novel_name"]').attr('content') ||
72-
$('meta[property="og:title"]').attr('content')?.split(' Novel')[0] ||
73-
$('h1').first().text().trim(),
74-
cover:
75-
$('meta[property="og:image"]').attr('content') ||
76-
$('meta[name="og:image"]').attr('content'),
77-
author:
78-
$('meta[name="og:novel:author"]').attr('content') ||
79-
$('meta[property="og:novel:author"]').attr('content') ||
80-
$('meta[name="author"]').attr('content') ||
81-
$('meta[property="article:author"]').attr('content'),
64+
name: $('meta[name="og:novel:novel_name"]').attr('content') || $('h1').first().text().trim(),
65+
cover: $('meta[property="og:image"]').attr('content'),
66+
author: $('meta[name="og:novel:author"]').attr('content') || $('meta[name="author"]').attr('content'),
8267
status:
83-
($('meta[name="og:novel:status"]').attr('content') ||
84-
$('meta[property="og:novel:status"]').attr('content')) === 'Ongoing'
68+
$('meta[name="og:novel:status"]').attr('content') === 'Ongoing'
8569
? NovelStatus.Ongoing
8670
: NovelStatus.Completed,
8771
summary: fullSummary,

0 commit comments

Comments
 (0)