fix authorToday (#1690)
* updates * fix * test * fix * Update src/plugins/russian/authortoday.ts Co-authored-by: K1ngfish3r <trulyihu@gmail.com> --------- Co-authored-by: K1ngfish3r <trulyihu@gmail.com>
This commit is contained in:
@@ -7549,7 +7549,7 @@
|
|||||||
"type": "CheckboxGroup"
|
"type": "CheckboxGroup"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"versionIncrements": 0
|
"versionIncrements": 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "erolate",
|
"id": "erolate",
|
||||||
|
|||||||
@@ -102,7 +102,7 @@ class RulatePlugin implements Plugin.PluginBase {
|
|||||||
'src',
|
'src',
|
||||||
);
|
);
|
||||||
novel.summary = loadedCheerio(
|
novel.summary = loadedCheerio(
|
||||||
'#Info > div:nth-child(3), .book__description',
|
'#Info > div:nth-child(4) > p:nth-child(1), .book__description',
|
||||||
)
|
)
|
||||||
.text()
|
.text()
|
||||||
.trim();
|
.trim();
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import { Plugin } from '@typings/plugin';
|
|||||||
class NovelUpdates implements Plugin.PluginBase {
|
class NovelUpdates implements Plugin.PluginBase {
|
||||||
id = 'novelupdates';
|
id = 'novelupdates';
|
||||||
name = 'Novel Updates';
|
name = 'Novel Updates';
|
||||||
version = '0.9.0';
|
version = '0.9.1';
|
||||||
icon = 'src/en/novelupdates/icon.png';
|
icon = 'src/en/novelupdates/icon.png';
|
||||||
customCSS = 'src/en/novelupdates/customCSS.css';
|
customCSS = 'src/en/novelupdates/customCSS.css';
|
||||||
site = 'https://www.novelupdates.com/';
|
site = 'https://www.novelupdates.com/';
|
||||||
@@ -799,7 +799,7 @@ class NovelUpdates implements Plugin.PluginBase {
|
|||||||
'.sidebar',
|
'.sidebar',
|
||||||
'.swg-button-v2-light',
|
'.swg-button-v2-light',
|
||||||
'.wp-block-buttons',
|
'.wp-block-buttons',
|
||||||
'.wp-block-columns',
|
//'.wp-block-columns',
|
||||||
'.wp-dark-mode-switcher',
|
'.wp-dark-mode-switcher',
|
||||||
'.wp-next-post-navi',
|
'.wp-next-post-navi',
|
||||||
'#hpk',
|
'#hpk',
|
||||||
|
|||||||
+233
-390
@@ -3,8 +3,7 @@ import { FilterTypes, Filters } from '@libs/filterInputs';
|
|||||||
import { defaultCover } from '@libs/defaultCover';
|
import { defaultCover } from '@libs/defaultCover';
|
||||||
import { fetchApi } from '@libs/fetch';
|
import { fetchApi } from '@libs/fetch';
|
||||||
import { NovelStatus } from '@libs/novelStatus';
|
import { NovelStatus } from '@libs/novelStatus';
|
||||||
import { load as parseHTML } from 'cheerio';
|
import { Parser } from 'htmlparser2';
|
||||||
import { storage } from '@libs/storage';
|
|
||||||
import dayjs from 'dayjs';
|
import dayjs from 'dayjs';
|
||||||
|
|
||||||
class AuthorToday implements Plugin.PluginBase {
|
class AuthorToday implements Plugin.PluginBase {
|
||||||
@@ -12,129 +11,249 @@ class AuthorToday implements Plugin.PluginBase {
|
|||||||
name = 'Автор Тудей';
|
name = 'Автор Тудей';
|
||||||
icon = 'src/ru/authortoday/icon.png';
|
icon = 'src/ru/authortoday/icon.png';
|
||||||
site = 'https://author.today';
|
site = 'https://author.today';
|
||||||
apiSite = 'https://api.author.today/v1/';
|
version = '1.2.0';
|
||||||
imageSite = 'https://cm.author.today/content/';
|
|
||||||
version = '1.1.1';
|
private userAgent =
|
||||||
|
'Mozilla/5.0 (Android 15; Mobile; rv:138.0) Gecko/138.0 Firefox/138.0';
|
||||||
|
|
||||||
|
parseNovels(url: string) {
|
||||||
|
return fetchApi(url, { headers: { 'User-Agent': this.userAgent } })
|
||||||
|
.then(res => res.text())
|
||||||
|
.then(html => {
|
||||||
|
const novels: Plugin.NovelItem[] = [];
|
||||||
|
let tempNovel = {} as Plugin.NovelItem;
|
||||||
|
let isParsingNovel = false;
|
||||||
|
let isParsingName = false;
|
||||||
|
const parser = new Parser({
|
||||||
|
onopentag(name, attribs) {
|
||||||
|
if (
|
||||||
|
name === 'a' &&
|
||||||
|
attribs['class'] === 'work-row item-link item-content' &&
|
||||||
|
attribs['href']
|
||||||
|
) {
|
||||||
|
tempNovel.path = attribs['href'].replace(/\D/g, '');
|
||||||
|
isParsingNovel = true;
|
||||||
|
}
|
||||||
|
if (
|
||||||
|
isParsingNovel &&
|
||||||
|
name === 'h4' &&
|
||||||
|
attribs['class'] === 'work-title'
|
||||||
|
) {
|
||||||
|
isParsingName = true;
|
||||||
|
}
|
||||||
|
if (
|
||||||
|
isParsingNovel &&
|
||||||
|
name === 'img' &&
|
||||||
|
attribs['alt'] === 'Обложка'
|
||||||
|
) {
|
||||||
|
tempNovel.cover = attribs['data-src'];
|
||||||
|
}
|
||||||
|
},
|
||||||
|
ontext(data) {
|
||||||
|
if (isParsingName) {
|
||||||
|
tempNovel.name = data.trim();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onclosetag(name) {
|
||||||
|
if (name === 'h4') {
|
||||||
|
isParsingName = false;
|
||||||
|
}
|
||||||
|
if (name === 'a' && isParsingNovel) {
|
||||||
|
if (!tempNovel.cover) {
|
||||||
|
tempNovel.cover = defaultCover;
|
||||||
|
}
|
||||||
|
novels.push(tempNovel);
|
||||||
|
tempNovel = {} as Plugin.NovelItem;
|
||||||
|
isParsingNovel = false;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
});
|
||||||
|
parser.write(html);
|
||||||
|
parser.end();
|
||||||
|
return novels;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
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.apiSite + 'catalog/search?page=' + pageNo;
|
let url = this.site + '/work/genre/' + (filters?.genre?.value || 'all');
|
||||||
if (filters?.genre?.value) {
|
|
||||||
url += '&genre=' + filters.genre.value;
|
|
||||||
}
|
|
||||||
|
|
||||||
url +=
|
url +=
|
||||||
'&sorting=' +
|
'?sorting=' +
|
||||||
(showLatestNovels ? 'recent' : filters?.sort?.value || 'popular');
|
(showLatestNovels ? 'recent' : filters?.sort?.value || 'popular');
|
||||||
|
|
||||||
url += '&form=' + (filters?.form?.value || 'any');
|
if (filters?.form?.value) url += '&form=' + filters.form.value;
|
||||||
url += '&state=' + (filters?.state?.value || 'any');
|
if (filters?.state?.value) url += '&state=' + filters.state.value;
|
||||||
url += '&series=' + (filters?.series?.value || 'any');
|
if (filters?.series?.value) url += '&series=' + filters.series.value;
|
||||||
url += '&access=' + (filters?.access?.value || 'any');
|
if (filters?.access?.value) url += '&access=' + filters.access.value;
|
||||||
url += '&promo=' + (filters?.promo?.value || 'hide');
|
if (filters?.promo?.value) url += '&promo=' + filters.promo.value;
|
||||||
|
url += '&page=' + pageNo;
|
||||||
|
|
||||||
const result: response = await fetchApi(url, {
|
return this.parseNovels(url);
|
||||||
headers: {
|
|
||||||
Authorization: 'Bearer guest',
|
|
||||||
},
|
|
||||||
}).then(res => res.json());
|
|
||||||
const novels: Plugin.NovelItem[] = [];
|
|
||||||
|
|
||||||
if (result.code === 'NotFound') {
|
|
||||||
return novels;
|
|
||||||
}
|
|
||||||
|
|
||||||
result?.searchResults?.forEach(novel =>
|
|
||||||
novels.push({
|
|
||||||
name: novel.title,
|
|
||||||
cover: novel.coverUrl ? this.imageSite + novel.coverUrl : defaultCover,
|
|
||||||
path: novel.id.toString(),
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
|
|
||||||
return novels;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async parseNovel(workID: string): Promise<Plugin.SourceNovel> {
|
async parseNovel(workID: string): Promise<Plugin.SourceNovel> {
|
||||||
if (!this.user) this.user = await this.getUser();
|
const html = await fetchApi(this.resolveUrl(workID, true), {
|
||||||
const book: responseBook = await fetchApi(
|
headers: { 'User-Agent': this.userAgent },
|
||||||
this.apiSite + 'work/' + workID + '/details',
|
}).then(res => res.text());
|
||||||
{
|
|
||||||
headers: {
|
|
||||||
Authorization: 'Bearer ' + this.user?.token || 'guest',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
).then(res => res.json());
|
|
||||||
|
|
||||||
const novel: Plugin.SourceNovel = {
|
const novel: Plugin.SourceNovel = {
|
||||||
path: workID,
|
path: workID,
|
||||||
name: book.title,
|
name: '',
|
||||||
cover: book.coverUrl ? book.coverUrl.split('?')[0] : defaultCover,
|
author: '',
|
||||||
genres: book.tags?.join(', '),
|
|
||||||
summary: '',
|
summary: '',
|
||||||
author:
|
|
||||||
book.originalAuthor ||
|
|
||||||
book.authorFIO ||
|
|
||||||
book.coAuthorFIO ||
|
|
||||||
book.secondCoAuthorFIO ||
|
|
||||||
book.translator ||
|
|
||||||
'',
|
|
||||||
status: book.isFinished ? NovelStatus.Completed : NovelStatus.Ongoing,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
if (book.annotation) {
|
|
||||||
novel.summary += book.annotation + '\n';
|
|
||||||
}
|
|
||||||
if (book.authorNotes) {
|
|
||||||
novel.summary += 'Примечания автора:\n' + book.authorNotes;
|
|
||||||
}
|
|
||||||
|
|
||||||
const chaptersJSON: ChaptersEntity[] = await fetchApi(
|
|
||||||
this.apiSite + 'work/' + workID + '/content',
|
|
||||||
{
|
|
||||||
headers: {
|
|
||||||
Authorization: 'Bearer ' + this.user?.token || 'guest',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
).then(res => res.json());
|
|
||||||
|
|
||||||
const chapters: Plugin.ChapterItem[] = [];
|
const chapters: Plugin.ChapterItem[] = [];
|
||||||
chaptersJSON.forEach((chapter, chapterIndex) => {
|
let isParsingName = false;
|
||||||
if (chapter.isAvailable && !chapter.isDraft) {
|
let isParsingAuthor = false;
|
||||||
chapters.push({
|
let isReadingSummary = false;
|
||||||
name: chapter.title || 'Глава ' + (chapterIndex + 1),
|
let isParsingGenres = false;
|
||||||
path: workID + '/' + chapter.id,
|
let isParsingStatus = false;
|
||||||
releaseTime: dayjs(
|
let isParsingChapter = false;
|
||||||
chapter.publishTime || chapter.lastModificationTime,
|
let isReadingChapterName = false;
|
||||||
).format('LLL'),
|
|
||||||
chapterNumber: (chapter.sortOrder || chapterIndex) + 1,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
|
let tempChapter = {} as Plugin.ChapterItem;
|
||||||
|
const parser = new Parser({
|
||||||
|
onopentag(name, attribs) {
|
||||||
|
if (name === 'h1' && attribs['class'] === 'card-title') {
|
||||||
|
isParsingName = true;
|
||||||
|
}
|
||||||
|
if (name === 'img' && attribs['class'] === 'cover-image') {
|
||||||
|
novel.cover = attribs['src'];
|
||||||
|
}
|
||||||
|
if (
|
||||||
|
name === 'a' &&
|
||||||
|
attribs['href'] &&
|
||||||
|
attribs['href'].endsWith('/works')
|
||||||
|
) {
|
||||||
|
isParsingAuthor = true;
|
||||||
|
}
|
||||||
|
if (name === 'div' && attribs['class'] === 'rich-content') {
|
||||||
|
isReadingSummary = true;
|
||||||
|
}
|
||||||
|
if (name === 'br' && isReadingSummary) {
|
||||||
|
novel.summary += '\n';
|
||||||
|
}
|
||||||
|
if (name === 'noindex') {
|
||||||
|
isParsingGenres = true;
|
||||||
|
if (novel.genres) novel.genres = '';
|
||||||
|
}
|
||||||
|
if (name === 'label' && attribs['class'].includes('label')) {
|
||||||
|
isParsingStatus = true;
|
||||||
|
}
|
||||||
|
if (name === 'li' && attribs['class'] === 'clearfix') {
|
||||||
|
isParsingChapter = true;
|
||||||
|
}
|
||||||
|
if (name === 'a' && isParsingChapter && attribs['href']) {
|
||||||
|
isReadingChapterName = true;
|
||||||
|
tempChapter.path = attribs.href.replace('/reader/', '');
|
||||||
|
}
|
||||||
|
if (name === 'span' && attribs['data-time']) {
|
||||||
|
tempChapter.releaseTime = dayjs(attribs['data-time']).format('LLL');
|
||||||
|
}
|
||||||
|
},
|
||||||
|
ontext(data) {
|
||||||
|
if (isParsingName) {
|
||||||
|
novel.name = data.trim();
|
||||||
|
isParsingName = false;
|
||||||
|
}
|
||||||
|
if (isParsingAuthor && data.trim()) {
|
||||||
|
novel.author += data.trim() + ', ';
|
||||||
|
}
|
||||||
|
if (isReadingSummary) {
|
||||||
|
novel.summary += data.trim();
|
||||||
|
}
|
||||||
|
if (isParsingGenres) {
|
||||||
|
novel.genres += data;
|
||||||
|
}
|
||||||
|
if (isParsingStatus) {
|
||||||
|
const status = data.trim();
|
||||||
|
switch (status) {
|
||||||
|
case 'в процессе':
|
||||||
|
novel.status = NovelStatus.Ongoing;
|
||||||
|
break;
|
||||||
|
case 'весь текст':
|
||||||
|
novel.status = NovelStatus.Completed;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
novel.status = NovelStatus.Unknown;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (isReadingChapterName) {
|
||||||
|
tempChapter.name = data.trim();
|
||||||
|
isReadingChapterName = false;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onclosetag(name) {
|
||||||
|
if (name === 'div' && isParsingAuthor) {
|
||||||
|
isParsingAuthor = false;
|
||||||
|
novel.author = novel.author?.slice(0, -2);
|
||||||
|
}
|
||||||
|
if (name === 'div' && isReadingSummary) {
|
||||||
|
isReadingSummary = false;
|
||||||
|
}
|
||||||
|
if (name === 'noindex') {
|
||||||
|
isParsingGenres = false;
|
||||||
|
}
|
||||||
|
if (name === 'label') {
|
||||||
|
isParsingStatus = false;
|
||||||
|
}
|
||||||
|
if (name === 'li' && isParsingChapter) {
|
||||||
|
tempChapter.chapterNumber = chapters.length;
|
||||||
|
if (tempChapter.path) {
|
||||||
|
chapters?.push(tempChapter);
|
||||||
|
}
|
||||||
|
tempChapter = {} as Plugin.ChapterItem;
|
||||||
|
isParsingChapter = false;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
});
|
||||||
|
parser.write(html);
|
||||||
|
parser.end();
|
||||||
|
|
||||||
|
if (!novel.cover) {
|
||||||
|
novel.cover = defaultCover;
|
||||||
|
}
|
||||||
|
if (!chapters.length) {
|
||||||
|
chapters.push({
|
||||||
|
name: 'Рассказ',
|
||||||
|
path: workID,
|
||||||
|
});
|
||||||
|
}
|
||||||
novel.chapters = chapters;
|
novel.chapters = chapters;
|
||||||
return novel;
|
return novel;
|
||||||
}
|
}
|
||||||
|
|
||||||
async parseChapter(chapterPath: string): Promise<string> {
|
async parseChapter(chapterPath: string): Promise<string> {
|
||||||
const [workID, chapterID] = chapterPath.split('/');
|
const html = await fetchApi(this.resolveUrl(chapterPath), {
|
||||||
if (!this.user) this.user = await this.getUser();
|
headers: { 'User-Agent': this.userAgent },
|
||||||
const result: encryptedСhapter = await fetchApi(
|
}).then(res => res.text());
|
||||||
this.apiSite + `work/${workID}/chapter/${chapterID}/text`,
|
|
||||||
{
|
|
||||||
headers: {
|
|
||||||
Authorization: 'Bearer ' + this.user?.token || 'guest',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
).then(res => res.json());
|
|
||||||
|
|
||||||
if (result.code) {
|
let [workID, chapterID] = chapterPath.split('/');
|
||||||
return result.code + '\n' + result?.message;
|
const userRaw = html.match(/userId:(.*?),/)?.[1]?.trim();
|
||||||
|
const userId = userRaw === 'null' ? '' : userRaw;
|
||||||
|
|
||||||
|
if (!chapterID) {
|
||||||
|
chapterID = html.match(/chapterId:(.*?),/)?.[1]?.trim() || '';
|
||||||
}
|
}
|
||||||
|
if (!chapterID) throw new Error('Chapter ID not found');
|
||||||
|
|
||||||
const chapterText = decrypt(result.text, result.key, this.user?.userId);
|
const chapter = await fetchApi(
|
||||||
|
this.site + '/reader/' + workID + '/chapter?id=' + chapterID,
|
||||||
|
{
|
||||||
|
headers: { 'User-Agent': this.userAgent },
|
||||||
|
},
|
||||||
|
);
|
||||||
|
const chapterJson: Result = await chapter.json();
|
||||||
|
const key = chapter.headers.get('reader-secret');
|
||||||
|
|
||||||
|
if (!key)
|
||||||
|
throw new Error('Failed to find the token\n' + chapterJson.messages);
|
||||||
|
|
||||||
|
const chapterText = decrypt(chapterJson.data.text, key, userId);
|
||||||
return chapterText;
|
return chapterText;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -144,64 +263,13 @@ class AuthorToday implements Plugin.PluginBase {
|
|||||||
): Promise<Plugin.NovelItem[]> {
|
): Promise<Plugin.NovelItem[]> {
|
||||||
const url =
|
const url =
|
||||||
this.site + '/search?category=works&q=' + searchTerm + '&page=' + pageNo;
|
this.site + '/search?category=works&q=' + searchTerm + '&page=' + pageNo;
|
||||||
const result = await fetchApi(url).then(res => res.text());
|
|
||||||
const loadedCheerio = parseHTML(result);
|
|
||||||
const novels: Plugin.NovelItem[] = [];
|
|
||||||
|
|
||||||
loadedCheerio('a.work-row').each((index, element) => {
|
return this.parseNovels(url);
|
||||||
const name = loadedCheerio(element)
|
|
||||||
.find('h4[class="work-title"]')
|
|
||||||
.text()
|
|
||||||
.trim();
|
|
||||||
let cover = loadedCheerio(element).find('img').attr('data-src');
|
|
||||||
const path = loadedCheerio(element).attr('href');
|
|
||||||
|
|
||||||
cover = cover ? cover.split('?')[0] : defaultCover;
|
|
||||||
|
|
||||||
if (!path) return;
|
|
||||||
novels.push({ name, cover, path: path.replace('/work/', '') });
|
|
||||||
});
|
|
||||||
|
|
||||||
return novels;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
resolveUrl = (path: string, isNovel?: boolean) =>
|
resolveUrl = (path: string, isNovel?: boolean) =>
|
||||||
this.site + (isNovel ? '/work/' : '/reader/') + path;
|
this.site + (isNovel ? '/work/' : '/reader/') + path;
|
||||||
|
|
||||||
user: authorization | undefined;
|
|
||||||
getUser = async () => {
|
|
||||||
let user = storage.get('user') || { userId: '', token: 'guest' };
|
|
||||||
if (user && user.userId && user.token) {
|
|
||||||
const currentUser: currentUser = await fetchApi(
|
|
||||||
this.apiSite + 'account/current-user',
|
|
||||||
{
|
|
||||||
headers: {
|
|
||||||
Authorization: 'Bearer ' + user.token || 'guest',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
).then(res => res.json());
|
|
||||||
if (currentUser?.id && !currentUser.isDisabled) return user;
|
|
||||||
|
|
||||||
storage.delete('user');
|
|
||||||
user = { userId: '', token: 'guest' };
|
|
||||||
}
|
|
||||||
|
|
||||||
const result = await fetchApi(this.site + '/account/bearer-token');
|
|
||||||
if (result.url.includes('Login?ReturnUrl=')) {
|
|
||||||
return user; //It looks like the user has lost the session
|
|
||||||
}
|
|
||||||
|
|
||||||
const loginUser: authorization = await result.json();
|
|
||||||
user = { userId: loginUser.userId, token: loginUser.token };
|
|
||||||
|
|
||||||
storage.set(
|
|
||||||
'user',
|
|
||||||
user, //for some reason they're ending an hour early.
|
|
||||||
new Date(loginUser.expires).getTime() - 1 * 60 * 60 * 1000,
|
|
||||||
);
|
|
||||||
return user; //user authorized successfully
|
|
||||||
};
|
|
||||||
|
|
||||||
filters = {
|
filters = {
|
||||||
sort: {
|
sort: {
|
||||||
label: 'Сортировка',
|
label: 'Сортировка',
|
||||||
@@ -294,9 +362,9 @@ class AuthorToday implements Plugin.PluginBase {
|
|||||||
},
|
},
|
||||||
form: {
|
form: {
|
||||||
label: 'Форма произведения',
|
label: 'Форма произведения',
|
||||||
value: 'any',
|
value: '',
|
||||||
options: [
|
options: [
|
||||||
{ label: 'Любой', value: 'any' },
|
{ label: 'Любой', value: '' },
|
||||||
{ label: 'Перевод', value: 'translation' },
|
{ label: 'Перевод', value: 'translation' },
|
||||||
{ label: 'Повесть', value: 'tale' },
|
{ label: 'Повесть', value: 'tale' },
|
||||||
{ label: 'Рассказ', value: 'story' },
|
{ label: 'Рассказ', value: 'story' },
|
||||||
@@ -308,9 +376,9 @@ class AuthorToday implements Plugin.PluginBase {
|
|||||||
},
|
},
|
||||||
state: {
|
state: {
|
||||||
label: 'Статус произведения',
|
label: 'Статус произведения',
|
||||||
value: 'any',
|
value: '',
|
||||||
options: [
|
options: [
|
||||||
{ label: 'Любой статус', value: 'any' },
|
{ label: 'Любой статус', value: '' },
|
||||||
{ label: 'В процессе', value: 'in-progress' },
|
{ label: 'В процессе', value: 'in-progress' },
|
||||||
{ label: 'Завершено', value: 'finished' },
|
{ label: 'Завершено', value: 'finished' },
|
||||||
],
|
],
|
||||||
@@ -318,9 +386,9 @@ class AuthorToday implements Plugin.PluginBase {
|
|||||||
},
|
},
|
||||||
series: {
|
series: {
|
||||||
label: 'Статус цикла',
|
label: 'Статус цикла',
|
||||||
value: 'any',
|
value: '',
|
||||||
options: [
|
options: [
|
||||||
{ label: 'Не важно', value: 'any' },
|
{ label: 'Не важно', value: '' },
|
||||||
{ label: 'Вне цикла', value: 'out' },
|
{ label: 'Вне цикла', value: 'out' },
|
||||||
{ label: 'Цикл завершен', value: 'finished' },
|
{ label: 'Цикл завершен', value: 'finished' },
|
||||||
{ label: 'Цикл не завершен', value: 'unfinished' },
|
{ label: 'Цикл не завершен', value: 'unfinished' },
|
||||||
@@ -329,9 +397,9 @@ class AuthorToday implements Plugin.PluginBase {
|
|||||||
},
|
},
|
||||||
access: {
|
access: {
|
||||||
label: 'Тип доступа',
|
label: 'Тип доступа',
|
||||||
value: 'any',
|
value: '',
|
||||||
options: [
|
options: [
|
||||||
{ label: 'Любой', value: 'any' },
|
{ label: 'Любой', value: '' },
|
||||||
{ label: 'Платный', value: 'paid' },
|
{ label: 'Платный', value: 'paid' },
|
||||||
{ label: 'Бесплатный', value: 'free' },
|
{ label: 'Бесплатный', value: 'free' },
|
||||||
],
|
],
|
||||||
@@ -354,10 +422,10 @@ export default new AuthorToday();
|
|||||||
function decrypt(
|
function decrypt(
|
||||||
encrypt: string,
|
encrypt: string,
|
||||||
encryptedKey: string,
|
encryptedKey: string,
|
||||||
userId: number | string = '',
|
userId: string | number = '',
|
||||||
) {
|
) {
|
||||||
const key = encryptedKey.split('').reverse().join('') + '@_@' + userId;
|
const key = encryptedKey.split('').reverse().join('') + '@_@' + userId;
|
||||||
const keyBytes = key.split('').map(char => char.charCodeAt());
|
const keyBytes = key.split('').map(char => char.charCodeAt(0));
|
||||||
const keyLength = keyBytes.length;
|
const keyLength = keyBytes.length;
|
||||||
let text = '';
|
let text = '';
|
||||||
|
|
||||||
@@ -370,238 +438,13 @@ function decrypt(
|
|||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
|
|
||||||
type authorization = {
|
type Result = {
|
||||||
userId: number;
|
isSuccessful: boolean;
|
||||||
token: string;
|
isWarning: boolean;
|
||||||
issued: string;
|
messages: string | null;
|
||||||
expires: string;
|
data: Data;
|
||||||
};
|
};
|
||||||
|
|
||||||
type currentUser = {
|
type Data = {
|
||||||
id: number;
|
|
||||||
userName: string;
|
|
||||||
fio: string;
|
|
||||||
email: string;
|
|
||||||
avatarUrl?: null;
|
|
||||||
backgroundUrl?: null;
|
|
||||||
status?: null;
|
|
||||||
hideDislike: boolean;
|
|
||||||
hideFinished: boolean;
|
|
||||||
isBanned: boolean;
|
|
||||||
banReason?: null;
|
|
||||||
banEnd?: null;
|
|
||||||
emailConfirmed: boolean;
|
|
||||||
isDeleted: boolean;
|
|
||||||
isDisabled: boolean;
|
|
||||||
};
|
|
||||||
|
|
||||||
type response = {
|
|
||||||
searchResults?: SearchResultsEntity[] | null;
|
|
||||||
realTotalCount: number;
|
|
||||||
code?: string;
|
|
||||||
errorMessage?: null;
|
|
||||||
isLastPage: boolean;
|
|
||||||
format: Format;
|
|
||||||
duration: Duration;
|
|
||||||
isWorkMarkEnabled: boolean;
|
|
||||||
};
|
|
||||||
type SearchResultsEntity = {
|
|
||||||
id: number;
|
|
||||||
title: string;
|
|
||||||
annotation: string;
|
|
||||||
authorId: number;
|
|
||||||
authorFIO: string;
|
|
||||||
authorUserName: string;
|
|
||||||
originalAuthor?: null;
|
|
||||||
coAuthorId?: number | null;
|
|
||||||
coAuthorFIO?: string | null;
|
|
||||||
coAuthorUserName?: string | null;
|
|
||||||
coAuthorConfirmed: boolean;
|
|
||||||
seriesId: number;
|
|
||||||
seriesTitle?: string | null;
|
|
||||||
publishTime: string;
|
|
||||||
lastModificationTime: string;
|
|
||||||
finishTime?: string | null;
|
|
||||||
isDraft: boolean;
|
|
||||||
formEnum: string;
|
|
||||||
genreId: number;
|
|
||||||
firstSubGenreId: number;
|
|
||||||
secondSubGenreId?: number | null;
|
|
||||||
adultOnly: boolean;
|
|
||||||
tags?: (string | null)[] | null;
|
|
||||||
coverUrl: string;
|
|
||||||
viewCount: number;
|
|
||||||
commentCount: number;
|
|
||||||
reviewCount: number;
|
|
||||||
textLength: number;
|
|
||||||
likeCount: number;
|
|
||||||
showAuthor: boolean;
|
|
||||||
price?: number | null;
|
|
||||||
discount?: null;
|
|
||||||
discountStartDate?: null;
|
|
||||||
discountEndDate?: null;
|
|
||||||
status: string;
|
|
||||||
promoFragment: boolean;
|
|
||||||
isExclusive: boolean;
|
|
||||||
format: string;
|
|
||||||
marks?: null[] | null;
|
|
||||||
isLiked: boolean;
|
|
||||||
isWorkMarkEnabled: boolean;
|
|
||||||
workInLibraryState: string;
|
|
||||||
};
|
|
||||||
type Format = {
|
|
||||||
enumValue: string;
|
|
||||||
value: string;
|
|
||||||
title: string;
|
|
||||||
mobileTitle: string;
|
|
||||||
};
|
|
||||||
type Duration = {
|
|
||||||
value: string;
|
|
||||||
title: string;
|
|
||||||
mobileTitle: string;
|
|
||||||
};
|
|
||||||
|
|
||||||
type responseBook = {
|
|
||||||
message?: string;
|
|
||||||
chapters?: ChaptersEntity[] | null;
|
|
||||||
allowDownloads: boolean;
|
|
||||||
downloadErrorCode: string;
|
|
||||||
downloadErrorMessage: string;
|
|
||||||
privacyDownloads: string;
|
|
||||||
collectionCount: number;
|
|
||||||
annotation: string;
|
|
||||||
authorNotes: string;
|
|
||||||
atRecommendation: boolean;
|
|
||||||
seriesWorkIds?: number[] | null;
|
|
||||||
seriesWorkNumber: number;
|
|
||||||
reviewCount: number;
|
|
||||||
tags?: string[] | null;
|
|
||||||
orderId?: null;
|
|
||||||
orderStatus: string;
|
|
||||||
orderStatusMessage?: null;
|
|
||||||
contests?: null[] | null;
|
|
||||||
galleryImages?: GalleryImagesEntity[] | null;
|
|
||||||
booktrailerVideoUrl?: null;
|
|
||||||
isExclusive: boolean;
|
|
||||||
freeChapterCount: number;
|
|
||||||
promoFragment: boolean;
|
|
||||||
recommendations?: RecommendationsEntity[] | null;
|
|
||||||
linkedWork?: null;
|
|
||||||
id: number;
|
|
||||||
title: string;
|
|
||||||
coverUrl: string;
|
|
||||||
lastModificationTime: string;
|
|
||||||
lastUpdateTime: string;
|
|
||||||
finishTime?: null;
|
|
||||||
isFinished: boolean;
|
|
||||||
textLength: number;
|
|
||||||
textLengthLastRead: number;
|
|
||||||
price: number;
|
|
||||||
discount?: null;
|
|
||||||
workForm: string;
|
|
||||||
status: string;
|
|
||||||
authorId: number;
|
|
||||||
authorFIO: string;
|
|
||||||
authorUserName: string;
|
|
||||||
originalAuthor?: null;
|
|
||||||
translator?: null;
|
|
||||||
reciter?: null;
|
|
||||||
coAuthorId?: null;
|
|
||||||
coAuthorFIO?: null;
|
|
||||||
coAuthorUserName?: null;
|
|
||||||
coAuthorConfirmed: boolean;
|
|
||||||
secondCoAuthorId?: null;
|
|
||||||
secondCoAuthorFIO?: null;
|
|
||||||
secondCoAuthorUserName?: null;
|
|
||||||
secondCoAuthorConfirmed: boolean;
|
|
||||||
isPurchased: boolean;
|
|
||||||
userLikeId?: null;
|
|
||||||
lastReadTime?: null;
|
|
||||||
lastChapterId?: null;
|
|
||||||
lastChapterProgress: number;
|
|
||||||
likeCount: number;
|
|
||||||
commentCount: number;
|
|
||||||
rewardCount: number;
|
|
||||||
rewardsEnabled: boolean;
|
|
||||||
inLibraryState: string;
|
|
||||||
addedToLibraryTime: string;
|
|
||||||
updateInLibraryTime: string;
|
|
||||||
privacyDisplay: string;
|
|
||||||
state: string;
|
|
||||||
isDraft: boolean;
|
|
||||||
enableRedLine: boolean;
|
|
||||||
enableTTS: boolean;
|
|
||||||
adultOnly: boolean;
|
|
||||||
seriesId: number;
|
|
||||||
seriesOrder: number;
|
|
||||||
seriesTitle: string;
|
|
||||||
afterword: string;
|
|
||||||
seriesNextWorkId?: null;
|
|
||||||
genreId: number;
|
|
||||||
firstSubGenreId: number;
|
|
||||||
secondSubGenreId: number;
|
|
||||||
format: string;
|
|
||||||
marks?: null;
|
|
||||||
purchaseTime?: null;
|
|
||||||
likeTime?: null;
|
|
||||||
markTime?: null;
|
|
||||||
};
|
|
||||||
type ChaptersEntity = {
|
|
||||||
id: number;
|
|
||||||
workId: number;
|
|
||||||
title: string;
|
|
||||||
isDraft: boolean;
|
|
||||||
sortOrder: number;
|
|
||||||
publishTime?: string;
|
|
||||||
lastModificationTime: string;
|
|
||||||
textLength: number;
|
|
||||||
isAvailable: boolean;
|
|
||||||
};
|
|
||||||
|
|
||||||
type GalleryImagesEntity = {
|
|
||||||
id: string;
|
|
||||||
caption?: null;
|
|
||||||
url: string;
|
|
||||||
height: number;
|
|
||||||
width: number;
|
|
||||||
};
|
|
||||||
type RecommendationsEntity = {
|
|
||||||
title: string;
|
|
||||||
coverUrl: string;
|
|
||||||
authorId: number;
|
|
||||||
authorFIO: string;
|
|
||||||
authorUserName: string;
|
|
||||||
originalAuthor?: null;
|
|
||||||
coAuthorId?: null;
|
|
||||||
coAuthorFIO?: null;
|
|
||||||
coAuthorUserName?: null;
|
|
||||||
coAuthorConfirmed: boolean;
|
|
||||||
secondCoAuthorId?: null;
|
|
||||||
secondCoAuthorFIO?: null;
|
|
||||||
secondCoAuthorUserName?: null;
|
|
||||||
secondCoAuthorConfirmed: boolean;
|
|
||||||
discount?: null;
|
|
||||||
price?: number | null;
|
|
||||||
lastModificationTime: string;
|
|
||||||
finishTime: string;
|
|
||||||
finished: boolean;
|
|
||||||
isExclusive: boolean;
|
|
||||||
format: string;
|
|
||||||
status: string;
|
|
||||||
state: string;
|
|
||||||
removalReason?: null;
|
|
||||||
removalReasonComment?: null;
|
|
||||||
id: number;
|
|
||||||
};
|
|
||||||
|
|
||||||
type encryptedСhapter = {
|
|
||||||
id: number;
|
|
||||||
title: string;
|
|
||||||
isDraft: boolean;
|
|
||||||
publishTime: string;
|
|
||||||
lastModificationTime: string;
|
|
||||||
text: string;
|
text: string;
|
||||||
key: string;
|
|
||||||
code?: string;
|
|
||||||
message?: string;
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ class Neobook implements Plugin.PluginBase {
|
|||||||
name = 'Neobook';
|
name = 'Neobook';
|
||||||
site = 'https://neobook.org';
|
site = 'https://neobook.org';
|
||||||
apiSite = 'https://api.neobook.org/';
|
apiSite = 'https://api.neobook.org/';
|
||||||
version = '1.0.1';
|
version = '1.0.2';
|
||||||
icon = 'src/ru/neobook/icon.png';
|
icon = 'src/ru/neobook/icon.png';
|
||||||
|
|
||||||
async fetchNovels(
|
async fetchNovels(
|
||||||
@@ -29,7 +29,7 @@ class Neobook implements Plugin.PluginBase {
|
|||||||
searchTerm?: string,
|
searchTerm?: string,
|
||||||
): Promise<Plugin.NovelItem[]> {
|
): Promise<Plugin.NovelItem[]> {
|
||||||
const formData = new FormData();
|
const formData = new FormData();
|
||||||
formData.append('version', '4.0');
|
formData.append('version', '4.4');
|
||||||
formData.append('uid', '0');
|
formData.append('uid', '0');
|
||||||
formData.append('utoken', '');
|
formData.append('utoken', '');
|
||||||
formData.append('resource', 'general');
|
formData.append('resource', 'general');
|
||||||
@@ -52,6 +52,7 @@ class Neobook implements Plugin.PluginBase {
|
|||||||
{
|
{
|
||||||
method: 'post',
|
method: 'post',
|
||||||
body: formData,
|
body: formData,
|
||||||
|
referrer: this.site,
|
||||||
},
|
},
|
||||||
).then(res => res.json());
|
).then(res => res.json());
|
||||||
const novels: Plugin.NovelItem[] = [];
|
const novels: Plugin.NovelItem[] = [];
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ class Zelluloza implements Plugin.PluginBase {
|
|||||||
id = 'zelluloza';
|
id = 'zelluloza';
|
||||||
name = 'Целлюлоза';
|
name = 'Целлюлоза';
|
||||||
site = 'https://zelluloza.ru';
|
site = 'https://zelluloza.ru';
|
||||||
version = '1.0.2';
|
version = '1.0.3';
|
||||||
icon = 'src/ru/zelluloza/icon.png';
|
icon = 'src/ru/zelluloza/icon.png';
|
||||||
|
|
||||||
async popularNovels(
|
async popularNovels(
|
||||||
@@ -21,17 +21,28 @@ class Zelluloza implements Plugin.PluginBase {
|
|||||||
): Promise<Plugin.NovelItem[]> {
|
): Promise<Plugin.NovelItem[]> {
|
||||||
const sort = showLatestNovels ? '0' : filters?.sort?.value || '3';
|
const sort = showLatestNovels ? '0' : filters?.sort?.value || '3';
|
||||||
|
|
||||||
const path = filters?.genres?.value
|
const genres = filters?.genres?.value || '0';
|
||||||
? `/search/genres/${filters.genres.value}/?page=${pageNo}`
|
|
||||||
: `/top/freebooks/?sort_order=${sort}&page=${pageNo}`;
|
|
||||||
|
|
||||||
const body = await fetchApi(this.site + path).then(res => res.text());
|
const body = await fetchApi(this.site + '/ajaxcall/', {
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/x-www-form-urlencoded',
|
||||||
|
Referer: this.site + '/search/done/#result',
|
||||||
|
Origin: this.site,
|
||||||
|
},
|
||||||
|
method: 'POST',
|
||||||
|
body: new URLSearchParams({
|
||||||
|
op: 'morebooks',
|
||||||
|
par1: '',
|
||||||
|
par2: `206:0:${genres}:0.${sort}.0.0.0.0.0.0.0.0.0.0.0..0..:${pageNo}`,
|
||||||
|
par4: '',
|
||||||
|
}).toString(),
|
||||||
|
}).then(res => res.text());
|
||||||
const loadedCheerio = parseHTML(body);
|
const loadedCheerio = parseHTML(body);
|
||||||
const novels: Plugin.NovelItem[] = [];
|
const novels: Plugin.NovelItem[] = [];
|
||||||
|
|
||||||
loadedCheerio('section[class="book-card-item"]').each((index, element) => {
|
loadedCheerio('div[style="display: flex;"]').each((index, element) => {
|
||||||
novels.push({
|
novels.push({
|
||||||
name: loadedCheerio(element).find('span[itemprop="name"]').text() || '',
|
name: loadedCheerio(element).find('a[class="txt"]').attr('title') || '',
|
||||||
cover:
|
cover:
|
||||||
this.site +
|
this.site +
|
||||||
loadedCheerio(element).find('img[class="shadow"]').attr('src'),
|
loadedCheerio(element).find('img[class="shadow"]').attr('src'),
|
||||||
@@ -45,7 +56,7 @@ class Zelluloza implements Plugin.PluginBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async parseNovel(novelPath: string): Promise<Plugin.SourceNovel> {
|
async parseNovel(novelPath: string): Promise<Plugin.SourceNovel> {
|
||||||
const body = await fetchApi(this.resolveUrl(novelPath, true)).then(res =>
|
const body = await fetchApi(this.resolveUrl(novelPath)).then(res =>
|
||||||
res.text(),
|
res.text(),
|
||||||
);
|
);
|
||||||
const loadedCheerio = parseHTML(body);
|
const loadedCheerio = parseHTML(body);
|
||||||
@@ -54,7 +65,10 @@ class Zelluloza implements Plugin.PluginBase {
|
|||||||
path: novelPath,
|
path: novelPath,
|
||||||
name: loadedCheerio('h2[class="bookname"]').text().trim(),
|
name: loadedCheerio('h2[class="bookname"]').text().trim(),
|
||||||
cover: this.site + loadedCheerio('img[class="shadow"]').attr('src'),
|
cover: this.site + loadedCheerio('img[class="shadow"]').attr('src'),
|
||||||
genres: loadedCheerio('.gnres').text()?.split?.(': ')?.[1],
|
genres: loadedCheerio('.gnres span[itemprop="genre"]')
|
||||||
|
.map((index, element) => loadedCheerio(element).text())
|
||||||
|
.get()
|
||||||
|
.join(','),
|
||||||
summary:
|
summary:
|
||||||
loadedCheerio('#bann_full').text() ||
|
loadedCheerio('#bann_full').text() ||
|
||||||
loadedCheerio('#bann_short').text(),
|
loadedCheerio('#bann_short').text(),
|
||||||
@@ -153,7 +167,7 @@ class Zelluloza implements Plugin.PluginBase {
|
|||||||
|
|
||||||
loadedCheerio('div[style="display: flex;"]').each((index, element) => {
|
loadedCheerio('div[style="display: flex;"]').each((index, element) => {
|
||||||
novels.push({
|
novels.push({
|
||||||
name: loadedCheerio(element).find('span[itemprop="name"]').text() || '',
|
name: loadedCheerio(element).find('a[class="txt"]').attr('title') || '',
|
||||||
cover:
|
cover:
|
||||||
this.site +
|
this.site +
|
||||||
loadedCheerio(element).find('img[class="shadow"]').attr('src'),
|
loadedCheerio(element).find('img[class="shadow"]').attr('src'),
|
||||||
@@ -191,6 +205,7 @@ class Zelluloza implements Plugin.PluginBase {
|
|||||||
{ label: 'По длительности чтения', value: '1' },
|
{ label: 'По длительности чтения', value: '1' },
|
||||||
{ label: 'По количеству читателей', value: '2' },
|
{ label: 'По количеству читателей', value: '2' },
|
||||||
{ label: 'По популярности', value: '4' },
|
{ label: 'По популярности', value: '4' },
|
||||||
|
{ label: 'Самые продаваемые', value: '5' },
|
||||||
],
|
],
|
||||||
type: FilterTypes.Picker,
|
type: FilterTypes.Picker,
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user