Feat: [Novel Updates]: Rating (#1169)

* novel-updates-rating: add rating to novels

* novel-updates-rating: update version

* novel-updates-rating: revert version

* novel-updates-rating: edit imports

* novel-updates-rating: update plugins version

* novel_updates_rating: revert version

* novel-updates: update test version

* novel-updates: update test version

* novel-updates: revert test version
This commit is contained in:
Batorian
2025-03-18 09:42:41 +01:00
committed by GitHub
parent b4f0863c6e
commit 447947faa5
4 changed files with 14 additions and 7 deletions
+1 -1
View File
@@ -67,4 +67,4 @@
"lint-staged": {
"**/*.{js,ts,jsx,tsx}": "prettier --write"
}
}
}
+1 -4
View File
@@ -27,10 +27,7 @@ const generator = function generator(source) {
});
const pluginScript = `
${madaraTemplate.replace(
'// CustomJS HERE',
source.options?.customJs || '',
)}
${madaraTemplate.replace('// CustomJS HERE', source.options?.customJs || '')}
const plugin = new MadaraPlugin(${JSON.stringify(source)});
export default plugin;
`.trim();
+10 -2
View File
@@ -6,7 +6,7 @@ import { Plugin } from '@typings/plugin';
class NovelUpdates implements Plugin.PluginBase {
id = 'novelupdates';
name = 'Novel Updates';
version = '0.7.16';
version = '0.8.0';
icon = 'src/en/novelupdates/icon.png';
customCSS = 'src/en/novelupdates/customCSS.css';
site = 'https://www.novelupdates.com/';
@@ -144,6 +144,14 @@ class NovelUpdates implements Plugin.PluginBase {
novel.summary = summary + `\n\nType: ${type}`;
const rating = loadedCheerio('.seriesother .uvotes')
.text()
.match(/(\d+\.\d+) \/ \d+\.\d+/)?.[1];
if (rating) {
novel.rating = parseFloat(rating);
}
const chapter: Plugin.ChapterItem[] = [];
const novelId = loadedCheerio('input#mypostid').attr('value')!;
@@ -1004,7 +1012,7 @@ class NovelUpdates implements Plugin.PluginBase {
);
searchTerm = longestSearchTerm.replace(/[‘’]/g, "'").replace(/\s+/g, '+');
const url = `${this.site}series-finder/?sf=1&sh=${encodeURIComponent(searchTerm)}&sort=srank&order=asc&pg=${page}`;
const url = `${this.site}series-finder/?sf=1&sh=${searchTerm}&sort=srank&order=asc&pg=${page}`;
const result = await fetchApi(url);
const body = await result.text();
+2
View File
@@ -30,6 +30,8 @@ export namespace Plugin {
author?: string;
artist?: string;
status?: string;
/** Rating out of 5 as float */
rating?: number;
chapters?: ChapterItem[];
} & NovelItem;