fix(novelarrow): Fetch Complete Summary (#2256)
This commit is contained in:
@@ -8,7 +8,7 @@ class NovelArrow implements Plugin.PluginBase {
|
|||||||
name = 'Novel Arrow';
|
name = 'Novel Arrow';
|
||||||
icon = 'src/en/novelarrow/icon.png';
|
icon = 'src/en/novelarrow/icon.png';
|
||||||
site = 'https://novelarrow.com/';
|
site = 'https://novelarrow.com/';
|
||||||
version = '1.0.0';
|
version = '1.0.1';
|
||||||
|
|
||||||
async popularNovels(page: number) {
|
async popularNovels(page: number) {
|
||||||
const url = `${this.site}novels/latest?page=${page}`;
|
const url = `${this.site}novels/latest?page=${page}`;
|
||||||
@@ -42,9 +42,7 @@ class NovelArrow implements Plugin.PluginBase {
|
|||||||
const novelId = novelPath.replace('novel/', '').replace(/^\//, '');
|
const novelId = novelPath.replace('novel/', '').replace(/^\//, '');
|
||||||
|
|
||||||
// Collect genres
|
// Collect genres
|
||||||
let genres =
|
let genres = $('meta[name="og:novel:genre"], meta[property="og:novel:genre"]').attr('content');
|
||||||
$('meta[name="og:novel:genre"]').attr('content') ||
|
|
||||||
$('meta[property="og:novel:genre"]').attr('content');
|
|
||||||
|
|
||||||
if (!genres) {
|
if (!genres) {
|
||||||
const genreList: string[] = [];
|
const genreList: string[] = [];
|
||||||
@@ -55,33 +53,19 @@ class NovelArrow implements Plugin.PluginBase {
|
|||||||
genres = genreList.join(', ');
|
genres = genreList.join(', ');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Attempt to get the full summary from the JSON stream if the meta tag is truncated
|
// Get the full summary from the paragraphs inside class .site-reading-copy
|
||||||
let fullSummary =
|
const fullSummary = $('.site-reading-copy p')
|
||||||
$('meta[name="description"]').attr('content') ||
|
.map((i, el) => $(el).text().trim())
|
||||||
$('meta[property="og:description"]').attr('content');
|
.get()
|
||||||
const summaryMatch = result.match(/\\?"description\\?":\\?"(.*?)\\?"/);
|
.join('\n\n') || $('.site-reading-copy').text().trim();
|
||||||
if (summaryMatch && summaryMatch[1].length > (fullSummary?.length || 0)) {
|
|
||||||
fullSummary = summaryMatch[1].replace(/\\n/g, '\n').replace(/\\"/g, '"');
|
|
||||||
}
|
|
||||||
|
|
||||||
const novel: Plugin.SourceNovel = {
|
const novel: Plugin.SourceNovel = {
|
||||||
path: novelPath,
|
path: novelPath,
|
||||||
name:
|
name: $('meta[name="og:novel:novel_name"]').attr('content') || $('h1').first().text().trim(),
|
||||||
$('meta[name="og:novel:novel_name"]').attr('content') ||
|
cover: $('meta[property="og:image"]').attr('content'),
|
||||||
$('meta[property="og:novel:novel_name"]').attr('content') ||
|
author: $('meta[name="og:novel:author"]').attr('content') || $('meta[name="author"]').attr('content'),
|
||||||
$('meta[property="og:title"]').attr('content')?.split(' Novel')[0] ||
|
|
||||||
$('h1').first().text().trim(),
|
|
||||||
cover:
|
|
||||||
$('meta[property="og:image"]').attr('content') ||
|
|
||||||
$('meta[name="og:image"]').attr('content'),
|
|
||||||
author:
|
|
||||||
$('meta[name="og:novel:author"]').attr('content') ||
|
|
||||||
$('meta[property="og:novel:author"]').attr('content') ||
|
|
||||||
$('meta[name="author"]').attr('content') ||
|
|
||||||
$('meta[property="article:author"]').attr('content'),
|
|
||||||
status:
|
status:
|
||||||
($('meta[name="og:novel:status"]').attr('content') ||
|
$('meta[name="og:novel:status"]').attr('content') === 'Ongoing'
|
||||||
$('meta[property="og:novel:status"]').attr('content')) === 'Ongoing'
|
|
||||||
? NovelStatus.Ongoing
|
? NovelStatus.Ongoing
|
||||||
: NovelStatus.Completed,
|
: NovelStatus.Completed,
|
||||||
summary: fullSummary,
|
summary: fullSummary,
|
||||||
|
|||||||
Reference in New Issue
Block a user