fixed renovels (#1368)

* test

* fix
This commit is contained in:
Rider21
2024-12-14 12:08:15 +03:00
committed by GitHub
parent 18206104a4
commit 2dfe790a8f
3 changed files with 85 additions and 24 deletions
+72 -14
View File
@@ -9,14 +9,14 @@ class novelOvh implements Plugin.PluginBase {
name = 'НовелОВХ'; name = 'НовелОВХ';
site = 'https://novel.ovh'; site = 'https://novel.ovh';
apiSite = 'https://api.novel.ovh/v2/'; apiSite = 'https://api.novel.ovh/v2/';
version = '1.0.2'; version = '1.0.3';
icon = 'src/ru/novelovh/icon.png'; icon = 'src/ru/novelovh/icon.png';
async popularNovels( async popularNovels(
pageNo: number, pageNo: number,
{ showLatestNovels, filters }: Plugin.PopularNovelsOptions, { showLatestNovels, filters }: Plugin.PopularNovelsOptions,
): Promise<Plugin.NovelItem[]> { ): Promise<Plugin.NovelItem[]> {
let url = this.site + '/content?page=' + (pageNo - 1); let url = this.apiSite + 'books?page=' + (pageNo - 1);
url += url +=
'&sort=' + '&sort=' +
(showLatestNovels (showLatestNovels
@@ -24,9 +24,7 @@ class novelOvh implements Plugin.PluginBase {
: filters?.sort?.value || 'averageRating') + : filters?.sort?.value || 'averageRating') +
',desc'; ',desc';
const { books }: { books: BooksEntity[] } = await fetchApi( const books: BooksEntity[] = await fetchApi(url).then(res => res.json());
url + '&_data=routes/reader/book/index',
).then(res => res.json());
const novels: Plugin.NovelItem[] = []; const novels: Plugin.NovelItem[] = [];
books.forEach(novel => books.forEach(novel =>
@@ -41,7 +39,7 @@ class novelOvh implements Plugin.PluginBase {
} }
async parseNovel(novelPath: string): Promise<Plugin.SourceNovel> { async parseNovel(novelPath: string): Promise<Plugin.SourceNovel> {
const { book, chapters }: responseNovel = await fetchApi( const { book, branches, chapters }: responseNovel = await fetchApi(
this.site + this.site +
'/content/' + '/content/' +
novelPath + novelPath +
@@ -69,8 +67,15 @@ class novelOvh implements Plugin.PluginBase {
} }
}); });
const chaptersRes: Plugin.ChapterItem[] = []; const branch_name: Record<string, string> = {};
if (branches.length) {
branches.forEach(({ id, publishers }) => {
if (id && publishers?.length)
branch_name[id] = publishers[0].name || 'Неизвестный';
});
}
const chaptersRes: Plugin.ChapterItem[] = [];
chapters.forEach((chapter, chapterIndex) => chapters.forEach((chapter, chapterIndex) =>
chaptersRes.push({ chaptersRes.push({
name: name:
@@ -80,9 +85,10 @@ class novelOvh implements Plugin.PluginBase {
' ' + ' ' +
(chapter.name || (chapter.name ||
'Глава ' + (chapter.number || chapters.length - chapterIndex)), 'Глава ' + (chapter.number || chapters.length - chapterIndex)),
path: novelPath + '/' + chapter.id + '/0', path: novelPath + '/' + chapter.id,
releaseTime: dayjs(chapter.createdAt).format('LLL'), releaseTime: dayjs(chapter.createdAt).format('LLL'),
chapterNumber: chapters.length - chapterIndex, chapterNumber: chapters.length - chapterIndex,
page: branch_name[chapter.branchId] || 'Главная страница',
}), }),
); );
@@ -140,16 +146,68 @@ class novelOvh implements Plugin.PluginBase {
break; break;
case 'paragraph': case 'paragraph':
html += html +=
'<p' + '<p>' +
(element?.attrs?.textAlign
? ` style="text-align: ${element.attrs.textAlign}"`
: '') +
'>' +
(element.content (element.content
? this.jsonToHtml(element.content, image) ? this.jsonToHtml(element.content, image)
: '<br>') + : '<br>') +
'</p>'; '</p>';
break; break;
case 'orderedList':
html +=
'<ol>' +
(element.content
? this.jsonToHtml(element.content, image)
: '<br>') +
'</ol>';
break;
case 'listItem':
html +=
'<li>' +
(element.content
? this.jsonToHtml(element.content, image)
: '<br>') +
'</li>';
break;
case 'blockquote':
html +=
'<blockquote>' +
(element.content
? this.jsonToHtml(element.content, image)
: '<br>') +
'</blockquote>';
break;
case 'italic':
html +=
'<i>' +
(element.content
? this.jsonToHtml(element.content, image)
: '<br>') +
'</i>';
break;
case 'bold':
html +=
'<b>' +
(element.content
? this.jsonToHtml(element.content, image)
: '<br>') +
'</b>';
break;
case 'underline':
html +=
'<u>' +
(element.content
? this.jsonToHtml(element.content, image)
: '<br>') +
'</u>';
break;
case 'heading':
html +=
'<h2>' +
(element.content
? this.jsonToHtml(element.content, image)
: '<br>') +
'</h2>';
break;
case 'text': case 'text':
html += element.text; html += element.text;
break; break;
@@ -161,7 +219,7 @@ class novelOvh implements Plugin.PluginBase {
return html; return html;
}; };
resolveUrl = (path: string) => this.site + '/novel/' + path; resolveUrl = (path: string) => this.site + '/content/' + path;
filters = { filters = {
sort: { sort: {
+1 -1
View File
@@ -126,7 +126,7 @@ class RLIB implements Plugin.PluginBase {
novel.genres = genres.join(', '); novel.genres = genres.join(', ');
} }
const branch_name: Record<number, string> = { 0: 'главная страница' }; const branch_name: Record<number, string> = { 0: 'Главная страница' };
if (data.teams.length) { if (data.teams.length) {
data.teams.forEach( data.teams.forEach(
({ name, details }) => (branch_name[details?.branch_id || '0'] = name), ({ name, details }) => (branch_name[details?.branch_id || '0'] = name),
+12 -9
View File
@@ -11,7 +11,7 @@ class ReN implements Plugin.PluginBase {
name = 'Renovels'; name = 'Renovels';
icon = 'src/ru/renovels/icon.png'; icon = 'src/ru/renovels/icon.png';
site = 'https://renovels.org'; site = 'https://renovels.org';
version = '1.0.1'; version = '1.0.2';
async popularNovels( async popularNovels(
pageNo: number, pageNo: number,
@@ -80,7 +80,7 @@ class ReN implements Plugin.PluginBase {
} }
const totalPages = const totalPages =
(content.branches?.[0]?.count_chapters || content.count_chapters) / 100; (content.branches?.[0]?.count_chapters || content.count_chapters) / 50;
const branch_id = content.branches?.[0]?.id || content.id; const branch_id = content.branches?.[0]?.id || content.id;
const chapters: Plugin.ChapterItem[] = []; const chapters: Plugin.ChapterItem[] = [];
@@ -92,9 +92,10 @@ class ReN implements Plugin.PluginBase {
this.site + this.site +
'/api/titles/chapters/?branch_id=' + '/api/titles/chapters/?branch_id=' +
branch_id + branch_id +
'&count=100&page=' + '&ordering=index&user_data=1&count=50&page=' +
(page + 1), (page + 1),
).then(res => res.json()); ).then(res => res.json());
let skip = false;
volumes.content.forEach(chapter => { volumes.content.forEach(chapter => {
if (!chapter.is_paid || chapter.is_bought) { if (!chapter.is_paid || chapter.is_bought) {
@@ -109,21 +110,23 @@ class ReN implements Plugin.PluginBase {
releaseTime: dayjs(chapter.upload_date).format('LLL'), releaseTime: dayjs(chapter.upload_date).format('LLL'),
chapterNumber: chapter.index, chapterNumber: chapter.index,
}); });
} else {
skip = true;
} }
}); });
if (skip) break;
} }
novel.chapters = chapters.reverse(); novel.chapters = chapters;
return novel; return novel;
} }
async parseChapter(chapterPath: string): Promise<string> { async parseChapter(chapterPath: string): Promise<string> {
const url = this.site + '/api/titles/chapters/' + chapterPath.split('/')[1]; const url =
const result: { content: responseСhapter } = await fetchApi(url).then(res => this.site + '/api/v2/titles/chapters/' + chapterPath.split('/')[1];
res.json(), const result: responseСhapter = await fetchApi(url).then(res => res.json());
);
return result.content.content || ''; return result.content || '';
} }
async searchNovels( async searchNovels(