fix(novelfull): add image fallbacks (#1457)

This commit is contained in:
John Ramberger
2025-01-24 05:08:09 -05:00
committed by GitHub
parent f7649eafdb
commit 2d7f97ef4e
+17 -4
View File
@@ -6,7 +6,7 @@ import { Filters, FilterTypes } from '@libs/filterInputs';
class NovelFull implements Plugin.PluginBase { class NovelFull implements Plugin.PluginBase {
id = 'novelfull'; id = 'novelfull';
name = 'NovelFull'; name = 'NovelFull';
version = '1.0.1'; version = '1.0.2';
icon = 'src/en/novelfull/icon.png'; icon = 'src/en/novelfull/icon.png';
site = 'https://novelfull.com/'; site = 'https://novelfull.com/';
@@ -16,8 +16,12 @@ class NovelFull implements Plugin.PluginBase {
loadedCheerio('.col-truyen-main .list-truyen .row').each((idx, ele) => { loadedCheerio('.col-truyen-main .list-truyen .row').each((idx, ele) => {
const novelName = loadedCheerio(ele).find('h3.truyen-title > a').text(); const novelName = loadedCheerio(ele).find('h3.truyen-title > a').text();
const novelCover = // Images from the site are now lazy loaded, so we need to check data-cfsrc as well
this.site + loadedCheerio(ele).find('img').attr('src')?.slice(1); let novelCover =
loadedCheerio(ele).find('img').attr('src') ??
loadedCheerio(ele).find('img').attr('data-cfsrc');
novelCover = novelCover ? this.site + novelCover.slice(1) : undefined;
const novelUrl = loadedCheerio(ele) const novelUrl = loadedCheerio(ele)
.find('h3.truyen-title > a') .find('h3.truyen-title > a')
@@ -60,10 +64,19 @@ class NovelFull implements Plugin.PluginBase {
let loadedCheerio = parseHTML(body); let loadedCheerio = parseHTML(body);
// Images from the site are now lazy loaded, so we need to check data-cfsrc as well (and fallback to other locations)
let cover =
loadedCheerio('div.book > img').attr('src') ??
loadedCheerio('div.book > img').attr('data-cfsrc') ??
loadedCheerio('div.book > noscript > img').attr('src') ??
loadedCheerio('meta[name="image"]').attr('content');
cover = cover ? this.site + cover.slice(1) : undefined;
const novel: Plugin.SourceNovel = { const novel: Plugin.SourceNovel = {
path: novelPath, path: novelPath,
name: loadedCheerio('div.book > img').attr('alt') || 'Untitled', name: loadedCheerio('div.book > img').attr('alt') || 'Untitled',
cover: this.site + loadedCheerio('div.book > img').attr('src'), cover: cover,
summary: loadedCheerio('div.desc-text').text().trim(), summary: loadedCheerio('div.desc-text').text().trim(),
status: loadedCheerio('h3:contains("Status")').next().text(), status: loadedCheerio('h3:contains("Status")').next().text(),
chapters: [], chapters: [],