diff --git a/src/sources/ru/jaomix.js b/src/sources/ru/jaomix.js index 4b464270..b03cf0da 100644 --- a/src/sources/ru/jaomix.js +++ b/src/sources/ru/jaomix.js @@ -13,18 +13,24 @@ const popularNovels = async page => { const loadedCheerio = cheerio.load(body); let novels = []; - loadedCheerio('div[class="block-home"] > div[class="one"]').each(function() { - const novelName = loadedCheerio(this).find('div[class="img-home"] > a').attr('title'); - const novelCover = loadedCheerio(this).find('div[class="img-home"] > a > img') - .attr('src').replace("-150x150", ""); - const novelUrl = loadedCheerio(this).find('div[class="img-home"] > a').attr('href'); + loadedCheerio('div[class="block-home"] > div[class="one"]').each(function () { + const novelName = loadedCheerio(this) + .find('div[class="img-home"] > a') + .attr('title'); + const novelCover = loadedCheerio(this) + .find('div[class="img-home"] > a > img') + .attr('src') + .replace('-150x150', ''); + const novelUrl = loadedCheerio(this) + .find('div[class="img-home"] > a') + .attr('href'); const novel = { sourceId, novelName, novelCover, novelUrl }; novels.push(novel); }); return { totalPages, novels }; -} +}; const parseNovelAndChapters = async novelUrl => { const result = await fetch(novelUrl); @@ -42,7 +48,7 @@ const parseNovelAndChapters = async novelUrl => { novel.novelCover = loadedCheerio('div[class="img-book"] > img').attr('src'); novel.summary = loadedCheerio('div[id="desc-tab"]').text().trim(); - const termid = loadedCheerio('div[class="like-but"]').attr('id') + const termid = loadedCheerio('div[class="like-but"]').attr('id'); const chapters = []; let formData = new FormData(); @@ -51,15 +57,15 @@ const parseNovelAndChapters = async novelUrl => { let doc = await fetch(baseUrl + '/wp-admin/admin-ajax.php', { method: 'POST', - body: formData + body: formData, }); - let results2 = await doc.text() - let loadedCheerio2 = cheerio.load(results2) - let page = loadedCheerio2('option').length + let results2 = await doc.text(); + let loadedCheerio2 = cheerio.load(results2); + let page = loadedCheerio2('option').length; for (let i = 0; i < page; i++) { if (i == 0) { - loadedCheerio2 = loadedCheerio + loadedCheerio2 = loadedCheerio; } else { formData = new FormData(); formData.append('action', 'toc'); @@ -67,16 +73,22 @@ const parseNovelAndChapters = async novelUrl => { formData.append('termid', termid); doc = await fetch(baseUrl + '/wp-admin/admin-ajax.php', { method: 'POST', - body: formData + body: formData, }); - results2 = await doc.text() - loadedCheerio2 = cheerio.load(results2) + results2 = await doc.text(); + loadedCheerio2 = cheerio.load(results2); } - loadedCheerio2('div[class="hiddenstab active"] > div > div[class="flex-dow-txt"]').each(function() { - const chapterName = loadedCheerio2(this).find('div[class="title"] > a').attr("title") + loadedCheerio2( + 'div[class="hiddenstab active"] > div > div[class="flex-dow-txt"]', + ).each(function () { + const chapterName = loadedCheerio2(this) + .find('div[class="title"] > a') + .attr('title'); const releaseDate = loadedCheerio2(this).find('time').text(); - const chapterUrl = loadedCheerio2(this).find('div[class="title"] > a').attr("href"); + const chapterUrl = loadedCheerio2(this) + .find('div[class="title"] > a') + .attr('href'); chapters.push({ chapterName, releaseDate, chapterUrl }); }); @@ -91,13 +103,13 @@ const parseChapter = async (novelUrl, chapterUrl) => { const body = await result.text(); const loadedCheerio = cheerio.load(body); - loadedCheerio('img').each(function() { + loadedCheerio('img').each(function () { if (!loadedCheerio(this).attr('src')?.startsWith('http')) { let src = loadedCheerio(this).attr('src'); loadedCheerio(this).attr('src', baseUrl + src); } - }) - loadedCheerio('div[class="adblock-service"]').remove() + }); + loadedCheerio('div[class="adblock-service"]').remove(); const chapterName = loadedCheerio('h1[class="entry-title"]').html(); const chapterText = loadedCheerio('div[class="entry-content"]').html(); @@ -119,11 +131,17 @@ const searchNovels = async searchTerm => { const loadedCheerio = cheerio.load(body); let novels = []; - loadedCheerio('div[class="block-home"] > div[class="one"]').each(function() { - const novelName = loadedCheerio(this).find('div[class="img-home"] > a').attr('title'); - const novelCover = loadedCheerio(this).find('div[class="img-home"] > a > img') - .attr('src').replace("-150x150", ""); - const novelUrl = loadedCheerio(this).find('div[class="img-home"] > a').attr('href'); + loadedCheerio('div[class="block-home"] > div[class="one"]').each(function () { + const novelName = loadedCheerio(this) + .find('div[class="img-home"] > a') + .attr('title'); + const novelCover = loadedCheerio(this) + .find('div[class="img-home"] > a > img') + .attr('src') + .replace('-150x150', ''); + const novelUrl = loadedCheerio(this) + .find('div[class="img-home"] > a') + .attr('href'); const novel = { sourceId, novelName, novelCover, novelUrl }; novels.push(novel); @@ -137,4 +155,4 @@ const JaomixScraper = { searchNovels, }; -export default JaomixScraper; \ No newline at end of file +export default JaomixScraper; diff --git a/src/sources/ru/ranobelib.js b/src/sources/ru/ranobelib.js index 5d576860..e05fa8ef 100644 --- a/src/sources/ru/ranobelib.js +++ b/src/sources/ru/ranobelib.js @@ -18,7 +18,8 @@ const popularNovels = async page => { loadedCheerio('.media-card-wrap').each(function () { const novelName = loadedCheerio(this).find('.media-card__title').text(); - const novelCover = baseUrl + loadedCheerio(this).find('a.media-card').attr('data-src'); + const novelCover = + baseUrl + loadedCheerio(this).find('a.media-card').attr('data-src'); const novelUrl = loadedCheerio(this).find('a.media-card').attr('href'); const novel = { sourceId, novelName, novelCover, novelUrl }; @@ -127,7 +128,8 @@ const searchNovels = async searchTerm => { loadedCheerio('.media-card-wrap').each(function () { const novelName = loadedCheerio(this).find('.media-card__title').text(); - const novelCover = baseUrl + loadedCheerio(this).find('a.media-card').attr('data-src'); + const novelCover = + baseUrl + loadedCheerio(this).find('a.media-card').attr('data-src'); const novelUrl = loadedCheerio(this).find('a.media-card').attr('href'); const novel = { sourceId, novelName, novelCover, novelUrl }; diff --git a/src/sources/ru/ranoberf.js b/src/sources/ru/ranoberf.js index ea9924fd..f07beb6b 100644 --- a/src/sources/ru/ranoberf.js +++ b/src/sources/ru/ranoberf.js @@ -47,11 +47,13 @@ const parseNovelAndChapters = async novelUrl => { let chapters = []; json.props.pageProps.book.chapters.map(item => { - const chapterName = item.title + const chapterName = item.title; const releaseDate = item.publishedAt; const chapterUrl = baseUrl + item.url; - if (!item.isDonate) chapters.push({ chapterName, releaseDate, chapterUrl }); + if (!item.isDonate) { + chapters.push({ chapterName, releaseDate, chapterUrl }); + } }); novel.chapters = chapters.reverse(); @@ -66,10 +68,10 @@ const parseChapter = async (novelUrl, chapterUrl) => { let json = loadedCheerio('#__NEXT_DATA__').html(); json = JSON.parse(json); - const chapterName = json.props.pageProps.chapter.title + const chapterName = json.props.pageProps.chapter.title; let temp = cheerio.load(json.props.pageProps.chapter.content.text); - temp('img').each(function() { + temp('img').each(function () { if (!loadedCheerio(this).attr('src')?.startsWith('http')) { let src = loadedCheerio(this).attr('src'); loadedCheerio(this).attr('src', baseUrl + src); diff --git a/src/sources/ru/renovels.js b/src/sources/ru/renovels.js index 2bc2ba7a..cff8c36e 100644 --- a/src/sources/ru/renovels.js +++ b/src/sources/ru/renovels.js @@ -33,17 +33,21 @@ const parseNovelAndChapters = async novelUrl => { sourceName, url: baseUrl + 'novel/' + body.content.dir, novelName: body.content.rus_name, - novelCover: 'https://api.renovels.org' + body.content.img?.high || body.content.img?.low, + novelCover: + 'https://api.renovels.org' + body.content.img?.high || + body.content.img?.low, summary: htmlToText(body.content.description), novelUrl, }; - let all = (body.content.count_chapters / 100 + 1) ^ 0 + let all = (body.content.count_chapters / 100 + 1) ^ 0; let chapters = []; for (let i = 0; i < all; i++) { let chapterResult = await fetch( - `https://api.renovels.org/api/titles/chapters/?branch_id=${body.content.branches[0].id}&count=100&page=${i + 1}`, + `https://api.renovels.org/api/titles/chapters/?branch_id=${ + body.content.branches[0].id + }&count=100&page=${i + 1}`, ); let volumes = await chapterResult.json(); @@ -51,9 +55,12 @@ const parseNovelAndChapters = async novelUrl => { const chapterName = `Том ${item.tome} Глава ${item.chapter} ${item.name}`?.trim(); const releaseDate = item.upload_date; - const chapterUrl = 'https://api.renovels.org/api/titles/chapters/' + item.id + '/'; + const chapterUrl = + 'https://api.renovels.org/api/titles/chapters/' + item.id + '/'; - if (!item.is_paid) chapters.push({ chapterName, releaseDate, chapterUrl }); + if (!item.is_paid) { + chapters.push({ chapterName, releaseDate, chapterUrl }); + } }); } @@ -100,4 +107,4 @@ const RenovelsScraper = { searchNovels, }; -export default RenovelsScraper; \ No newline at end of file +export default RenovelsScraper; diff --git a/src/sources/ru/rulate.js b/src/sources/ru/rulate.js index 798ec088..c10640d9 100644 --- a/src/sources/ru/rulate.js +++ b/src/sources/ru/rulate.js @@ -13,9 +13,10 @@ const popularNovels = async page => { const loadedCheerio = cheerio.load(body); let novels = []; - loadedCheerio('.imged > li').each(function() { + loadedCheerio('.imged > li').each(function () { const novelName = loadedCheerio(this).find('p > a').text(); - const novelCover = baseUrl + loadedCheerio(this).find('div').attr('style').split("'")[1]; + const novelCover = + baseUrl + loadedCheerio(this).find('div').attr('style').split("'")[1]; const novelUrl = loadedCheerio(this).find('p > a').attr('href'); const novel = { sourceId, novelName, novelCover, novelUrl }; @@ -37,15 +38,23 @@ const parseNovelAndChapters = async novelUrl => { novelUrl, }; - novel.novelName = loadedCheerio('div[class="container"] > div > div > h1').text().trim(); - novel.novelCover = baseUrl + loadedCheerio('div[class="images"] > div img').attr('src'); + novel.novelName = loadedCheerio('div[class="container"] > div > div > h1') + .text() + .trim(); + novel.novelCover = + baseUrl + loadedCheerio('div[class="images"] > div img').attr('src'); novel.summary = loadedCheerio('#Info > div:nth-child(3)').text().trim(); let chapters = []; - loadedCheerio('table > tbody > tr.chapter_row').each(function() { - const chapterName = loadedCheerio(this).find('td[class="t"] > a').text().trim() - const releaseDate = null - const chapterUrl = loadedCheerio(this).find('td[class="t"] > a').attr("href"); + loadedCheerio('table > tbody > tr.chapter_row').each(function () { + const chapterName = loadedCheerio(this) + .find('td[class="t"] > a') + .text() + .trim(); + const releaseDate = null; + const chapterUrl = loadedCheerio(this) + .find('td[class="t"] > a') + .attr('href'); if (loadedCheerio(this).find('td > span[class="disabled"]').length < 1) { chapters.push({ chapterName, releaseDate, chapterUrl }); @@ -61,14 +70,18 @@ const parseChapter = async (novelUrl, chapterUrl) => { const body = await result.text(); const loadedCheerio = cheerio.load(body); - loadedCheerio('.content-text img').each(function() { + loadedCheerio('.content-text img').each(function () { if (!loadedCheerio(this).attr('src')?.startsWith('http')) { const src = loadedCheerio(this).attr('src'); loadedCheerio(this).attr('src', baseUrl + src); } }); - const chapterName = loadedCheerio('.chapter_select > select > option[selected]').text().trim(); + const chapterName = loadedCheerio( + '.chapter_select > select > option[selected]', + ) + .text() + .trim(); const chapterText = loadedCheerio('.content-text').html(); const chapter = { @@ -83,9 +96,11 @@ const parseChapter = async (novelUrl, chapterUrl) => { }; const searchNovels = async searchTerm => { - const result = await fetch(baseUrl + '/search/autocomplete?query=' + searchTerm); + const result = await fetch( + baseUrl + '/search/autocomplete?query=' + searchTerm, + ); let json = await result.json(); - let novels = [] + let novels = []; json.map(item => { const novelName = item.title_one + ' / ' + item.title_two; @@ -105,4 +120,4 @@ const RulateLibScraper = { searchNovels, }; -export default RulateLibScraper; \ No newline at end of file +export default RulateLibScraper; diff --git a/src/sources/sourceManager.ts b/src/sources/sourceManager.ts index 375ed640..9c15693f 100644 --- a/src/sources/sourceManager.ts +++ b/src/sources/sourceManager.ts @@ -255,4 +255,4 @@ export const sourceManager = (sourceId: number): Scraper => { }; return scrapers[sourceId]; -}; \ No newline at end of file +};