eslint quick-fix (#87)
* fix(github-check): Catch github connection errors * fix(eslint): fixed eslint warnings and errors Fixed every eslint warning and error that wasn't one of the following: - react-hooks/exhaustive-deps - no-console Added .vscode to .gitignore Added no-console:warn to eslintrc * fix(gradlew): set file to runnable (chmod 755) * remove .vscode
This commit is contained in:
@@ -3,5 +3,6 @@ module.exports = {
|
||||
extends: '@react-native-community',
|
||||
rules: {
|
||||
'react-native/no-inline-styles': 'off',
|
||||
'no-console': 'warn',
|
||||
},
|
||||
};
|
||||
|
||||
+3
-1
@@ -70,4 +70,6 @@ buck-out/
|
||||
.expo/
|
||||
web-build/
|
||||
|
||||
# @end expo-cli
|
||||
# @end expo-cli
|
||||
|
||||
.vscode/
|
||||
@@ -21,7 +21,7 @@ const ColorPickerModal = ({
|
||||
setError();
|
||||
};
|
||||
|
||||
const onChangeText = text => setText(text);
|
||||
const onChangeText = txt => setText(txt);
|
||||
|
||||
const onSubmitEditing = () => {
|
||||
const re = /^#([0-9a-f]{6}|[0-9a-f]{3})$/i;
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
/* eslint-disable no-bitwise */
|
||||
|
||||
import PropTypes from 'prop-types';
|
||||
import React, {PureComponent, Children} from 'react';
|
||||
import {View, Animated, StyleSheet} from 'react-native';
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
/* eslint-disable no-unused-vars */
|
||||
|
||||
import React from 'react';
|
||||
import {StyleSheet} from 'react-native';
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ import React from 'react';
|
||||
import {Text, View} from 'react-native';
|
||||
|
||||
import {IconButton} from 'react-native-paper';
|
||||
import {Row} from './Common';
|
||||
// import {Row} from './Common';
|
||||
|
||||
import EmptyView from './EmptyView';
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ import React from 'react';
|
||||
import {Pressable, StyleSheet, Text, View} from 'react-native';
|
||||
import {IconButton} from 'react-native-paper';
|
||||
|
||||
const icons = ['(・o・;)', 'Σ(ಠ_ಠ)', 'ಥ_ಥ', '(˘・_・˘)', '(; ̄Д ̄)', '(・Д・。'];
|
||||
// const icons = ['(・o・;)', 'Σ(ಠ_ಠ)', 'ಥ_ಥ', '(˘・_・˘)', '(; ̄Д ̄)', '(・Д・。'];
|
||||
|
||||
export const ErrorView = ({errorName, actions, theme}) => (
|
||||
<View style={{flex: 1, justifyContent: 'center', alignItems: 'center'}}>
|
||||
|
||||
@@ -12,7 +12,7 @@ import FastImage from 'react-native-fast-image';
|
||||
|
||||
import ListView from './ListView';
|
||||
|
||||
import {getDeviceOrientation} from '../services/utils/helpers';
|
||||
import {useDeviceOrientation} from '../services/utils/helpers';
|
||||
import {useSettings} from '../hooks/reduxHooks';
|
||||
import {defaultCoverUri} from '../sources/helpers/constants';
|
||||
|
||||
@@ -30,7 +30,7 @@ const NovelCover = ({
|
||||
|
||||
const window = useWindowDimensions();
|
||||
|
||||
const orientation = getDeviceOrientation();
|
||||
const orientation = useDeviceOrientation();
|
||||
|
||||
const getNovelsPerRow = () =>
|
||||
orientation === 'landscape' ? 6 : novelsPerRow;
|
||||
|
||||
@@ -2,7 +2,7 @@ import React, {useCallback} from 'react';
|
||||
import {StyleSheet, FlatList} from 'react-native';
|
||||
|
||||
import {useSettings} from '../hooks/reduxHooks';
|
||||
import {getDeviceOrientation} from '../services/utils/helpers';
|
||||
import {useDeviceOrientation} from '../services/utils/helpers';
|
||||
|
||||
const NovelList = ({
|
||||
data,
|
||||
@@ -15,7 +15,7 @@ const NovelList = ({
|
||||
}) => {
|
||||
const {displayMode, novelsPerRow} = useSettings();
|
||||
|
||||
const orientation = getDeviceOrientation();
|
||||
const orientation = useDeviceOrientation();
|
||||
|
||||
const getNovelsPerRow = () => {
|
||||
if (displayMode === 2) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import React from 'react';
|
||||
import {View, Text, StyleSheet, Pressable} from 'react-native';
|
||||
import {View, Text, /* StyleSheet, */ Pressable} from 'react-native';
|
||||
import MaterialCommunityIcons from 'react-native-vector-icons/MaterialCommunityIcons';
|
||||
|
||||
export const ThemePicker = ({theme, currentTheme, onPress}) => (
|
||||
@@ -15,7 +15,7 @@ export const ThemePicker = ({theme, currentTheme, onPress}) => (
|
||||
backgroundColor: theme.colorPrimaryDark,
|
||||
borderWidth: 3.6,
|
||||
borderColor:
|
||||
currentTheme.id == theme.id
|
||||
currentTheme.id === theme.id
|
||||
? theme.colorAccent
|
||||
: currentTheme.colorPrimaryDark,
|
||||
width: 95,
|
||||
@@ -26,7 +26,7 @@ export const ThemePicker = ({theme, currentTheme, onPress}) => (
|
||||
}}
|
||||
>
|
||||
<Pressable style={{flex: 1}} onPress={onPress}>
|
||||
{currentTheme.id == theme.id && (
|
||||
{currentTheme.id === theme.id && (
|
||||
<MaterialCommunityIcons
|
||||
name="check"
|
||||
color={theme.colorButtonText}
|
||||
@@ -169,4 +169,4 @@ export const ThemePicker = ({theme, currentTheme, onPress}) => (
|
||||
</View>
|
||||
);
|
||||
|
||||
const styles = StyleSheet.create({});
|
||||
// const styles = StyleSheet.create({});
|
||||
|
||||
@@ -16,7 +16,7 @@ import {
|
||||
import {createDownloadTableQuery} from './tables/DownloadTable';
|
||||
import {
|
||||
createUpdatesTableQuery,
|
||||
updatesSeedDataQuery,
|
||||
// updatesSeedDataQuery,
|
||||
} from './tables/UpdateTable';
|
||||
|
||||
/**
|
||||
|
||||
@@ -2,7 +2,8 @@ import * as SQLite from 'expo-sqlite';
|
||||
import {getSource} from '../../sources/sources';
|
||||
const db = SQLite.openDatabase('lnreader.db');
|
||||
|
||||
const insertChaptersQuery = `INSERT INTO chapters (chapterUrl, chapterName, releaseDate, novelId) values (?, ?, ?, ?)`;
|
||||
const insertChaptersQuery =
|
||||
'INSERT INTO chapters (chapterUrl, chapterName, releaseDate, novelId) values (?, ?, ?, ?)';
|
||||
|
||||
export const insertChapters = async (novelId, chapters) => {
|
||||
db.transaction(tx => {
|
||||
@@ -53,7 +54,7 @@ export const getChapters = (novelId, sort, filter) => {
|
||||
);
|
||||
};
|
||||
|
||||
const getChapterQuery = `SELECT * FROM downloads WHERE downloadChapterId = ?`;
|
||||
const getChapterQuery = 'SELECT * FROM downloads WHERE downloadChapterId = ?';
|
||||
|
||||
export const getChapterFromDB = async chapterId => {
|
||||
return new Promise((resolve, reject) =>
|
||||
@@ -61,7 +62,7 @@ export const getChapterFromDB = async chapterId => {
|
||||
tx.executeSql(
|
||||
getChapterQuery,
|
||||
[chapterId],
|
||||
(tx, results) => {
|
||||
(txObj, results) => {
|
||||
resolve(results.rows.item(0));
|
||||
},
|
||||
(txObj, error) => console.log('Error ', error),
|
||||
@@ -74,9 +75,9 @@ export const getNextChapterFromDB = async (novelId, chapterId) => {
|
||||
return new Promise((resolve, reject) =>
|
||||
db.transaction(tx => {
|
||||
tx.executeSql(
|
||||
`SELECT * FROM chapters WHERE novelId = ? AND chapterId > ?`,
|
||||
'SELECT * FROM chapters WHERE novelId = ? AND chapterId > ?',
|
||||
[novelId, chapterId],
|
||||
(tx, results) => {
|
||||
(txObj, results) => {
|
||||
resolve(results.rows.item(0));
|
||||
},
|
||||
(txObj, error) => console.log('Error ', error),
|
||||
@@ -89,9 +90,9 @@ export const getPrevChapterFromDB = async (novelId, chapterId) => {
|
||||
return new Promise((resolve, reject) =>
|
||||
db.transaction(tx => {
|
||||
tx.executeSql(
|
||||
`SELECT * FROM chapters WHERE novelId = ? AND chapterId < ?`,
|
||||
'SELECT * FROM chapters WHERE novelId = ? AND chapterId < ?',
|
||||
[novelId, chapterId],
|
||||
(tx, results) => {
|
||||
(txObj, results) => {
|
||||
resolve(results.rows.item(results.rows.length - 1));
|
||||
},
|
||||
(txObj, error) => console.log('Error ', error),
|
||||
@@ -100,59 +101,64 @@ export const getPrevChapterFromDB = async (novelId, chapterId) => {
|
||||
);
|
||||
};
|
||||
|
||||
const markChapterReadQuery = `UPDATE chapters SET \`read\` = 1 WHERE chapterId = ?`;
|
||||
const markChapterReadQuery =
|
||||
'UPDATE chapters SET `read` = 1 WHERE chapterId = ?';
|
||||
|
||||
export const markChapterRead = async chapterId => {
|
||||
db.transaction(tx => {
|
||||
tx.executeSql(
|
||||
markChapterReadQuery,
|
||||
[chapterId],
|
||||
(tx, res) => {},
|
||||
(tx, error) => console.log(error),
|
||||
(txObj, res) => {},
|
||||
(txObj, error) => console.log(error),
|
||||
);
|
||||
});
|
||||
};
|
||||
|
||||
const markChapterUnreadQuery = `UPDATE chapters SET \`read\` = 0 WHERE chapterId = ?`;
|
||||
const markChapterUnreadQuery =
|
||||
'UPDATE chapters SET `read` = 0 WHERE chapterId = ?';
|
||||
|
||||
export const markChapterUnread = async chapterId => {
|
||||
db.transaction(tx => {
|
||||
tx.executeSql(
|
||||
markChapterUnreadQuery,
|
||||
[chapterId],
|
||||
(tx, res) => {},
|
||||
(tx, error) => console.log(error),
|
||||
(txObj, res) => {},
|
||||
(txObj, error) => console.log(error),
|
||||
);
|
||||
});
|
||||
};
|
||||
|
||||
const markAllChaptersReadQuery = `UPDATE chapters SET \`read\` = 1 WHERE novelId = ?`;
|
||||
const markAllChaptersReadQuery =
|
||||
'UPDATE chapters SET `read` = 1 WHERE novelId = ?';
|
||||
|
||||
export const markAllChaptersRead = async novelId => {
|
||||
db.transaction(tx => {
|
||||
tx.executeSql(
|
||||
markAllChaptersReadQuery,
|
||||
[novelId],
|
||||
(tx, res) => {},
|
||||
(tx, error) => console.log(error),
|
||||
(txObj, res) => {},
|
||||
(txObj, error) => console.log(error),
|
||||
);
|
||||
});
|
||||
};
|
||||
|
||||
const markAllChaptersUnreadQuery = `UPDATE chapters SET \`read\` = 0 WHERE novelId = ?`;
|
||||
const markAllChaptersUnreadQuery =
|
||||
'UPDATE chapters SET `read` = 0 WHERE novelId = ?';
|
||||
|
||||
export const markAllChaptersUnread = async novelId => {
|
||||
db.transaction(tx => {
|
||||
tx.executeSql(
|
||||
markAllChaptersUnreadQuery,
|
||||
[novelId],
|
||||
(tx, res) => {},
|
||||
(tx, error) => console.log(error),
|
||||
(txObj, res) => {},
|
||||
(txObj, error) => console.log(error),
|
||||
);
|
||||
});
|
||||
};
|
||||
|
||||
const isChapterDownloadedQuery = `SELECT * FROM downloads WHERE downloadChapterId=?`;
|
||||
const isChapterDownloadedQuery =
|
||||
'SELECT * FROM downloads WHERE downloadChapterId=?';
|
||||
|
||||
export const isChapterDownloaded = async chapterId => {
|
||||
return new Promise((resolve, reject) =>
|
||||
@@ -173,7 +179,8 @@ export const isChapterDownloaded = async chapterId => {
|
||||
);
|
||||
};
|
||||
|
||||
const downloadChapterQuery = `INSERT INTO downloads (downloadChapterId, chapterName, chapterText) VALUES (?, ?, ?)`;
|
||||
const downloadChapterQuery =
|
||||
'INSERT INTO downloads (downloadChapterId, chapterName, chapterText) VALUES (?, ?, ?)';
|
||||
|
||||
export const downloadChapter = async (
|
||||
sourceId,
|
||||
@@ -186,13 +193,13 @@ export const downloadChapter = async (
|
||||
const chapter = await source.parseChapter(novelUrl, chapterUrl);
|
||||
|
||||
db.transaction(tx => {
|
||||
tx.executeSql(`UPDATE chapters SET downloaded = 1 WHERE chapterId = ?`, [
|
||||
tx.executeSql('UPDATE chapters SET downloaded = 1 WHERE chapterId = ?', [
|
||||
chapterId,
|
||||
]);
|
||||
tx.executeSql(
|
||||
downloadChapterQuery,
|
||||
[chapterId, chapter.chapterName, chapter.chapterText],
|
||||
(tx, res) => {
|
||||
(txObj, res) => {
|
||||
// console.log(`Downloaded Chapter ${chapter.chapterUrl}`);
|
||||
},
|
||||
(txObj, error) => console.log('Error ', error),
|
||||
@@ -201,20 +208,21 @@ export const downloadChapter = async (
|
||||
};
|
||||
|
||||
export const deleteChapter = async chapterId => {
|
||||
const updateIsDownloadedQuery = `UPDATE chapters SET downloaded = 0 WHERE chapterId=?`;
|
||||
const deleteChapterQuery = `DELETE FROM downloads WHERE downloadChapterId=?`;
|
||||
const updateIsDownloadedQuery =
|
||||
'UPDATE chapters SET downloaded = 0 WHERE chapterId=?';
|
||||
const deleteChapterQuery = 'DELETE FROM downloads WHERE downloadChapterId=?';
|
||||
|
||||
db.transaction(tx => {
|
||||
tx.executeSql(
|
||||
updateIsDownloadedQuery,
|
||||
[chapterId],
|
||||
(tx, res) => {},
|
||||
(txObj, res) => {},
|
||||
(txObj, error) => console.log('Error ', error),
|
||||
);
|
||||
tx.executeSql(
|
||||
deleteChapterQuery,
|
||||
[chapterId],
|
||||
(tx, res) => console.log(`Chapter deleted`),
|
||||
(txObj, res) => console.log('Chapter deleted'),
|
||||
(txObj, error) => console.log('Error ', error),
|
||||
);
|
||||
});
|
||||
@@ -234,48 +242,51 @@ export const getLastReadChapter = async novelId => {
|
||||
tx.executeSql(
|
||||
getLastReadChapterQuery,
|
||||
[novelId],
|
||||
(tx, {rows}) => resolve(rows.item(0)),
|
||||
(txObj, {rows}) => resolve(rows.item(0)),
|
||||
(txObj, error) => console.log('Error ', error),
|
||||
);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
const bookmarkChapterQuery = `UPDATE chapters SET bookmark = ? WHERE chapterId = ?`;
|
||||
const bookmarkChapterQuery =
|
||||
'UPDATE chapters SET bookmark = ? WHERE chapterId = ?';
|
||||
|
||||
export const bookmarkChapter = async (bookmark, chapterId) => {
|
||||
db.transaction(tx => {
|
||||
tx.executeSql(
|
||||
bookmarkChapterQuery,
|
||||
[!bookmark, chapterId],
|
||||
(tx, res) => {},
|
||||
(txObj, res) => {},
|
||||
(txObj, error) => console.log('Error ', error),
|
||||
);
|
||||
});
|
||||
};
|
||||
|
||||
const markPreviuschaptersReadQuery = `UPDATE chapters SET \`read\` = 1 WHERE chapterId < ? AND novelId = ?`;
|
||||
const markPreviuschaptersReadQuery =
|
||||
'UPDATE chapters SET `read` = 1 WHERE chapterId < ? AND novelId = ?';
|
||||
|
||||
export const markPreviuschaptersRead = async (chapterId, novelId) => {
|
||||
db.transaction(tx => {
|
||||
tx.executeSql(
|
||||
markPreviuschaptersReadQuery,
|
||||
[chapterId, novelId],
|
||||
(tx, res) => {},
|
||||
(tx, error) => console.log(error),
|
||||
(txObj, res) => {},
|
||||
(txObj, error) => console.log(error),
|
||||
);
|
||||
});
|
||||
};
|
||||
|
||||
const markPreviousChaptersUnreadQuery = `UPDATE chapters SET \`read\` = 0 WHERE chapterId < ? AND novelId = ?`;
|
||||
const markPreviousChaptersUnreadQuery =
|
||||
'UPDATE chapters SET `read` = 0 WHERE chapterId < ? AND novelId = ?';
|
||||
|
||||
export const markPreviousChaptersUnread = async (chapterId, novelId) => {
|
||||
db.transaction(tx => {
|
||||
tx.executeSql(
|
||||
markPreviousChaptersUnreadQuery,
|
||||
[chapterId, novelId],
|
||||
(tx, res) => {},
|
||||
(tx, error) => console.log(error),
|
||||
(txObj, res) => {},
|
||||
(txObj, error) => console.log(error),
|
||||
);
|
||||
});
|
||||
};
|
||||
@@ -304,7 +315,7 @@ export const getDownloadedChapters = () => {
|
||||
|
||||
export const deleteDownloads = async () => {
|
||||
db.transaction(tx => {
|
||||
tx.executeSql(`UPDATE chapters SET downloaded = 0`);
|
||||
tx.executeSql('UPDATE chapters SET downloaded = 0');
|
||||
tx.executeSql('DELETE FROM downloads; VACCUM;');
|
||||
});
|
||||
};
|
||||
|
||||
@@ -9,7 +9,8 @@ import {insertChapters} from './ChapterQueries';
|
||||
|
||||
import {showToast} from '../../hooks/showToast';
|
||||
|
||||
const insertNovelQuery = `INSERT INTO novels (novelUrl, sourceUrl, sourceId, source, novelName, novelCover, novelSummary, author, artist, status, genre) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`;
|
||||
const insertNovelQuery =
|
||||
'INSERT INTO novels (novelUrl, sourceUrl, sourceId, source, novelName, novelCover, novelSummary, author, artist, status, genre) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)';
|
||||
|
||||
export const insertNovel = async novel => {
|
||||
return new Promise((resolve, reject) =>
|
||||
@@ -41,7 +42,7 @@ export const followNovel = async (followed, novelId) => {
|
||||
tx.executeSql(
|
||||
'UPDATE novels SET followed = ? WHERE novelId = ?',
|
||||
[!followed, novelId],
|
||||
(tx, res) => {},
|
||||
(txo, res) => {},
|
||||
(txObj, error) => console.log('Error ', error),
|
||||
);
|
||||
});
|
||||
@@ -52,13 +53,13 @@ export const unfollowNovel = async novelId => {
|
||||
tx.executeSql(
|
||||
'UPDATE novels SET followed = 0 WHERE novelId = ?',
|
||||
[novelId],
|
||||
(tx, res) => {},
|
||||
(txo, res) => {},
|
||||
(txObj, error) => console.log('Error ', error),
|
||||
);
|
||||
});
|
||||
};
|
||||
|
||||
const checkNovelInCacheQuery = `SELECT * FROM novels WHERE novelUrl=? LIMIT 1`;
|
||||
const checkNovelInCacheQuery = 'SELECT * FROM novels WHERE novelUrl=? LIMIT 1';
|
||||
|
||||
export const checkNovelInCache = novelUrl => {
|
||||
return new Promise((resolve, reject) =>
|
||||
@@ -83,7 +84,7 @@ export const getNovel = async (sourceId, novelUrl) => {
|
||||
return new Promise((resolve, reject) =>
|
||||
db.transaction(tx => {
|
||||
tx.executeSql(
|
||||
`SELECT * FROM novels WHERE novelUrl = ? AND sourceId = ?`,
|
||||
'SELECT * FROM novels WHERE novelUrl = ? AND sourceId = ?',
|
||||
[novelUrl, sourceId],
|
||||
(txObj, {rows}) => resolve(rows.item(0)),
|
||||
(txObj, error) => console.log('Error ', error),
|
||||
@@ -103,7 +104,8 @@ export const deleteNovelCache = () => {
|
||||
});
|
||||
};
|
||||
|
||||
const restoreFromBackupQuery = `INSERT INTO novels (novelUrl, sourceUrl, sourceId, source, novelName, novelCover, novelSummary, author, artist, status, genre, followed, unread) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`;
|
||||
const restoreFromBackupQuery =
|
||||
'INSERT INTO novels (novelUrl, sourceUrl, sourceId, source, novelName, novelCover, novelSummary, author, artist, status, genre, followed, unread) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)';
|
||||
|
||||
export const restoreLibrary = async novel => {
|
||||
return new Promise((resolve, reject) =>
|
||||
@@ -135,7 +137,8 @@ export const restoreLibrary = async novel => {
|
||||
);
|
||||
};
|
||||
|
||||
const migrateNovelQuery = `INSERT INTO novels (novelUrl, sourceUrl, sourceId, source, novelName, novelCover, novelSummary, author, artist, status, genre, followed) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`;
|
||||
const migrateNovelQuery =
|
||||
'INSERT INTO novels (novelUrl, sourceUrl, sourceId, source, novelName, novelCover, novelSummary, author, artist, status, genre, followed) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)';
|
||||
|
||||
export const migrateNovel = async (sourceId, novelUrl) => {
|
||||
try {
|
||||
|
||||
@@ -8,4 +8,5 @@ export const createHistoryTableQuery = `
|
||||
ON DELETE CASCADE
|
||||
)`;
|
||||
|
||||
export const createChapterIdIndexQuery = `CREATE INDEX IF NOT EXISTS historyChapterIdIndex ON history(historyChapterId)`;
|
||||
export const createChapterIdIndexQuery =
|
||||
'CREATE INDEX IF NOT EXISTS historyChapterIdIndex ON history(historyChapterId)';
|
||||
|
||||
@@ -16,6 +16,8 @@ export const createNovelTableQuery = `
|
||||
unread INTEGER DEFAULT 1
|
||||
)`;
|
||||
|
||||
export const createUrlIndexQuery = `CREATE INDEX IF NOT EXISTS novelUrlIndex ON novels(novelUrl)`;
|
||||
export const createUrlIndexQuery =
|
||||
'CREATE INDEX IF NOT EXISTS novelUrlIndex ON novels(novelUrl)';
|
||||
|
||||
export const createLibraryIndexQuery = `CREATE INDEX IF NOT EXISTS novelFollowedIndex ON novels(followed)`;
|
||||
export const createLibraryIndexQuery =
|
||||
'CREATE INDEX IF NOT EXISTS novelFollowedIndex ON novels(followed)';
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import {useState, useEffect} from 'react';
|
||||
|
||||
export const githubUpdateChecker = () => {
|
||||
import {showToast} from './../hooks/showToast';
|
||||
|
||||
export const useGithubUpdateChecker = () => {
|
||||
const latestReleaseUrl =
|
||||
'https://api.github.com/repos/rajarsheechatterjee/lnreader/releases/latest';
|
||||
|
||||
@@ -32,7 +34,10 @@ export const githubUpdateChecker = () => {
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
checkForRelease();
|
||||
checkForRelease().catch(e => {
|
||||
showToast(`Could not connect to github:\n${`${e}`.split(':')[1].trim()}`);
|
||||
// console.error(e);
|
||||
});
|
||||
}, []);
|
||||
|
||||
if (!checking) {
|
||||
|
||||
@@ -37,7 +37,7 @@ const useChapter = () => {
|
||||
return chapter;
|
||||
};
|
||||
|
||||
const findNovel = novelId => {
|
||||
const useFindNovel = novelId => {
|
||||
let novel = useSelector(state => state.preferenceReducer.novelSettings);
|
||||
novel = novel[novelId];
|
||||
|
||||
@@ -47,7 +47,7 @@ const findNovel = novelId => {
|
||||
const usePreferences = novelId => {
|
||||
let sort, filter, position, showChapterTitles;
|
||||
|
||||
const novel = findNovel(novelId);
|
||||
const novel = useFindNovel(novelId);
|
||||
|
||||
if (novel) {
|
||||
sort = novel.sort;
|
||||
@@ -68,7 +68,7 @@ const useSavedSettings = () => {
|
||||
const useContinueReading = (chapters, novelId) => {
|
||||
let lastReadChapter, chapterId, novel, position;
|
||||
|
||||
novel = findNovel(novelId);
|
||||
novel = useFindNovel(novelId);
|
||||
if (novel) {
|
||||
chapterId = novel.lastRead;
|
||||
position = novel.position;
|
||||
@@ -90,7 +90,7 @@ const useContinueReading = (chapters, novelId) => {
|
||||
const usePosition = (novelId, chapterId) => {
|
||||
let novel, position;
|
||||
|
||||
novel = findNovel(novelId);
|
||||
novel = useFindNovel(novelId);
|
||||
|
||||
if (novel) {
|
||||
if (novel.position) {
|
||||
|
||||
@@ -25,12 +25,12 @@ const BottomNavigationBar = ({
|
||||
}) => {
|
||||
const focusedOptions = descriptors[state.routes[state.index].key].options;
|
||||
|
||||
const insets = useSafeAreaInsets();
|
||||
|
||||
if (focusedOptions.tabBarVisible === false) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const insets = useSafeAreaInsets();
|
||||
|
||||
return (
|
||||
<View
|
||||
style={{
|
||||
|
||||
@@ -2,7 +2,7 @@ import React from 'react';
|
||||
|
||||
import {createMaterialBottomTabNavigator} from '@react-navigation/material-bottom-tabs';
|
||||
import MaterialCommunityIcons from 'react-native-vector-icons/MaterialCommunityIcons';
|
||||
import {useSafeAreaInsets} from 'react-native-safe-area-context';
|
||||
// import {useSafeAreaInsets} from 'react-native-safe-area-context';
|
||||
|
||||
import Library from '../screens/library/LibraryScreen';
|
||||
import Updates from '../screens/updates/UpdatesScreen';
|
||||
@@ -16,7 +16,7 @@ const Tab = createMaterialBottomTabNavigator();
|
||||
|
||||
const BottomNavigator = () => {
|
||||
const theme = useTheme();
|
||||
const insets = useSafeAreaInsets();
|
||||
// const insets = useSafeAreaInsets();
|
||||
|
||||
const {
|
||||
showHistoryTab = true,
|
||||
|
||||
@@ -6,7 +6,7 @@ import {createStackNavigator} from '@react-navigation/stack';
|
||||
|
||||
import {setBarColor} from '../theme/utils/setBarColor';
|
||||
import {useTheme} from '../hooks/reduxHooks';
|
||||
import {githubUpdateChecker} from '../hooks/githubUpdateChecker';
|
||||
import {useGithubUpdateChecker} from '../hooks/githubUpdateChecker';
|
||||
import * as SplashScreen from 'expo-splash-screen';
|
||||
|
||||
/**
|
||||
@@ -42,7 +42,7 @@ const MainNavigator = () => {
|
||||
}, 500);
|
||||
}, [theme]);
|
||||
|
||||
const {isNewVersion, latestRelease} = githubUpdateChecker() || {};
|
||||
const {isNewVersion, latestRelease} = useGithubUpdateChecker() || {};
|
||||
|
||||
return (
|
||||
<NavigationContainer theme={{colors: {background: theme.colorPrimaryDark}}}>
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
import {
|
||||
SET_DOWNLOAD_QUEUE,
|
||||
CANCEL_DOWNLOAD,
|
||||
PAUSE_DOWNLOADS,
|
||||
} from './donwloads.types';
|
||||
import {CANCEL_DOWNLOAD, PAUSE_DOWNLOADS} from './donwloads.types';
|
||||
import BackgroundService from 'react-native-background-actions';
|
||||
import {downloadChapter} from '../../database/queries/ChapterQueries';
|
||||
import {CHAPTER_DOWNLOADED} from '../novel/novel.types';
|
||||
import {showToast} from '../../hooks/showToast';
|
||||
|
||||
import * as Notifications from 'expo-notifications';
|
||||
|
||||
export const pauseDownloads = () => async dispatch => {
|
||||
showToast('Download paused');
|
||||
|
||||
|
||||
@@ -86,7 +86,7 @@ export const getNovelAction =
|
||||
/**
|
||||
* Check if novel is cached.
|
||||
*/
|
||||
const novel = await getNovel(sourceId, novelUrl);
|
||||
let novel = await getNovel(sourceId, novelUrl);
|
||||
|
||||
if (novel) {
|
||||
/**
|
||||
@@ -112,7 +112,7 @@ export const getNovelAction =
|
||||
/**
|
||||
* Get novel from db.
|
||||
*/
|
||||
const novel = await getNovel(sourceId, novelUrl);
|
||||
novel = await getNovel(sourceId, novelUrl);
|
||||
novel.chapters = await getChapters(novel.novelId);
|
||||
|
||||
dispatch({
|
||||
|
||||
@@ -8,7 +8,7 @@ import {showToast} from '../../hooks/showToast';
|
||||
export const getUpdatesAction = () => async dispatch => {
|
||||
const updates = await getUpdates();
|
||||
|
||||
const groups = updates.reduce((groups, update) => {
|
||||
const groups = updates.reduce((grs, update) => {
|
||||
var dateParts = update.updateTime.split('-');
|
||||
var jsDate = new Date(
|
||||
dateParts[0],
|
||||
@@ -16,11 +16,11 @@ export const getUpdatesAction = () => async dispatch => {
|
||||
dateParts[2].substr(0, 2),
|
||||
);
|
||||
const date = jsDate.toISOString();
|
||||
if (!groups[date]) {
|
||||
groups[date] = [];
|
||||
if (!grs[date]) {
|
||||
grs[date] = [];
|
||||
}
|
||||
groups[date].push(update);
|
||||
return groups;
|
||||
grs[date].push(update);
|
||||
return grs;
|
||||
}, {});
|
||||
|
||||
const groupedUpdates = Object.keys(groups).map(date => {
|
||||
|
||||
@@ -5,7 +5,6 @@ import {Switch} from 'react-native-paper';
|
||||
import {useDispatch, useSelector} from 'react-redux';
|
||||
|
||||
import {Appbar} from '../../components/Appbar';
|
||||
import {ScreenContainer} from '../../components/Common';
|
||||
import {List} from '../../components/List';
|
||||
|
||||
import {useSettings, useTheme} from '../../hooks/reduxHooks';
|
||||
|
||||
@@ -2,7 +2,6 @@ import React from 'react';
|
||||
import {StyleSheet, View, FlatList, Text} from 'react-native';
|
||||
import {useLibrary, useTheme} from '../../hooks/reduxHooks';
|
||||
|
||||
import EmptyView from '../../components/EmptyView';
|
||||
import {Appbar} from '../../components/Appbar';
|
||||
import ListView from '../../components/ListView';
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import React from 'react';
|
||||
import {StyleSheet, Pressable, Text, View, FlatList} from 'react-native';
|
||||
import {StyleSheet, Pressable, Text, View} from 'react-native';
|
||||
import FastImage from 'react-native-fast-image';
|
||||
import {Row} from '../../../components/Common';
|
||||
|
||||
const GenreChip = ({children, theme}) => (
|
||||
<View style={{flexDirection: 'row'}}>
|
||||
|
||||
@@ -6,9 +6,9 @@ import * as WebBrowser from 'expo-web-browser';
|
||||
import {Searchbar} from '../../../components/Searchbar/Searchbar';
|
||||
import {ErrorView} from '../../../components/ErrorView/ErrorView';
|
||||
|
||||
import {useTheme, useSettings} from '../../../hooks/reduxHooks';
|
||||
import {useTheme /*, useSettings */} from '../../../hooks/reduxHooks';
|
||||
import {showToast} from '../../../hooks/showToast';
|
||||
import {getDeviceOrientation} from '../../../services/utils/helpers';
|
||||
// import {useDeviceOrientation} from '../../../services/utils/helpers';
|
||||
import {scrapeSearchResults, scrapeTopNovels} from './MyAnimeListScraper';
|
||||
import BrowseMalCard from './BrowseMalCard';
|
||||
|
||||
@@ -24,17 +24,17 @@ const BrowseMalScreen = ({navigation, route}) => {
|
||||
|
||||
const malUrl = 'https://myanimelist.net/topmanga.php?type=lightnovels';
|
||||
|
||||
const getNovels = async limit => {
|
||||
const getNovels = async lim => {
|
||||
try {
|
||||
const data = await scrapeTopNovels(limit);
|
||||
const data = await scrapeTopNovels(lim ?? limit);
|
||||
|
||||
setNovels(novels => novels.concat(data));
|
||||
setNovels(before => before.concat(data));
|
||||
setLoading(false);
|
||||
} catch (error) {
|
||||
setError(error.message);
|
||||
} catch (err) {
|
||||
setError(err.message);
|
||||
setNovels([]);
|
||||
setLoading(false);
|
||||
showToast(error.message);
|
||||
showToast(err.message);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -52,11 +52,11 @@ const BrowseMalScreen = ({navigation, route}) => {
|
||||
|
||||
setNovels(data);
|
||||
setLoading(false);
|
||||
} catch (error) {
|
||||
setError(error.message);
|
||||
} catch (err) {
|
||||
setError(err.message);
|
||||
setNovels([]);
|
||||
setLoading(false);
|
||||
showToast(error.message);
|
||||
showToast(err.message);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -76,21 +76,21 @@ const BrowseMalScreen = ({navigation, route}) => {
|
||||
/>
|
||||
);
|
||||
|
||||
const {displayMode, novelsPerRow} = useSettings();
|
||||
// const {displayMode, novelsPerRow} = useSettings();
|
||||
|
||||
const orientation = getDeviceOrientation();
|
||||
// const orientation = useDeviceOrientation();
|
||||
|
||||
const getNovelsPerRow = () => {
|
||||
if (displayMode === 2) {
|
||||
return 1;
|
||||
}
|
||||
// const getNovelsPerRow = () => {
|
||||
// if (displayMode === 2) {
|
||||
// return 1;
|
||||
// }
|
||||
|
||||
if (orientation === 'landscape') {
|
||||
return 6;
|
||||
} else {
|
||||
return novelsPerRow;
|
||||
}
|
||||
};
|
||||
// if (orientation === 'landscape') {
|
||||
// return 6;
|
||||
// } else {
|
||||
// return novelsPerRow;
|
||||
// }
|
||||
// };
|
||||
|
||||
const isCloseToBottom = ({layoutMeasurement, contentOffset, contentSize}) => {
|
||||
const paddingToBottom = 20;
|
||||
@@ -150,7 +150,7 @@ const BrowseMalScreen = ({navigation, route}) => {
|
||||
onScroll={({nativeEvent}) => {
|
||||
if (!searchText && isCloseToBottom(nativeEvent)) {
|
||||
getNovels(limit + 50);
|
||||
setLimit(limit => limit + 50);
|
||||
setLimit(before => before + 50);
|
||||
}
|
||||
}}
|
||||
ListFooterComponent={
|
||||
|
||||
@@ -11,7 +11,7 @@ const scrapeTopNovels = async pageNo => {
|
||||
|
||||
const novels = [];
|
||||
|
||||
$('tr.ranking-list').each(function (res) {
|
||||
$('tr.ranking-list').each(function () {
|
||||
const novelId = $(this).find('img').attr('data-src').split('/');
|
||||
|
||||
const novelCover =
|
||||
@@ -48,7 +48,7 @@ const scrapeSearchResults = async searchTerm => {
|
||||
|
||||
$('.list')
|
||||
.find('tr')
|
||||
.each(function (res) {
|
||||
.each(function () {
|
||||
const novelName = $(this).find('a > strong').text();
|
||||
|
||||
if (novelName) {
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
import React, {useEffect, useState} from 'react';
|
||||
import {StyleSheet, View, FlatList, ActivityIndicator} from 'react-native';
|
||||
import {
|
||||
/* StyleSheet, */ View,
|
||||
FlatList,
|
||||
ActivityIndicator,
|
||||
} from 'react-native';
|
||||
|
||||
import {ProgressBar} from 'react-native-paper';
|
||||
import {useSelector} from 'react-redux';
|
||||
@@ -42,10 +46,7 @@ const GlobalSearch = ({route, navigation}) => {
|
||||
const library = useLibrary();
|
||||
|
||||
useEffect(() => {
|
||||
let mounted = true;
|
||||
novelName && onSubmitEditing();
|
||||
|
||||
return () => (mounted = false);
|
||||
}, []);
|
||||
|
||||
const clearSearchbar = () => setSearchText('');
|
||||
@@ -64,8 +65,8 @@ const GlobalSearch = ({route, navigation}) => {
|
||||
const source = getSource(globalSearchSources[i].sourceId);
|
||||
const data = await source.searchNovels(encodeURI(searchText));
|
||||
|
||||
setSearchResults(searchResults => [
|
||||
...searchResults,
|
||||
setSearchResults(before => [
|
||||
...before,
|
||||
{
|
||||
sourceId: globalSearchSources[i].sourceId,
|
||||
sourceName: globalSearchSources[i].sourceName,
|
||||
@@ -76,8 +77,8 @@ const GlobalSearch = ({route, navigation}) => {
|
||||
setLoading(false);
|
||||
} catch (error) {
|
||||
showToast(globalSearchSources[i].sourceName + ': ' + error.message);
|
||||
setSearchResults(searchResults => [
|
||||
...searchResults,
|
||||
setSearchResults(before => [
|
||||
...before,
|
||||
{
|
||||
sourceId: globalSearchSources[i].sourceId,
|
||||
sourceName: globalSearchSources[i].sourceName,
|
||||
@@ -87,7 +88,7 @@ const GlobalSearch = ({route, navigation}) => {
|
||||
]);
|
||||
setLoading(false);
|
||||
}
|
||||
setProgress(progress => progress + 1 / globalSearchSources.length);
|
||||
setProgress(before => before + 1 / globalSearchSources.length);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -160,4 +161,4 @@ const GlobalSearch = ({route, navigation}) => {
|
||||
|
||||
export default GlobalSearch;
|
||||
|
||||
const styles = StyleSheet.create({});
|
||||
// const styles = StyleSheet.create({});
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import React, {useEffect, useState} from 'react';
|
||||
import {
|
||||
StyleSheet,
|
||||
/* StyleSheet, */
|
||||
View,
|
||||
Text,
|
||||
FlatList,
|
||||
@@ -49,8 +49,8 @@ const MigrationNovels = ({navigation, route}) => {
|
||||
const source = getSource(migrationSources[i].sourceId);
|
||||
const data = await source.searchNovels(novelName);
|
||||
|
||||
setSearchResults(searchResults => [
|
||||
...searchResults,
|
||||
setSearchResults(before => [
|
||||
...before,
|
||||
{
|
||||
sourceId: migrationSources[i].sourceId,
|
||||
sourceName: migrationSources[i].sourceName,
|
||||
@@ -62,8 +62,8 @@ const MigrationNovels = ({navigation, route}) => {
|
||||
} catch (error) {
|
||||
showToast(error.message);
|
||||
|
||||
setSearchResults(searchResults => [
|
||||
...searchResults,
|
||||
setSearchResults(before => [
|
||||
...before,
|
||||
{
|
||||
sourceId: migrationSources[i].sourceId,
|
||||
sourceName: migrationSources[i].sourceName,
|
||||
@@ -73,7 +73,7 @@ const MigrationNovels = ({navigation, route}) => {
|
||||
]);
|
||||
setLoading(false);
|
||||
}
|
||||
setProgress(progress => progress + 1 / migrationSources.length);
|
||||
setProgress(before => before + 1 / migrationSources.length);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -145,4 +145,4 @@ const MigrationNovels = ({navigation, route}) => {
|
||||
|
||||
export default MigrationNovels;
|
||||
|
||||
const styles = StyleSheet.create({});
|
||||
// const styles = StyleSheet.create({});
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import React, {useState, useCallback} from 'react';
|
||||
import {
|
||||
StyleSheet,
|
||||
FlatList,
|
||||
ActivityIndicator,
|
||||
Text,
|
||||
View,
|
||||
@@ -89,7 +88,7 @@ const History = ({navigation}) => {
|
||||
};
|
||||
|
||||
const groupByDate = rawHistory => {
|
||||
const groups = rawHistory.reduce((groups, update) => {
|
||||
const groups = rawHistory.reduce((grs, update) => {
|
||||
var dateParts = update.historyTimeRead.split('-');
|
||||
var jsDate = new Date(
|
||||
dateParts[0],
|
||||
@@ -97,11 +96,11 @@ const History = ({navigation}) => {
|
||||
dateParts[2].substr(0, 2),
|
||||
);
|
||||
const date = jsDate.toISOString();
|
||||
if (!groups[date]) {
|
||||
groups[date] = [];
|
||||
if (!grs[date]) {
|
||||
grs[date] = [];
|
||||
}
|
||||
groups[date].push(update);
|
||||
return groups;
|
||||
grs[date].push(update);
|
||||
return grs;
|
||||
}, {});
|
||||
|
||||
const groupedHistory = Object.keys(groups).map(date => {
|
||||
|
||||
@@ -209,8 +209,8 @@ const LibraryScreen = ({navigation}) => {
|
||||
{
|
||||
icon: 'check',
|
||||
onPress: () => {
|
||||
selectedNovels.map(id => markAllChaptersRead(id)),
|
||||
setSelectedNovels([]);
|
||||
selectedNovels.map(id => markAllChaptersRead(id));
|
||||
setSelectedNovels([]);
|
||||
dispatch(getLibraryAction(sort, filter));
|
||||
},
|
||||
},
|
||||
|
||||
@@ -98,9 +98,7 @@ const Downloads = ({navigation}) => {
|
||||
|
||||
const deleteChapter = (chapterId, chapterName) => {
|
||||
dispatch(deleteChapterAction(chapterId, chapterName));
|
||||
setChapters(chapters =>
|
||||
chapters.filter(item => item.chapterId !== chapterId),
|
||||
);
|
||||
setChapters(chaps => chaps.filter(item => item.chapterId !== chapterId));
|
||||
};
|
||||
|
||||
const renderItem = ({item}) => (
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
import React from 'react';
|
||||
import {StyleSheet, View, Image, Pressable, Text} from 'react-native';
|
||||
import {/* StyleSheet ,*/ View, Pressable, Text} from 'react-native';
|
||||
import {Switch} from 'react-native-paper';
|
||||
import {useDispatch, useSelector} from 'react-redux';
|
||||
|
||||
import {Appbar} from '../../components/Appbar';
|
||||
import {ScreenContainer} from '../../components/Common';
|
||||
import {List} from '../../components/List';
|
||||
|
||||
@@ -148,4 +147,4 @@ const MoreScreen = ({navigation}) => {
|
||||
|
||||
export default MoreScreen;
|
||||
|
||||
const styles = StyleSheet.create({});
|
||||
// const styles = StyleSheet.create({});
|
||||
|
||||
@@ -108,7 +108,7 @@ const Novel = ({route, navigation}) => {
|
||||
|
||||
const [jumpToChapterModal, showJumpToChapterModal] = useState(false);
|
||||
|
||||
const keyExtractor = useCallback(item => item.chapterId.toString(), []);
|
||||
const keyExtractor = useCallback(i => i.chapterId.toString(), []);
|
||||
|
||||
const downloadChapter = (chapterUrl, chapterName, chapterId) =>
|
||||
dispatch(
|
||||
@@ -133,11 +133,11 @@ const Novel = ({route, navigation}) => {
|
||||
navigateToChapter();
|
||||
} else {
|
||||
if (isSelected(chapter.chapterId)) {
|
||||
setSelected(selected =>
|
||||
selected.filter(item => item.chapterId !== chapter.chapterId),
|
||||
setSelected(sel =>
|
||||
sel.filter(it => it.chapterId !== chapter.chapterId),
|
||||
);
|
||||
} else {
|
||||
setSelected(selected => [...selected, chapter]);
|
||||
setSelected(sel => [...sel, chapter]);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -145,7 +145,7 @@ const Novel = ({route, navigation}) => {
|
||||
const onSelectLongPress = chapter => {
|
||||
if (selected.length === 0) {
|
||||
Haptics.impactAsync(Haptics.ImpactFeedbackStyle.Medium);
|
||||
setSelected(selected => [...selected, chapter]);
|
||||
setSelected(sel => [...sel, chapter]);
|
||||
} else {
|
||||
/**
|
||||
* Select custom range
|
||||
@@ -154,8 +154,8 @@ const Novel = ({route, navigation}) => {
|
||||
|
||||
if (lastSelectedChapter.chapterId !== chapter.chapterId) {
|
||||
if (lastSelectedChapter.chapterId > chapter.chapterId) {
|
||||
setSelected(selected => [
|
||||
...selected,
|
||||
setSelected(sel => [
|
||||
...sel,
|
||||
chapter,
|
||||
...chapters.filter(
|
||||
chap =>
|
||||
@@ -164,8 +164,8 @@ const Novel = ({route, navigation}) => {
|
||||
),
|
||||
]);
|
||||
} else {
|
||||
setSelected(selected => [
|
||||
...selected,
|
||||
setSelected(sel => [
|
||||
...sel,
|
||||
chapter,
|
||||
...chapters.filter(
|
||||
chap =>
|
||||
@@ -223,10 +223,10 @@ const Novel = ({route, navigation}) => {
|
||||
showExtraMenu(false);
|
||||
};
|
||||
|
||||
const renderItem = ({item, index}) => (
|
||||
const renderItem = ({item: it, index}) => (
|
||||
<ChapterItem
|
||||
theme={theme}
|
||||
chapter={item}
|
||||
chapter={it}
|
||||
index={index}
|
||||
showChapterTitles={showChapterTitles}
|
||||
downloadQueue={downloadQueue}
|
||||
@@ -254,7 +254,7 @@ const Novel = ({route, navigation}) => {
|
||||
width: Dimensions.get('window').width,
|
||||
elevation: 2,
|
||||
}}
|
||||
active={selected.length == 0}
|
||||
active={selected.length === 0}
|
||||
animationDuration={100}
|
||||
>
|
||||
<View
|
||||
@@ -285,7 +285,7 @@ const Novel = ({route, navigation}) => {
|
||||
/>
|
||||
</View>
|
||||
</FadeView>
|
||||
{selected.length == 0 && (
|
||||
{selected.length === 0 && (
|
||||
<View
|
||||
style={{
|
||||
position: 'absolute',
|
||||
@@ -469,7 +469,7 @@ const Novel = ({route, navigation}) => {
|
||||
small
|
||||
color={theme.colorButtonText}
|
||||
uppercase={false}
|
||||
label={novel.unread ? `Start` : `Resume`}
|
||||
label={novel.unread ? 'Start' : 'Resume'}
|
||||
icon="play"
|
||||
onPress={() =>
|
||||
navigation.navigate('Chapter', {
|
||||
|
||||
@@ -9,7 +9,7 @@ import {
|
||||
} from 'react-native';
|
||||
|
||||
import MaterialCommunityIcons from 'react-native-vector-icons/MaterialCommunityIcons';
|
||||
import {Button, Modal, Portal, Switch, TextInput} from 'react-native-paper';
|
||||
import {Button, Modal, Portal, TextInput} from 'react-native-paper';
|
||||
import {setNovel} from '../../../redux/novel/novel.actions';
|
||||
import {updateNovelInfo} from '../../../database/queries/NovelQueries';
|
||||
|
||||
@@ -27,8 +27,8 @@ const EditInfoModal = ({theme, hideModal, modalVisible, novel, dispatch}) => {
|
||||
},
|
||||
};
|
||||
|
||||
const removeTag = tag => {
|
||||
let tags = info.genre.split(',').filter(item => item !== tag);
|
||||
const removeTag = t => {
|
||||
let tags = info.genre.split(',').filter(item => item !== t);
|
||||
setInfo({...info, genre: tags.join(',')});
|
||||
};
|
||||
|
||||
@@ -118,7 +118,7 @@ const EditInfoModal = ({theme, hideModal, modalVisible, novel, dispatch}) => {
|
||||
/>
|
||||
|
||||
<TextInput
|
||||
placeholder={`Add Tag`}
|
||||
placeholder={'Add Tag'}
|
||||
style={{fontSize: 14}}
|
||||
numberOfLines={1}
|
||||
mode="outlined"
|
||||
|
||||
@@ -3,7 +3,6 @@ import {View, Text, StyleSheet, Clipboard, Pressable} from 'react-native';
|
||||
|
||||
import * as WebBrowser from 'expo-web-browser';
|
||||
import {IconButton} from 'react-native-paper';
|
||||
import MaterialCommunityIcons from 'react-native-vector-icons/MaterialCommunityIcons';
|
||||
|
||||
import {followNovelAction} from '../../../../redux/novel/novel.actions';
|
||||
import {useTrackingStatus, useSettings} from '../../../../hooks/reduxHooks';
|
||||
|
||||
@@ -34,7 +34,7 @@ const ReadButton = ({navigation, novel, chapters, theme, lastRead}) => {
|
||||
}}
|
||||
onPress={navigateToLastReadChapter}
|
||||
>
|
||||
{novel.unread ? `Start reading ` : `Continue reading `}
|
||||
{novel.unread ? 'Start reading ' : 'Continue reading '}
|
||||
{lastRead.chapterName}
|
||||
</Button>
|
||||
) : (
|
||||
|
||||
@@ -57,12 +57,12 @@ const JumpToChapterModal = ({
|
||||
});
|
||||
hideModal();
|
||||
} else {
|
||||
setError(`Enter a valid chapter name`);
|
||||
setError('Enter a valid chapter name');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const onChangeText = text => setText(text);
|
||||
const onChangeText = txt => setText(txt);
|
||||
|
||||
const textInputTheme = {
|
||||
colors: {
|
||||
|
||||
@@ -8,7 +8,6 @@ import {
|
||||
} from 'react-native';
|
||||
|
||||
import {TabView, SceneMap, TabBar} from 'react-native-tab-view';
|
||||
import {Checkbox as PaperCheckbox} from 'react-native-paper';
|
||||
import Bottomsheet from 'rn-sliding-up-panel';
|
||||
|
||||
import {Checkbox, SortItem} from '../../../components/Checkbox/Checkbox';
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
import React, {useState} from 'react';
|
||||
import {StyleSheet, Text} from 'react-native';
|
||||
import {Modal, TextInput} from 'react-native-paper';
|
||||
import {
|
||||
RadioButton,
|
||||
RadioButtonGroup,
|
||||
} from '../../../../components/RadioButton';
|
||||
|
||||
const SetTrackChaptersDialog = ({
|
||||
trackItem,
|
||||
|
||||
@@ -205,9 +205,9 @@ const Chapter = ({route, navigation}) => {
|
||||
}
|
||||
};
|
||||
|
||||
const getChapter = async chapterId => {
|
||||
const getChapter = async id => {
|
||||
try {
|
||||
if (chapterId) {
|
||||
if (id) {
|
||||
const chapterDownloaded = await getChapterFromDB(chapterId);
|
||||
|
||||
if (chapterDownloaded) {
|
||||
@@ -223,10 +223,10 @@ const Chapter = ({route, navigation}) => {
|
||||
}
|
||||
|
||||
setLoading(false);
|
||||
} catch (error) {
|
||||
setError(error.message);
|
||||
} catch (e) {
|
||||
setError(e.message);
|
||||
setLoading(false);
|
||||
showToast(error.message);
|
||||
showToast(e.message);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -295,6 +295,7 @@ const Chapter = ({route, navigation}) => {
|
||||
}, [autoScroll, currentOffset]);
|
||||
|
||||
const isCloseToBottom = useCallback(
|
||||
// eslint-disable-next-line no-shadow
|
||||
({layoutMeasurement, contentOffset, contentSize}) => {
|
||||
const paddingToBottom = 40;
|
||||
return (
|
||||
@@ -319,12 +320,10 @@ const Chapter = ({route, navigation}) => {
|
||||
|
||||
const onScroll = useCallback(({nativeEvent}) => {
|
||||
const offsetY = nativeEvent.contentOffset.y;
|
||||
const position =
|
||||
const pos =
|
||||
nativeEvent.contentOffset.y + nativeEvent.layoutMeasurement.height;
|
||||
|
||||
const percentage = Math.round(
|
||||
(position / nativeEvent.contentSize.height) * 100,
|
||||
);
|
||||
const percentage = Math.round((pos / nativeEvent.contentSize.height) * 100);
|
||||
setScrollPercentage(percentage);
|
||||
|
||||
if (!incognitoMode) {
|
||||
@@ -418,7 +417,7 @@ const Chapter = ({route, navigation}) => {
|
||||
dispatch(setAppSettings('useWebViewForChapter', !useWebViewForChapter));
|
||||
|
||||
const onWebViewNavigationStateChange = async ({url}) => {
|
||||
if ((sourceId === 50 || sourceId == 62) && url !== 'about:blank') {
|
||||
if ((sourceId === 50 || sourceId === 62) && url !== 'about:blank') {
|
||||
setLoading(true);
|
||||
const res = await fetchChapter(sourceId, novelUrl, url);
|
||||
setChapter(res);
|
||||
|
||||
@@ -1,22 +1,13 @@
|
||||
import React, {memo, useState} from 'react';
|
||||
import {
|
||||
StyleSheet,
|
||||
View,
|
||||
Text,
|
||||
Pressable,
|
||||
ScrollView,
|
||||
Animated,
|
||||
} from 'react-native';
|
||||
import {StyleSheet, View, Text, ScrollView, Animated} from 'react-native';
|
||||
|
||||
import Slider from '@react-native-community/slider';
|
||||
import {IconButton, Switch} from 'react-native-paper';
|
||||
import {IconButton} from 'react-native-paper';
|
||||
import Bottomsheet from 'rn-sliding-up-panel';
|
||||
|
||||
import BottomSheetHandle from '../../../../components/BottomSheetHandle';
|
||||
import {Row} from '../../../../components/Common';
|
||||
|
||||
import {fonts} from '../../../../services/utils/constants';
|
||||
|
||||
import {
|
||||
setAppSettings,
|
||||
setReaderSettings,
|
||||
|
||||
-1
@@ -1,5 +1,4 @@
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import {Pressable, ScrollView, StyleSheet, Text, View} from 'react-native';
|
||||
|
||||
import {useDispatch} from 'react-redux';
|
||||
|
||||
@@ -2,7 +2,7 @@ import React from 'react';
|
||||
import {Dimensions, View, Text, StyleSheet} from 'react-native';
|
||||
|
||||
import Slider from '@react-native-community/slider';
|
||||
import {getDeviceOrientation} from '../../../services/utils/helpers';
|
||||
import {useDeviceOrientation} from '../../../services/utils/helpers';
|
||||
|
||||
const VerticalScrollbar = ({
|
||||
theme,
|
||||
@@ -23,92 +23,94 @@ const VerticalScrollbar = ({
|
||||
setLoading(false);
|
||||
};
|
||||
|
||||
const screenOrientation = useDeviceOrientation();
|
||||
|
||||
if (hide) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (screenOrientation === 'potrait' && verticalSeekbar) {
|
||||
return (
|
||||
<View
|
||||
style={[
|
||||
styles.verticalSliderContainer,
|
||||
{backgroundColor: `${theme.colorPrimary}E6`},
|
||||
]}
|
||||
>
|
||||
<Text
|
||||
style={{
|
||||
color: theme.textColorPrimary,
|
||||
marginLeft: 16,
|
||||
transform: [{rotate: '-90deg'}],
|
||||
}}
|
||||
>
|
||||
{scrollPercentage}
|
||||
</Text>
|
||||
<Slider
|
||||
style={{
|
||||
flex: 1,
|
||||
height: 40,
|
||||
}}
|
||||
minimumValue={0}
|
||||
maximumValue={100}
|
||||
step={1}
|
||||
value={scrollPercentage}
|
||||
onSlidingComplete={onSlidingComplete}
|
||||
thumbTintColor={theme.colorAccent}
|
||||
minimumTrackTintColor={theme.colorAccent}
|
||||
maximumTrackTintColor={theme.textColorPrimary}
|
||||
/>
|
||||
<Text
|
||||
style={{
|
||||
color: theme.textColorPrimary,
|
||||
marginRight: 16,
|
||||
transform: [{rotate: '-90deg'}],
|
||||
}}
|
||||
>
|
||||
100
|
||||
</Text>
|
||||
</View>
|
||||
);
|
||||
} else {
|
||||
if (getDeviceOrientation() === 'potrait' && verticalSeekbar) {
|
||||
return (
|
||||
<View
|
||||
style={[
|
||||
styles.verticalSliderContainer,
|
||||
{backgroundColor: `${theme.colorPrimary}E6`},
|
||||
]}
|
||||
return (
|
||||
<View
|
||||
style={[
|
||||
styles.horizontalSliderContainer,
|
||||
{backgroundColor: `${theme.colorPrimary}E6`},
|
||||
]}
|
||||
>
|
||||
<Text
|
||||
style={{
|
||||
color: '#FFFFFF',
|
||||
marginLeft: 16,
|
||||
}}
|
||||
>
|
||||
<Text
|
||||
style={{
|
||||
color: theme.textColorPrimary,
|
||||
marginLeft: 16,
|
||||
transform: [{rotate: '-90deg'}],
|
||||
}}
|
||||
>
|
||||
{scrollPercentage}
|
||||
</Text>
|
||||
<Slider
|
||||
style={{
|
||||
flex: 1,
|
||||
height: 40,
|
||||
}}
|
||||
minimumValue={0}
|
||||
maximumValue={100}
|
||||
step={1}
|
||||
value={scrollPercentage}
|
||||
onSlidingComplete={onSlidingComplete}
|
||||
thumbTintColor={theme.colorAccent}
|
||||
minimumTrackTintColor={theme.colorAccent}
|
||||
maximumTrackTintColor={theme.textColorPrimary}
|
||||
/>
|
||||
<Text
|
||||
style={{
|
||||
color: theme.textColorPrimary,
|
||||
marginRight: 16,
|
||||
transform: [{rotate: '-90deg'}],
|
||||
}}
|
||||
>
|
||||
100
|
||||
</Text>
|
||||
</View>
|
||||
);
|
||||
} else {
|
||||
return (
|
||||
<View
|
||||
style={[
|
||||
styles.horizontalSliderContainer,
|
||||
{backgroundColor: `${theme.colorPrimary}E6`},
|
||||
]}
|
||||
{scrollPercentage}
|
||||
</Text>
|
||||
<Slider
|
||||
style={{
|
||||
flex: 1,
|
||||
height: 40,
|
||||
}}
|
||||
minimumValue={0}
|
||||
maximumValue={100}
|
||||
step={1}
|
||||
value={scrollPercentage}
|
||||
onSlidingComplete={onSlidingComplete}
|
||||
thumbTintColor={theme.colorAccent}
|
||||
minimumTrackTintColor={theme.colorAccent}
|
||||
maximumTrackTintColor={theme.textColorPrimary}
|
||||
/>
|
||||
<Text
|
||||
style={{
|
||||
color: '#FFFFFF',
|
||||
marginRight: 16,
|
||||
}}
|
||||
>
|
||||
<Text
|
||||
style={{
|
||||
color: '#FFFFFF',
|
||||
marginLeft: 16,
|
||||
}}
|
||||
>
|
||||
{scrollPercentage}
|
||||
</Text>
|
||||
<Slider
|
||||
style={{
|
||||
flex: 1,
|
||||
height: 40,
|
||||
}}
|
||||
minimumValue={0}
|
||||
maximumValue={100}
|
||||
step={1}
|
||||
value={scrollPercentage}
|
||||
onSlidingComplete={onSlidingComplete}
|
||||
thumbTintColor={theme.colorAccent}
|
||||
minimumTrackTintColor={theme.colorAccent}
|
||||
maximumTrackTintColor={theme.textColorPrimary}
|
||||
/>
|
||||
<Text
|
||||
style={{
|
||||
color: '#FFFFFF',
|
||||
marginRight: 16,
|
||||
}}
|
||||
>
|
||||
100
|
||||
</Text>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
100
|
||||
</Text>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import React from 'react';
|
||||
import {useDispatch} from 'react-redux';
|
||||
|
||||
import {Appbar} from '../../components/Appbar';
|
||||
import {List} from '../../components/List';
|
||||
|
||||
@@ -214,7 +214,9 @@ const FirstRoute = React.memo(({theme, dispatch, reader}) => {
|
||||
keyboardType="numeric"
|
||||
onChangeText={text =>
|
||||
text !== '' &&
|
||||
dispatch(setAppSettings('autoScrollInterval', parseInt(text)))
|
||||
dispatch(
|
||||
setAppSettings('autoScrollInterval', parseInt(text, 10)),
|
||||
)
|
||||
}
|
||||
/>
|
||||
</View>
|
||||
|
||||
@@ -46,14 +46,14 @@ const TrackerScreen = ({navigation}) => {
|
||||
myAnimeListConfig.authUrl,
|
||||
myAnimeListConfig.redirectUri,
|
||||
).then(res => {
|
||||
console.log(res.type);
|
||||
// console.log(res.type);
|
||||
if (res.type === 'success') {
|
||||
const {url} = res;
|
||||
|
||||
const codeExtractor = new RegExp(/=([^&]+)/);
|
||||
const codeExtractor = new RegExp(/[=]([^&]+)/);
|
||||
let code = url.match(codeExtractor);
|
||||
|
||||
console.log(code);
|
||||
// console.log(code);
|
||||
|
||||
if (code) {
|
||||
code = code[1];
|
||||
@@ -61,7 +61,7 @@ const TrackerScreen = ({navigation}) => {
|
||||
code,
|
||||
myAnimeListConfig.codeChallenge,
|
||||
).then(objects => {
|
||||
console.log(objects);
|
||||
// console.log(objects);
|
||||
dispatch(setTracker(objects));
|
||||
});
|
||||
}
|
||||
@@ -74,7 +74,7 @@ const TrackerScreen = ({navigation}) => {
|
||||
/>
|
||||
{tracker && tracker.expires_in < new Date(Date.now()) && (
|
||||
<>
|
||||
<Divider theme={theme} />
|
||||
<List.Divider theme={theme} />
|
||||
<List.SubHeader theme={theme}>Settings</List.SubHeader>
|
||||
<List.Item
|
||||
title="Revalidate MyAnimeList"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import React, {useCallback, useEffect, useState} from 'react';
|
||||
import React, {useCallback, useState} from 'react';
|
||||
import {StyleSheet, View, ActivityIndicator} from 'react-native';
|
||||
|
||||
import * as WebBrowser from 'expo-web-browser';
|
||||
@@ -43,22 +43,25 @@ const Extension = ({navigation, route}) => {
|
||||
setSearchText('');
|
||||
};
|
||||
|
||||
const getNovels = async () => {
|
||||
try {
|
||||
if (page <= totalPages) {
|
||||
const source = getSource(sourceId);
|
||||
const res = await source.popularNovels(page);
|
||||
setNovels(prevState => [...prevState, ...res.novels]);
|
||||
setTotalPages(res.totalPages);
|
||||
const getNovels = useCallback(
|
||||
async loadPage => {
|
||||
try {
|
||||
if (loadPage <= totalPages) {
|
||||
const source = getSource(sourceId);
|
||||
const res = await source.popularNovels(loadPage);
|
||||
setNovels(prevState => [...prevState, ...res.novels]);
|
||||
setTotalPages(res.totalPages);
|
||||
setLoading(false);
|
||||
}
|
||||
} catch (e) {
|
||||
setError(e.message);
|
||||
showToast(e.message);
|
||||
setNovels([]);
|
||||
setLoading(false);
|
||||
}
|
||||
} catch (error) {
|
||||
setError(error.message);
|
||||
showToast(error.message);
|
||||
setNovels([]);
|
||||
setLoading(false);
|
||||
}
|
||||
};
|
||||
},
|
||||
[sourceId, totalPages],
|
||||
);
|
||||
|
||||
const getSearchResults = async () => {
|
||||
try {
|
||||
@@ -67,30 +70,23 @@ const Extension = ({navigation, route}) => {
|
||||
const res = await source.searchNovels(searchText);
|
||||
setNovels(res);
|
||||
setLoading(false);
|
||||
} catch (error) {
|
||||
setError(error.message);
|
||||
showToast(error.message);
|
||||
} catch (e) {
|
||||
setError(e.message);
|
||||
showToast(e.message);
|
||||
setNovels([]);
|
||||
setLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
const checkIFInLibrary = useCallback(
|
||||
(sourceId, novelUrl) =>
|
||||
library.some(
|
||||
obj => obj.novelUrl === novelUrl && obj.sourceId === sourceId,
|
||||
),
|
||||
[],
|
||||
(id, novelUrl) =>
|
||||
library.some(obj => obj.novelUrl === novelUrl && obj.sourceId === id),
|
||||
[library],
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
let mounted = true;
|
||||
getNovels();
|
||||
|
||||
return () => {
|
||||
mounted = false;
|
||||
};
|
||||
}, [page]);
|
||||
useCallback(() => {
|
||||
getNovels(page);
|
||||
}, [page, getNovels]);
|
||||
|
||||
const getNextPage = () => {
|
||||
if (!searchText) {
|
||||
|
||||
@@ -2,7 +2,6 @@ import React, {useState, useCallback} from 'react';
|
||||
import {
|
||||
StyleSheet,
|
||||
View,
|
||||
FlatList,
|
||||
ActivityIndicator,
|
||||
RefreshControl,
|
||||
Text,
|
||||
@@ -44,7 +43,7 @@ const Updates = ({navigation}) => {
|
||||
useFocusEffect(
|
||||
useCallback(() => {
|
||||
dispatch(getUpdatesAction());
|
||||
}, []),
|
||||
}, [dispatch]),
|
||||
);
|
||||
|
||||
const onRefresh = async () => {
|
||||
@@ -65,7 +64,7 @@ const Updates = ({navigation}) => {
|
||||
novelName: item.novelName,
|
||||
bookmark: item.bookmark,
|
||||
}),
|
||||
[],
|
||||
[navigation],
|
||||
);
|
||||
|
||||
const onPressCover = useCallback(
|
||||
@@ -76,7 +75,7 @@ const Updates = ({navigation}) => {
|
||||
novelName: item.novelName,
|
||||
novelCover: item.novelCover,
|
||||
}),
|
||||
[],
|
||||
[navigation],
|
||||
);
|
||||
|
||||
const downloadChapter = useCallback(
|
||||
@@ -91,13 +90,16 @@ const Updates = ({navigation}) => {
|
||||
),
|
||||
);
|
||||
},
|
||||
[],
|
||||
[dispatch],
|
||||
);
|
||||
|
||||
const deleteChapter = useCallback((chapterId, chapterName) => {
|
||||
dispatch(deleteChapterAction(chapterId, chapterName));
|
||||
dispatch(getUpdatesAction());
|
||||
}, []);
|
||||
const deleteChapter = useCallback(
|
||||
(chapterId, chapterName) => {
|
||||
dispatch(deleteChapterAction(chapterId, chapterName));
|
||||
dispatch(getUpdatesAction());
|
||||
},
|
||||
[dispatch],
|
||||
);
|
||||
|
||||
const renderItem = ({item}) => (
|
||||
<UpdatesItem
|
||||
|
||||
@@ -27,7 +27,7 @@ const redirectUri = Linking.makeUrl();
|
||||
|
||||
export const authUrl = `${baseOAuthUrl}?response_type=code&client_id=${clientId}&code_challenge_method=plain&code_challenge=${codeChallenge}`;
|
||||
|
||||
const tokenUrl = `https://myanimelist.net/v1/oauth2/token`;
|
||||
const tokenUrl = 'https://myanimelist.net/v1/oauth2/token';
|
||||
|
||||
export const myAnimeListConfig = {
|
||||
clientId,
|
||||
@@ -37,7 +37,7 @@ export const myAnimeListConfig = {
|
||||
tokenUrl,
|
||||
};
|
||||
|
||||
export const getAccessToken = async (code, codeChallenge) => {
|
||||
export const getAccessToken = async (code, challenge) => {
|
||||
const headers = {
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
};
|
||||
@@ -46,7 +46,7 @@ export const getAccessToken = async (code, codeChallenge) => {
|
||||
client_id: myAnimeListConfig.clientId,
|
||||
grant_type: 'authorization_code',
|
||||
code,
|
||||
code_verifier: codeChallenge,
|
||||
code_verifier: challenge,
|
||||
};
|
||||
|
||||
const response = await fetch(myAnimeListConfig.tokenUrl, {
|
||||
@@ -62,7 +62,7 @@ export const getAccessToken = async (code, codeChallenge) => {
|
||||
expires_in: new Date(Date.now() + tokenResponse.expires_in),
|
||||
};
|
||||
|
||||
console.log(tokenResponse);
|
||||
// console.log(tokenResponse);
|
||||
|
||||
return tokenResponse;
|
||||
};
|
||||
@@ -117,7 +117,7 @@ export const updateItem = async (malId, bearerToken, body) => {
|
||||
});
|
||||
|
||||
const listItem = await res.json();
|
||||
console.log(listItem);
|
||||
// console.log(listItem);
|
||||
return listItem;
|
||||
};
|
||||
|
||||
@@ -136,7 +136,7 @@ export const updateMalChaptersRead = async (malId, bearerToken, body) => {
|
||||
});
|
||||
|
||||
const listItem = await res.json();
|
||||
console.log(listItem.num_chapters_read);
|
||||
// console.log(listItem.num_chapters_read);
|
||||
return listItem.num_chapters_read;
|
||||
};
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import * as SQLite from 'expo-sqlite';
|
||||
const db = SQLite.openDatabase('lnreader.db');
|
||||
|
||||
const getLibraryNovelsQuery = `SELECT * FROM novels WHERE followed = 1`;
|
||||
const getLibraryNovelsQuery = 'SELECT * FROM novels WHERE followed = 1';
|
||||
|
||||
const getLibraryNovels = () => {
|
||||
return new Promise((resolve, reject) =>
|
||||
@@ -16,7 +16,8 @@ const getLibraryNovels = () => {
|
||||
);
|
||||
};
|
||||
|
||||
const getLibraryChaptersQuery = `SELECT chapters.* FROM chapters JOIN novels ON chapters.novelId = novels.novelId WHERE novels.followed = 1`;
|
||||
const getLibraryChaptersQuery =
|
||||
'SELECT chapters.* FROM chapters JOIN novels ON chapters.novelId = novels.novelId WHERE novels.followed = 1';
|
||||
|
||||
const getLibraryChapters = () => {
|
||||
return new Promise((resolve, reject) =>
|
||||
@@ -31,7 +32,8 @@ const getLibraryChapters = () => {
|
||||
);
|
||||
};
|
||||
|
||||
const getLibraryDownloadsQuery = `SELECT downloads.* FROM downloads JOIN chapters ON downloads.downloadChapterId = chapters.chapterId JOIN novels ON chapters.novelId = novels.novelId WHERE novels.followed = 1`;
|
||||
const getLibraryDownloadsQuery =
|
||||
'SELECT downloads.* FROM downloads JOIN chapters ON downloads.downloadChapterId = chapters.chapterId JOIN novels ON chapters.novelId = novels.novelId WHERE novels.followed = 1';
|
||||
|
||||
const getLibraryDownloads = () => {
|
||||
return new Promise((resolve, reject) =>
|
||||
@@ -46,7 +48,8 @@ const getLibraryDownloads = () => {
|
||||
);
|
||||
};
|
||||
|
||||
const restoreNovelsQuery = `INSERT OR REPLACE INTO novels (novelId, novelUrl, sourceUrl, sourceId, source, novelName, novelCover, novelSummary, author, artist, status, genre, followed, unread) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`;
|
||||
const restoreNovelsQuery =
|
||||
'INSERT OR REPLACE INTO novels (novelId, novelUrl, sourceUrl, sourceId, source, novelName, novelCover, novelSummary, author, artist, status, genre, followed, unread) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)';
|
||||
|
||||
const restoreNovels = async novel => {
|
||||
db.transaction(tx =>
|
||||
@@ -74,7 +77,8 @@ const restoreNovels = async novel => {
|
||||
);
|
||||
};
|
||||
|
||||
const restoreChaptersQuery = `INSERT OR IGNORE INTO chapters (novelId, chapterId, chapterUrl, chapterName, releaseDate, bookmark, \`read\`, downloaded) VALUES (?, ?, ?, ?, ?, ?, ?, ?)`;
|
||||
const restoreChaptersQuery =
|
||||
'INSERT OR IGNORE INTO chapters (novelId, chapterId, chapterUrl, chapterName, releaseDate, bookmark, `read`, downloaded) VALUES (?, ?, ?, ?, ?, ?, ?, ?)';
|
||||
|
||||
const restoreChapters = async chapter => {
|
||||
const {
|
||||
@@ -107,7 +111,8 @@ const restoreChapters = async chapter => {
|
||||
);
|
||||
};
|
||||
|
||||
const restoreDownloadsQuery = `INSERT OR IGNORE INTO downloads (downloadChapterId, chapterName, chapterText) VALUES (?, ?, ?)`;
|
||||
const restoreDownloadsQuery =
|
||||
'INSERT OR IGNORE INTO downloads (downloadChapterId, chapterName, chapterText) VALUES (?, ?, ?)';
|
||||
|
||||
const restoreDownloads = async chapter => {
|
||||
const {downloadChapterId, chapterName, chapterText} = chapter;
|
||||
|
||||
@@ -54,7 +54,7 @@ export const updateNovel = async (sourceId, novelUrl, novelId) => {
|
||||
tx.executeSql(
|
||||
"INSERT OR IGNORE INTO updates (chapterId, novelId, updateTime) values (?, ?, (datetime('now','localtime')))",
|
||||
[insertId, novelId],
|
||||
(txObj, res) => {
|
||||
(txOBJ, res) => {
|
||||
// console.log(
|
||||
// "Inserted Chapter Id -> " +
|
||||
// insertId +
|
||||
@@ -62,7 +62,7 @@ export const updateNovel = async (sourceId, novelUrl, novelId) => {
|
||||
// novelId
|
||||
// );
|
||||
},
|
||||
(txObj, error) => console.log('Error ', error),
|
||||
(txOBJ, error) => console.log('Error ', error),
|
||||
);
|
||||
}
|
||||
},
|
||||
@@ -95,8 +95,8 @@ export const updateNovelChapters = async (
|
||||
tx.executeSql(
|
||||
"INSERT OR IGNORE INTO updates (chapterId, novelId, updateTime) values (?, ?, (datetime('now','localtime')))",
|
||||
[insertId, novelId],
|
||||
(txObj, res) => {},
|
||||
(txObj, error) => console.log('Error ', error),
|
||||
(txOBJ, res) => {},
|
||||
(txOBJ, error) => console.log('Error ', error),
|
||||
);
|
||||
}
|
||||
},
|
||||
|
||||
@@ -16,7 +16,7 @@ export const parseChapterNumber = chapterName => {
|
||||
}
|
||||
};
|
||||
|
||||
export const getDeviceOrientation = () => {
|
||||
export const useDeviceOrientation = () => {
|
||||
const window = useWindowDimensions();
|
||||
|
||||
if (window.width > window.height) {
|
||||
|
||||
+32
-24
@@ -12,16 +12,19 @@ const popularNovels = async page => {
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
let loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novels = [];
|
||||
|
||||
$('.page-item-detail').each(function () {
|
||||
const novelName = $(this).find('.h5 > a').text();
|
||||
loadedCheerio('.page-item-detail').each(function () {
|
||||
const novelName = loadedCheerio(this).find('.h5 > a').text();
|
||||
const novelCover =
|
||||
'https://github.com/LNReader/lnreader-sources/blob/main/src/coverNotAvailable.jpg?raw=true';
|
||||
|
||||
let novelUrl = $(this).find('.h5 > a').attr('href').split('/')[4];
|
||||
let novelUrl = loadedCheerio(this)
|
||||
.find('.h5 > a')
|
||||
.attr('href')
|
||||
.split('/')[4];
|
||||
|
||||
const novel = {
|
||||
sourceId,
|
||||
@@ -42,11 +45,11 @@ const parseNovelAndChapters = async novelUrl => {
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
let loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novel = {sourceId, sourceName, url, novelUrl};
|
||||
|
||||
novel.novelName = $('.post-title > h1')
|
||||
novel.novelName = loadedCheerio('.post-title > h1')
|
||||
.text()
|
||||
.replace(/[\t\n]/g, '')
|
||||
.trim();
|
||||
@@ -54,13 +57,13 @@ const parseNovelAndChapters = async novelUrl => {
|
||||
novel.novelCover =
|
||||
'https://github.com/LNReader/lnreader-sources/blob/main/src/coverNotAvailable.jpg?raw=true';
|
||||
|
||||
$('.post-content_item').each(function () {
|
||||
detailName = $(this)
|
||||
loadedCheerio('.post-content_item').each(function () {
|
||||
const detailName = loadedCheerio(this)
|
||||
.find('.summary-heading > h5')
|
||||
.text()
|
||||
.replace(/[\t\n]/g, '')
|
||||
.trim();
|
||||
detail = $(this)
|
||||
const detail = loadedCheerio(this)
|
||||
.find('.summary-content')
|
||||
.text()
|
||||
.replace(/[\t\n]/g, '')
|
||||
@@ -79,15 +82,17 @@ const parseNovelAndChapters = async novelUrl => {
|
||||
}
|
||||
});
|
||||
|
||||
$('.description-summary > div.summary__content').find('em').remove();
|
||||
loadedCheerio('.description-summary > div.summary__content')
|
||||
.find('em')
|
||||
.remove();
|
||||
|
||||
novel.summary = $('.description-summary > div.summary__content')
|
||||
novel.summary = loadedCheerio('.description-summary > div.summary__content')
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
let novelChapters = [];
|
||||
|
||||
// const novelId = $('#manga-chapters-holder').attr('data-id');
|
||||
// const novelId = loadedCheerio('#manga-chapters-holder').attr('data-id');
|
||||
|
||||
// let formData = new FormData();
|
||||
// formData.append('action', 'manga_get_chapters');
|
||||
@@ -98,18 +103,18 @@ const parseNovelAndChapters = async novelUrl => {
|
||||
});
|
||||
const text = await data.text();
|
||||
|
||||
$ = cheerio.load(text);
|
||||
loadedCheerio = cheerio.load(text);
|
||||
|
||||
$('.wp-manga-chapter').each(function () {
|
||||
chapterName = $(this)
|
||||
loadedCheerio('.wp-manga-chapter').each(function () {
|
||||
const chapterName = loadedCheerio(this)
|
||||
.find('a')
|
||||
.text()
|
||||
.replace(/[\t\n]/g, '')
|
||||
.trim();
|
||||
|
||||
releaseDate = $(this).find('span').text().trim();
|
||||
const releaseDate = loadedCheerio(this).find('span').text().trim();
|
||||
|
||||
chapterUrl = $(this).find('a').attr('href').split('/');
|
||||
let chapterUrl = loadedCheerio(this).find('a').attr('href').split('/');
|
||||
|
||||
chapterUrl[6]
|
||||
? (chapterUrl = chapterUrl[5] + '/' + chapterUrl[6])
|
||||
@@ -129,10 +134,10 @@ const parseChapter = async (novelUrl, chapterUrl) => {
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
let loadedCheerio = cheerio.load(body);
|
||||
|
||||
const chapterName = $('h1#chapter-heading').text();
|
||||
const chapterText = $('.reading-content').html();
|
||||
const chapterName = loadedCheerio('h1#chapter-heading').text();
|
||||
const chapterText = loadedCheerio('.reading-content').html();
|
||||
|
||||
const chapter = {
|
||||
sourceId,
|
||||
@@ -151,16 +156,19 @@ const searchNovels = async searchTerm => {
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
let loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novels = [];
|
||||
|
||||
$('.c-tabs-item__content').each(function () {
|
||||
const novelName = $(this).find('.h4 > a').text();
|
||||
loadedCheerio('.c-tabs-item__content').each(function () {
|
||||
const novelName = loadedCheerio(this).find('.h4 > a').text();
|
||||
const novelCover =
|
||||
'https://github.com/LNReader/lnreader-sources/blob/main/src/coverNotAvailable.jpg?raw=true';
|
||||
|
||||
let novelUrl = $(this).find('.h4 > a').attr('href').split('/')[4];
|
||||
let novelUrl = loadedCheerio(this)
|
||||
.find('.h4 > a')
|
||||
.attr('href')
|
||||
.split('/')[4];
|
||||
|
||||
const novel = {
|
||||
sourceId,
|
||||
|
||||
@@ -14,15 +14,20 @@ const popularNovels = async page => {
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
let loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novels = [];
|
||||
|
||||
$('.page-item-detail').each(function () {
|
||||
const novelName = $(this).find('.item-summary h3').text().trim();
|
||||
const novelCover = $(this).find('.img-responsive').attr('data-src');
|
||||
loadedCheerio('.page-item-detail').each(function () {
|
||||
const novelName = loadedCheerio(this)
|
||||
.find('.item-summary h3')
|
||||
.text()
|
||||
.trim();
|
||||
const novelCover = loadedCheerio(this)
|
||||
.find('.img-responsive')
|
||||
.attr('data-src');
|
||||
|
||||
let novelUrl = $(this).find('div > a').attr('href');
|
||||
let novelUrl = loadedCheerio(this).find('div > a').attr('href');
|
||||
|
||||
const novel = {
|
||||
sourceId,
|
||||
@@ -43,21 +48,24 @@ const parseNovelAndChapters = async novelUrl => {
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
let loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novel = {sourceId, url, sourceName};
|
||||
|
||||
$('.post-title > h3 > span').remove();
|
||||
loadedCheerio('.post-title > h3 > span').remove();
|
||||
|
||||
novel.novelUrl = novelUrl;
|
||||
|
||||
novel.novelName = $('.post-title > h1').text().trim();
|
||||
novel.novelName = loadedCheerio('.post-title > h1').text().trim();
|
||||
|
||||
novel.novelCover = $('.summary_image > a > img').attr('data-src');
|
||||
novel.novelCover = loadedCheerio('.summary_image > a > img').attr('data-src');
|
||||
|
||||
$('.post-content_item').each(function () {
|
||||
const detailName = $(this).find('.summary-heading > h5').text().trim();
|
||||
const detail = $(this).find('.summary-content').text().trim();
|
||||
loadedCheerio('.post-content_item').each(function () {
|
||||
const detailName = loadedCheerio(this)
|
||||
.find('.summary-heading > h5')
|
||||
.text()
|
||||
.trim();
|
||||
const detail = loadedCheerio(this).find('.summary-content').text().trim();
|
||||
|
||||
switch (detailName) {
|
||||
case 'Genre(s)':
|
||||
@@ -74,25 +82,27 @@ const parseNovelAndChapters = async novelUrl => {
|
||||
}
|
||||
});
|
||||
|
||||
$('.description-summary > div.summary__content').find('em').remove();
|
||||
$('.premium-block').remove();
|
||||
loadedCheerio('.description-summary > div.summary__content')
|
||||
.find('em')
|
||||
.remove();
|
||||
loadedCheerio('.premium-block').remove();
|
||||
|
||||
novel.summary = $('div.summary__content').text().trim();
|
||||
novel.summary = loadedCheerio('div.summary__content').text().trim();
|
||||
|
||||
let novelChapters = [];
|
||||
|
||||
const data = await fetch(novelUrl + 'ajax/chapters', {method: 'POST'});
|
||||
const text = await data.text();
|
||||
|
||||
$ = cheerio.load(text);
|
||||
loadedCheerio = cheerio.load(text);
|
||||
|
||||
$('.wp-manga-chapter').each(function () {
|
||||
$('i').remove();
|
||||
loadedCheerio('.wp-manga-chapter').each(function () {
|
||||
loadedCheerio('i').remove();
|
||||
|
||||
const chapterName = $(this).find('a').text().trim();
|
||||
const chapterName = loadedCheerio(this).find('a').text().trim();
|
||||
const releaseDate = null;
|
||||
|
||||
const chapterUrl = $(this).find('a').attr('href');
|
||||
const chapterUrl = loadedCheerio(this).find('a').attr('href');
|
||||
|
||||
const chapter = {chapterName, releaseDate, chapterUrl};
|
||||
|
||||
@@ -110,10 +120,10 @@ const parseChapter = async (novelUrl, chapterUrl) => {
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
let loadedCheerio = cheerio.load(body);
|
||||
|
||||
const chapterName = $('#chapter-heading').text();
|
||||
const chapterText = $('.reading-content').html();
|
||||
const chapterName = loadedCheerio('#chapter-heading').text();
|
||||
const chapterText = loadedCheerio('.reading-content').html();
|
||||
|
||||
const chapter = {
|
||||
sourceId,
|
||||
@@ -132,15 +142,20 @@ const searchNovels = async searchTerm => {
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
let loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novels = [];
|
||||
|
||||
$('.c-tabs-item__content').each(function (result) {
|
||||
const novelName = $(this).find('.post-title > h3').text().trim();
|
||||
const novelCover = $(this).find('div > div > a > img').attr('data-src');
|
||||
loadedCheerio('.c-tabs-item__content').each(function () {
|
||||
const novelName = loadedCheerio(this)
|
||||
.find('.post-title > h3')
|
||||
.text()
|
||||
.trim();
|
||||
const novelCover = loadedCheerio(this)
|
||||
.find('div > div > a > img')
|
||||
.attr('data-src');
|
||||
|
||||
let novelUrl = $(this).find('div > div > a').attr('href');
|
||||
let novelUrl = loadedCheerio(this).find('div > div > a').attr('href');
|
||||
novelUrl = novelUrl.replace(`${baseUrl}/`, '');
|
||||
|
||||
const novel = {
|
||||
|
||||
@@ -15,15 +15,20 @@ const popularNovels = async page => {
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
let loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novels = [];
|
||||
|
||||
$('.page-item-detail').each(function (result) {
|
||||
const novelName = $(this).find('.item-summary h3').text().trim();
|
||||
const novelCover = $(this).find('.img-responsive').attr('data-src');
|
||||
loadedCheerio('.page-item-detail').each(function () {
|
||||
const novelName = loadedCheerio(this)
|
||||
.find('.item-summary h3')
|
||||
.text()
|
||||
.trim();
|
||||
const novelCover = loadedCheerio(this)
|
||||
.find('.img-responsive')
|
||||
.attr('data-src');
|
||||
|
||||
let novelUrl = $(this).find('div > a').attr('href');
|
||||
let novelUrl = loadedCheerio(this).find('div > a').attr('href');
|
||||
|
||||
const novel = {
|
||||
sourceId,
|
||||
@@ -44,21 +49,24 @@ const parseNovelAndChapters = async novelUrl => {
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
let loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novel = {sourceId, url, sourceName};
|
||||
|
||||
$('.post-title > h3 > span').remove();
|
||||
loadedCheerio('.post-title > h3 > span').remove();
|
||||
|
||||
novel.novelUrl = novelUrl;
|
||||
|
||||
novel.novelName = $('.post-title > h1').text().trim();
|
||||
novel.novelName = loadedCheerio('.post-title > h1').text().trim();
|
||||
|
||||
novel.novelCover = $('.summary_image > a > img').attr('data-src');
|
||||
novel.novelCover = loadedCheerio('.summary_image > a > img').attr('data-src');
|
||||
|
||||
$('.post-content_item').each(function () {
|
||||
const detailName = $(this).find('.summary-heading > h5').text().trim();
|
||||
const detail = $(this).find('.summary-content').text().trim();
|
||||
loadedCheerio('.post-content_item').each(function () {
|
||||
const detailName = loadedCheerio(this)
|
||||
.find('.summary-heading > h5')
|
||||
.text()
|
||||
.trim();
|
||||
const detail = loadedCheerio(this).find('.summary-content').text().trim();
|
||||
|
||||
switch (detailName) {
|
||||
case 'Genre(s)':
|
||||
@@ -75,20 +83,22 @@ const parseNovelAndChapters = async novelUrl => {
|
||||
}
|
||||
});
|
||||
|
||||
$('.description-summary > div.summary__content').find('em').remove();
|
||||
$('.premium-block').remove();
|
||||
loadedCheerio('.description-summary > div.summary__content')
|
||||
.find('em')
|
||||
.remove();
|
||||
loadedCheerio('.premium-block').remove();
|
||||
|
||||
novel.summary = $('div.summary__content').text().trim();
|
||||
novel.summary = loadedCheerio('div.summary__content').text().trim();
|
||||
|
||||
let novelChapters = [];
|
||||
|
||||
$('.wp-manga-chapter').each(function () {
|
||||
$('i').remove();
|
||||
loadedCheerio('.wp-manga-chapter').each(function () {
|
||||
loadedCheerio('i').remove();
|
||||
|
||||
const chapterName = $(this).find('a').text().trim();
|
||||
const chapterName = loadedCheerio(this).find('a').text().trim();
|
||||
const releaseDate = null;
|
||||
|
||||
const chapterUrl = $(this).find('a').attr('href');
|
||||
const chapterUrl = loadedCheerio(this).find('a').attr('href');
|
||||
|
||||
const chapter = {chapterName, releaseDate, chapterUrl};
|
||||
|
||||
@@ -106,10 +116,10 @@ const parseChapter = async (novelUrl, chapterUrl) => {
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
let loadedCheerio = cheerio.load(body);
|
||||
|
||||
const chapterName = $('#chapter-heading').text();
|
||||
let chapterText = $('.reading-content').html();
|
||||
const chapterName = loadedCheerio('#chapter-heading').text();
|
||||
let chapterText = loadedCheerio('.reading-content').html();
|
||||
const chapter = {
|
||||
sourceId,
|
||||
novelUrl,
|
||||
@@ -127,15 +137,20 @@ const searchNovels = async searchTerm => {
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
let loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novels = [];
|
||||
|
||||
$('.c-tabs-item__content').each(function (result) {
|
||||
const novelName = $(this).find('.post-title > h3').text().trim();
|
||||
const novelCover = $(this).find('div > div > a > img').attr('data-src');
|
||||
loadedCheerio('.c-tabs-item__content').each(function () {
|
||||
const novelName = loadedCheerio(this)
|
||||
.find('.post-title > h3')
|
||||
.text()
|
||||
.trim();
|
||||
const novelCover = loadedCheerio(this)
|
||||
.find('div > div > a > img')
|
||||
.attr('data-src');
|
||||
|
||||
let novelUrl = $(this).find('div > div > a').attr('href');
|
||||
let novelUrl = loadedCheerio(this).find('div > div > a').attr('href');
|
||||
novelUrl = novelUrl.replace(`${baseUrl}/`, '');
|
||||
|
||||
const novel = {
|
||||
|
||||
+30
-22
@@ -14,16 +14,20 @@ const popularNovels = async page => {
|
||||
});
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
let loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novels = [];
|
||||
|
||||
$('.clearfix > li').each(function (result) {
|
||||
loadedCheerio('.clearfix > li').each(function () {
|
||||
const novelUrl =
|
||||
$(this).find('a').attr('href').replace('.html', '').substring(1) + '/';
|
||||
loadedCheerio(this)
|
||||
.find('a')
|
||||
.attr('href')
|
||||
.replace('.html', '')
|
||||
.substring(1) + '/';
|
||||
|
||||
const novelName = $(this).find('a').text();
|
||||
let novelCover = $(this).find('img').attr('src');
|
||||
const novelName = loadedCheerio(this).find('a').text();
|
||||
let novelCover = loadedCheerio(this).find('img').attr('src');
|
||||
novelCover = novelCover.includes('https://tva1.sinaimg.cn/')
|
||||
? `${novelCover}`
|
||||
: `${baseUrl}${novelCover}`;
|
||||
@@ -52,7 +56,7 @@ const parseNovelAndChapters = async novelUrl => {
|
||||
});
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
let loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novel = {};
|
||||
|
||||
@@ -64,15 +68,15 @@ const parseNovelAndChapters = async novelUrl => {
|
||||
|
||||
novel.novelUrl = novelUrl;
|
||||
|
||||
novel.novelName = $('dd > h2').text();
|
||||
novel.novelName = loadedCheerio('dd > h2').text();
|
||||
|
||||
novel.novelCover = $('dt > img').attr('src');
|
||||
novel.novelCover = loadedCheerio('dt > img').attr('src');
|
||||
|
||||
novel.summary = $('div.content > p').text();
|
||||
novel.summary = loadedCheerio('div.content > p').text();
|
||||
|
||||
let info = [];
|
||||
$('.info a').each(function (result) {
|
||||
info.push($(this).text());
|
||||
loadedCheerio('.info a').each(function () {
|
||||
info.push(loadedCheerio(this).text());
|
||||
});
|
||||
|
||||
novel.genre = info[0];
|
||||
@@ -85,9 +89,9 @@ const parseNovelAndChapters = async novelUrl => {
|
||||
|
||||
let chapters = [];
|
||||
|
||||
$('.bookshelf-list a').each(function (result) {
|
||||
let chapterUrl = $(this).attr('href').substring(1);
|
||||
let chapterName = $(this).attr('title');
|
||||
loadedCheerio('.bookshelf-list a').each(function () {
|
||||
let chapterUrl = loadedCheerio(this).attr('href').substring(1);
|
||||
let chapterName = loadedCheerio(this).attr('title');
|
||||
let releaseDate = null;
|
||||
|
||||
chapters.push({
|
||||
@@ -113,10 +117,10 @@ const parseChapter = async (novelUrl, chapterUrl) => {
|
||||
});
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
let loadedCheerio = cheerio.load(body);
|
||||
|
||||
const chapterName = $('.read-section h3').text();
|
||||
let chapterText = $('.read-section').html();
|
||||
const chapterName = loadedCheerio('.read-section h3').text();
|
||||
let chapterText = loadedCheerio('.read-section').html();
|
||||
|
||||
const chapter = {
|
||||
sourceId: 52,
|
||||
@@ -144,16 +148,20 @@ const searchNovels = async searchTerm => {
|
||||
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
let loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novels = [];
|
||||
|
||||
$('.clearfix > li').each(function (result) {
|
||||
loadedCheerio('.clearfix > li').each(function () {
|
||||
let novelUrl =
|
||||
$(this).find('a').attr('href').replace('.html', '').substring(1) + '/';
|
||||
loadedCheerio(this)
|
||||
.find('a')
|
||||
.attr('href')
|
||||
.replace('.html', '')
|
||||
.substring(1) + '/';
|
||||
|
||||
const novelName = $(this).find('a').text();
|
||||
let novelCover = $(this).find('img').attr('src');
|
||||
const novelName = loadedCheerio(this).find('a').text();
|
||||
let novelCover = loadedCheerio(this).find('img').attr('src');
|
||||
novelCover = novelCover.includes('https://tva1.sinaimg.cn/')
|
||||
? `${novelCover}`
|
||||
: `${baseUrl}${novelCover}`;
|
||||
|
||||
+32
-27
@@ -12,15 +12,15 @@ const popularNovels = async page => {
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
|
||||
const $ = cheerio.load(body);
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novels = [];
|
||||
|
||||
$('.page-item-detail').each(function (result) {
|
||||
const novelName = $(this).find('h3 > a').text();
|
||||
const novelCover = $(this).find('img').attr('src');
|
||||
loadedCheerio('.page-item-detail').each(function () {
|
||||
const novelName = loadedCheerio(this).find('h3 > a').text();
|
||||
const novelCover = loadedCheerio(this).find('img').attr('src');
|
||||
|
||||
let novelUrl = $(this).find('h3 > a').attr('href');
|
||||
let novelUrl = loadedCheerio(this).find('h3 > a').attr('href');
|
||||
novelUrl = novelUrl.replace(`${baseUrl}/`, '');
|
||||
|
||||
const novel = {
|
||||
@@ -42,11 +42,11 @@ const parseNovelAndChapters = async novelUrl => {
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
|
||||
let $ = cheerio.load(body);
|
||||
let loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novel = {};
|
||||
|
||||
$('.post-title > h3 > span').remove();
|
||||
loadedCheerio('.post-title > h3 > span').remove();
|
||||
|
||||
novel.sourceId = 1;
|
||||
|
||||
@@ -56,20 +56,20 @@ const parseNovelAndChapters = async novelUrl => {
|
||||
|
||||
novel.novelUrl = novelUrl;
|
||||
|
||||
novel.novelName = $('.post-title > h3')
|
||||
novel.novelName = loadedCheerio('.post-title > h3')
|
||||
.text()
|
||||
.replace(/[\t\n]/g, '')
|
||||
.trim();
|
||||
|
||||
novel.novelCover = $('.summary_image > a > img').attr('src');
|
||||
novel.novelCover = loadedCheerio('.summary_image > a > img').attr('src');
|
||||
|
||||
$('.post-content_item').each(function (result) {
|
||||
detailName = $(this)
|
||||
loadedCheerio('.post-content_item').each(function () {
|
||||
const detailName = loadedCheerio(this)
|
||||
.find('.summary-heading > h5')
|
||||
.text()
|
||||
.replace(/[\t\n]/g, '')
|
||||
.trim();
|
||||
detail = $(this)
|
||||
const detail = loadedCheerio(this)
|
||||
.find('.summary-content')
|
||||
.text()
|
||||
.replace(/[\t\n]/g, '')
|
||||
@@ -88,9 +88,11 @@ const parseNovelAndChapters = async novelUrl => {
|
||||
}
|
||||
});
|
||||
|
||||
$('.description-summary > div.summary__content').find('em').remove();
|
||||
loadedCheerio('.description-summary > div.summary__content')
|
||||
.find('em')
|
||||
.remove();
|
||||
|
||||
novel.summary = $('.description-summary > div.summary__content')
|
||||
novel.summary = loadedCheerio('.description-summary > div.summary__content')
|
||||
.text()
|
||||
.replace(/[\t\n]|Description|Summary/g, '');
|
||||
|
||||
@@ -99,22 +101,25 @@ const parseNovelAndChapters = async novelUrl => {
|
||||
const data = await fetch(`${url}ajax/chapters/`, {method: 'POST'});
|
||||
const text = await data.text();
|
||||
|
||||
$ = cheerio.load(text);
|
||||
loadedCheerio = cheerio.load(text);
|
||||
|
||||
$('.wp-manga-chapter').each(function () {
|
||||
const chapterName = $(this)
|
||||
loadedCheerio('.wp-manga-chapter').each(function () {
|
||||
const chapterName = loadedCheerio(this)
|
||||
.find('a')
|
||||
.text()
|
||||
.replace(/[\t\n]/g, '')
|
||||
.trim();
|
||||
|
||||
const releaseDate = $(this)
|
||||
const releaseDate = loadedCheerio(this)
|
||||
.find('span')
|
||||
.text()
|
||||
.replace(/[\t\n]/g, '')
|
||||
.trim();
|
||||
|
||||
const chapterUrl = $(this).find('a').attr('href').replace(url, '');
|
||||
const chapterUrl = loadedCheerio(this)
|
||||
.find('a')
|
||||
.attr('href')
|
||||
.replace(url, '');
|
||||
|
||||
const chapter = {chapterName, releaseDate, chapterUrl};
|
||||
|
||||
@@ -132,10 +137,10 @@ const parseChapter = async (novelUrl, chapterUrl) => {
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
const chapterName = $('div.text-left > h3').text();
|
||||
let chapterText = $('.reading-content').html();
|
||||
const chapterName = loadedCheerio('div.text-left > h3').text();
|
||||
let chapterText = loadedCheerio('.reading-content').html();
|
||||
const chapter = {
|
||||
sourceId,
|
||||
novelUrl,
|
||||
@@ -153,15 +158,15 @@ const searchNovels = async searchTerm => {
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novels = [];
|
||||
|
||||
$('.c-tabs-item__content').each(function (result) {
|
||||
const novelName = $(this).find('h4 > a').text();
|
||||
const novelCover = $(this).find('img').attr('src');
|
||||
loadedCheerio('.c-tabs-item__content').each(function () {
|
||||
const novelName = loadedCheerio(this).find('h4 > a').text();
|
||||
const novelCover = loadedCheerio(this).find('img').attr('src');
|
||||
|
||||
let novelUrl = $(this).find('h4 > a').attr('href');
|
||||
let novelUrl = loadedCheerio(this).find('h4 > a').attr('href');
|
||||
novelUrl = novelUrl.replace(`${baseUrl}/`, '');
|
||||
|
||||
const novel = {
|
||||
|
||||
@@ -13,19 +13,19 @@ const popularNovels = async page => {
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novels = [];
|
||||
|
||||
$('div.container')
|
||||
loadedCheerio('div.container')
|
||||
.find('section')
|
||||
.each(function () {
|
||||
const novelName = $(this)
|
||||
const novelName = loadedCheerio(this)
|
||||
.find('div.columns > div:nth-child(2) > a')
|
||||
.text();
|
||||
const novelCover = $(this).find('img').attr('src');
|
||||
const novelCover = loadedCheerio(this).find('img').attr('src');
|
||||
|
||||
let novelUrl = $(this)
|
||||
let novelUrl = loadedCheerio(this)
|
||||
.find('div.columns > div:nth-child(2) > a')
|
||||
.attr('href');
|
||||
novelUrl = novelUrl.replace(baseUrl + 'novel/', '');
|
||||
@@ -45,35 +45,37 @@ const popularNovels = async page => {
|
||||
|
||||
const parseNovelAndChapters = async novelUrl => {
|
||||
const url = baseUrl + 'novel/' + novelUrl;
|
||||
console.log(url);
|
||||
// console.log(url);
|
||||
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novel = {sourceId, sourceName, url, novelUrl};
|
||||
|
||||
novel.novelName = $(
|
||||
novel.novelName = loadedCheerio(
|
||||
'#NovelInfo > div > div.column.is-one-third.has-text-centered > p',
|
||||
)
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
novel.novelCover = $('img.attachment-post-thumbnail').attr('src');
|
||||
novel.novelCover = loadedCheerio('img.attachment-post-thumbnail').attr('src');
|
||||
|
||||
novel.summary = $('#NovelInfo > div > div:nth-child(2) > p').text().trim();
|
||||
novel.summary = loadedCheerio('#NovelInfo > div > div:nth-child(2) > p')
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
novel.genre = $('#NovelInfo > p:nth-child(2)')
|
||||
novel.genre = loadedCheerio('#NovelInfo > p:nth-child(2)')
|
||||
.text()
|
||||
.replace(/Genre(s):|\s/g, '');
|
||||
|
||||
novel.status = $('#NovelInfo > p:nth-child(5)')
|
||||
novel.status = loadedCheerio('#NovelInfo > p:nth-child(5)')
|
||||
.text()
|
||||
.replace(/Status:|\s/g, '')
|
||||
.trim();
|
||||
|
||||
novel.author = $('#NovelInfo > p:nth-child(4)')
|
||||
novel.author = loadedCheerio('#NovelInfo > p:nth-child(4)')
|
||||
.text()
|
||||
.replace(/Publisher:|\s/g, '')
|
||||
.trim();
|
||||
@@ -97,7 +99,7 @@ const parseNovelAndChapters = async novelUrl => {
|
||||
|
||||
// $("small").remove();
|
||||
|
||||
let chapterUrlPrefix = $('table > tbody')
|
||||
let chapterUrlPrefix = loadedCheerio('table > tbody')
|
||||
.find('tr')
|
||||
.first()
|
||||
.find('a')
|
||||
@@ -111,7 +113,7 @@ const parseNovelAndChapters = async novelUrl => {
|
||||
|
||||
chapterUrlPrefix = chapterUrlPrefix.join('-').toLowerCase();
|
||||
|
||||
let latestChapter = $('table > tbody')
|
||||
let latestChapter = loadedCheerio('table > tbody')
|
||||
.find('tr')
|
||||
.first()
|
||||
.find('a')
|
||||
@@ -140,16 +142,16 @@ const parseNovelAndChapters = async novelUrl => {
|
||||
const parseChapter = async (novelUrl, chapterUrl) => {
|
||||
const url = `${baseUrl}mtl/${novelUrl}/${chapterUrl}`;
|
||||
|
||||
console.log(url);
|
||||
// console.log(url);
|
||||
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
let chapterName = '';
|
||||
|
||||
let chapterText = $('#content').html();
|
||||
let chapterText = loadedCheerio('#content').html();
|
||||
|
||||
const chapter = {
|
||||
sourceId,
|
||||
@@ -168,17 +170,17 @@ const searchNovels = async searchTerm => {
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novels = [];
|
||||
|
||||
$('.newbox')
|
||||
loadedCheerio('.newbox')
|
||||
.find('li')
|
||||
.each(function () {
|
||||
const novelName = $(this).find('h3').text();
|
||||
const novelCover = $(this).find('img').attr('src');
|
||||
const novelName = loadedCheerio(this).find('h3').text();
|
||||
const novelCover = loadedCheerio(this).find('img').attr('src');
|
||||
|
||||
let novelUrl = $(this).find('a').attr('href');
|
||||
let novelUrl = loadedCheerio(this).find('a').attr('href');
|
||||
novelUrl = novelUrl.replace(baseUrl + 'novel/', '');
|
||||
|
||||
const novel = {
|
||||
|
||||
@@ -13,16 +13,16 @@ const popularNovels = async page => {
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novels = [];
|
||||
|
||||
$('#main')
|
||||
loadedCheerio('#main')
|
||||
.find('li')
|
||||
.each(function () {
|
||||
const novelName = $(this).find('a').text();
|
||||
const novelName = loadedCheerio(this).find('a').text();
|
||||
const novelCover = null;
|
||||
const novelUrl = $(this).find(' a').attr('href');
|
||||
const novelUrl = loadedCheerio(this).find(' a').attr('href');
|
||||
|
||||
const novel = {
|
||||
sourceId,
|
||||
@@ -43,35 +43,37 @@ const parseNovelAndChapters = async novelUrl => {
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novel = {sourceId, sourceName, url, novelUrl};
|
||||
|
||||
novel.novelName = $('h1.entry-title').text().trim();
|
||||
novel.novelName = loadedCheerio('h1.entry-title').text().trim();
|
||||
|
||||
novel.novelCover =
|
||||
$('.entry-content').find('img').attr('src') ||
|
||||
loadedCheerio('.entry-content').find('img').attr('src') ||
|
||||
'https://github.com/LNReader/lnreader-sources/blob/main/src/coverNotAvailable.jpg?raw=true';
|
||||
|
||||
novel.summary = $('#main > article > div > p:nth-child(6)').text().trim();
|
||||
novel.summary = loadedCheerio('#main > article > div > p:nth-child(6)')
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
novel.genre = null;
|
||||
|
||||
novel.status = null;
|
||||
|
||||
novel.author = $('#main > article > div > h3:nth-child(2)')
|
||||
novel.author = loadedCheerio('#main > article > div > h3:nth-child(2)')
|
||||
.text()
|
||||
.replace(/Author:/g, '')
|
||||
.trim();
|
||||
|
||||
let novelChapters = [];
|
||||
|
||||
$('#main')
|
||||
loadedCheerio('#main')
|
||||
.find('li > span > a')
|
||||
.each(function () {
|
||||
const chapterName = $(this).text().trim();
|
||||
const chapterName = loadedCheerio(this).text().trim();
|
||||
const releaseDate = null;
|
||||
const chapterUrl = $(this).attr('href');
|
||||
const chapterUrl = loadedCheerio(this).attr('href');
|
||||
|
||||
novelChapters.push({chapterName, releaseDate, chapterUrl});
|
||||
});
|
||||
@@ -87,14 +89,14 @@ const parseChapter = async (novelUrl, chapterUrl) => {
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
let chapterName = $('.entry-title').text().trim();
|
||||
let chapterName = loadedCheerio('.entry-title').text().trim();
|
||||
|
||||
let chapterText = $('.entry-content').html();
|
||||
let chapterText = loadedCheerio('.entry-content').html();
|
||||
|
||||
if (!chapterText) {
|
||||
chapterText = $('.page-header').html();
|
||||
chapterText = loadedCheerio('.page-header').html();
|
||||
}
|
||||
|
||||
const chapter = {
|
||||
@@ -114,16 +116,16 @@ const searchNovels = async searchTerm => {
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novels = [];
|
||||
|
||||
$('#main')
|
||||
loadedCheerio('#main')
|
||||
.find('li')
|
||||
.each(function () {
|
||||
const novelName = $(this).find('a').text();
|
||||
const novelName = loadedCheerio(this).find('a').text();
|
||||
const novelCover = null;
|
||||
const novelUrl = $(this).find(' a').attr('href');
|
||||
const novelUrl = loadedCheerio(this).find(' a').attr('href');
|
||||
|
||||
const novel = {
|
||||
sourceId,
|
||||
|
||||
+29
-29
@@ -1,7 +1,7 @@
|
||||
import cheerio from 'react-native-cheerio';
|
||||
|
||||
const baseUrl = 'https://fastnovel.net';
|
||||
const searchUrl = `https://fastnovel.net/search/`;
|
||||
const searchUrl = 'https://fastnovel.net/search/';
|
||||
|
||||
const popularNovels = async page => {
|
||||
let totalPages = 39;
|
||||
@@ -10,14 +10,14 @@ const popularNovels = async page => {
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novels = [];
|
||||
|
||||
$('.film-item').each(function (result) {
|
||||
const novelName = $(this).find('.name').text();
|
||||
const novelCover = $(this).find('.img').attr('data-original');
|
||||
const novelUrl = $(this).find('a').attr('href').substring(1);
|
||||
loadedCheerio('.film-item').each(function () {
|
||||
const novelName = loadedCheerio(this).find('.name').text();
|
||||
const novelCover = loadedCheerio(this).find('.img').attr('data-original');
|
||||
const novelUrl = loadedCheerio(this).find('a').attr('href').substring(1);
|
||||
|
||||
const novel = {
|
||||
sourceId: 3,
|
||||
@@ -38,7 +38,7 @@ const parseNovelAndChapters = async novelUrl => {
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novel = {};
|
||||
|
||||
@@ -50,22 +50,22 @@ const parseNovelAndChapters = async novelUrl => {
|
||||
|
||||
novel.novelUrl = novelUrl;
|
||||
|
||||
novel.novelName = $('h1').text();
|
||||
novel.novelName = loadedCheerio('h1').text();
|
||||
|
||||
novel.novelCover = $('.book-cover').attr('data-original');
|
||||
novel.novelCover = loadedCheerio('.book-cover').attr('data-original');
|
||||
|
||||
novel.summary = $('div.film-content > p').text();
|
||||
novel.summary = loadedCheerio('div.film-content > p').text();
|
||||
|
||||
novel.author = $('li > label')
|
||||
novel.author = loadedCheerio('li > label')
|
||||
.filter(function () {
|
||||
return $(this).text().trim() === 'Author:';
|
||||
return loadedCheerio(this).text().trim() === 'Author:';
|
||||
})
|
||||
.next()
|
||||
.text();
|
||||
|
||||
novel.genre = $('li')
|
||||
novel.genre = loadedCheerio('li')
|
||||
.filter(function () {
|
||||
return $(this).find('label').text().trim() === 'Genre:';
|
||||
return loadedCheerio(this).find('label').text().trim() === 'Genre:';
|
||||
})
|
||||
.text()
|
||||
.replace('Genre:', '');
|
||||
@@ -74,9 +74,9 @@ const parseNovelAndChapters = async novelUrl => {
|
||||
|
||||
novel.status = null;
|
||||
|
||||
novel.status = $('li')
|
||||
novel.status = loadedCheerio('li')
|
||||
.filter(function () {
|
||||
return $(this).find('label').text().trim() === 'Status:';
|
||||
return loadedCheerio(this).find('label').text().trim() === 'Status:';
|
||||
})
|
||||
.text()
|
||||
.includes('Completed')
|
||||
@@ -85,19 +85,19 @@ const parseNovelAndChapters = async novelUrl => {
|
||||
|
||||
let novelChapters = [];
|
||||
|
||||
$('.chapter').each(function (result) {
|
||||
const chapterName = $(this).text();
|
||||
loadedCheerio('.chapter').each(function () {
|
||||
const chapterName = loadedCheerio(this).text();
|
||||
const releaseDate = null;
|
||||
let chapterUrl = $(this).attr('href');
|
||||
let chapterUrl = loadedCheerio(this).attr('href');
|
||||
chapterUrl = chapterUrl.replace(`/${novelUrl}/`, '');
|
||||
|
||||
const novel = {
|
||||
const chapter = {
|
||||
chapterName,
|
||||
releaseDate,
|
||||
chapterUrl,
|
||||
};
|
||||
|
||||
novelChapters.push(novel);
|
||||
novelChapters.push(chapter);
|
||||
});
|
||||
|
||||
novel.chapters = novelChapters;
|
||||
@@ -111,11 +111,11 @@ const parseChapter = async (novelUrl, chapterUrl) => {
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
const chapterName = $('.episode-name').text();
|
||||
const chapterName = loadedCheerio('.episode-name').text();
|
||||
|
||||
let chapterText = $('#chapter-body').html();
|
||||
let chapterText = loadedCheerio('#chapter-body').html();
|
||||
const chapter = {
|
||||
sourceId: 3,
|
||||
novelUrl,
|
||||
@@ -133,14 +133,14 @@ const searchNovels = async searchTerm => {
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novels = [];
|
||||
|
||||
$('.film-item').each(function (result) {
|
||||
const novelName = $(this).find('div.title > p.name').text();
|
||||
const novelCover = $(this).find('.img').attr('data-original');
|
||||
const novelUrl = $(this).find('a').attr('href').substring(1);
|
||||
loadedCheerio('.film-item').each(function () {
|
||||
const novelName = loadedCheerio(this).find('div.title > p.name').text();
|
||||
const novelCover = loadedCheerio(this).find('.img').attr('data-original');
|
||||
const novelUrl = loadedCheerio(this).find('a').attr('href').substring(1);
|
||||
|
||||
const novel = {
|
||||
sourceId: 3,
|
||||
|
||||
+34
-26
@@ -9,15 +9,18 @@ const popularNovels = async page => {
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novels = [];
|
||||
|
||||
$('.page-item-detail').each(function (result) {
|
||||
const novelName = $(this).find('.h5 > a').text();
|
||||
const novelCover = $(this).find('img').attr('data-src');
|
||||
loadedCheerio('.page-item-detail').each(function () {
|
||||
const novelName = loadedCheerio(this).find('.h5 > a').text();
|
||||
const novelCover = loadedCheerio(this).find('img').attr('data-src');
|
||||
|
||||
let novelUrl = $(this).find('.h5 > a').attr('href').split('/')[4];
|
||||
let novelUrl = loadedCheerio(this)
|
||||
.find('.h5 > a')
|
||||
.attr('href')
|
||||
.split('/')[4];
|
||||
novelUrl += '/';
|
||||
|
||||
const novel = {
|
||||
@@ -39,7 +42,7 @@ const parseNovelAndChapters = async novelUrl => {
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
let loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novel = {};
|
||||
|
||||
@@ -51,20 +54,20 @@ const parseNovelAndChapters = async novelUrl => {
|
||||
|
||||
novel.novelUrl = novelUrl;
|
||||
|
||||
novel.novelName = $('.post-title > h1')
|
||||
novel.novelName = loadedCheerio('.post-title > h1')
|
||||
.text()
|
||||
.replace(/[\t\n]/g, '')
|
||||
.trim();
|
||||
|
||||
novel.novelCover = $('.summary_image > a > img').attr('data-src');
|
||||
novel.novelCover = loadedCheerio('.summary_image > a > img').attr('data-src');
|
||||
|
||||
$('.post-content_item').each(function (result) {
|
||||
detailName = $(this)
|
||||
loadedCheerio('.post-content_item').each(function () {
|
||||
const detailName = loadedCheerio(this)
|
||||
.find('.summary-heading > h5')
|
||||
.text()
|
||||
.replace(/[\t\n]/g, '')
|
||||
.trim();
|
||||
detail = $(this)
|
||||
const detail = loadedCheerio(this)
|
||||
.find('.summary-content')
|
||||
.text()
|
||||
.replace(/[\t\n]/g, '')
|
||||
@@ -83,9 +86,11 @@ const parseNovelAndChapters = async novelUrl => {
|
||||
}
|
||||
});
|
||||
|
||||
$('.description-summary > div.summary__content').find('em').remove();
|
||||
loadedCheerio('.description-summary > div.summary__content')
|
||||
.find('em')
|
||||
.remove();
|
||||
|
||||
novel.summary = $('.description-summary > div.summary__content')
|
||||
novel.summary = loadedCheerio('.description-summary > div.summary__content')
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
@@ -102,18 +107,18 @@ const parseNovelAndChapters = async novelUrl => {
|
||||
});
|
||||
const text = await data.text();
|
||||
|
||||
$ = cheerio.load(text);
|
||||
loadedCheerio = cheerio.load(text);
|
||||
|
||||
$('.wp-manga-chapter').each(function (result) {
|
||||
chapterName = $(this)
|
||||
loadedCheerio('.wp-manga-chapter').each(function () {
|
||||
const chapterName = loadedCheerio(this)
|
||||
.find('a')
|
||||
.text()
|
||||
.replace(/[\t\n]/g, '')
|
||||
.trim();
|
||||
|
||||
releaseDate = $(this).find('span').text().trim();
|
||||
const releaseDate = loadedCheerio(this).find('span').text().trim();
|
||||
|
||||
chapterUrl = $(this).find('a').attr('href').split('/');
|
||||
let chapterUrl = loadedCheerio(this).find('a').attr('href').split('/');
|
||||
|
||||
chapterUrl[6]
|
||||
? (chapterUrl = chapterUrl[5] + '/' + chapterUrl[6])
|
||||
@@ -133,10 +138,10 @@ const parseChapter = async (novelUrl, chapterUrl) => {
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
const chapterName = $('h1#chapter-heading').text();
|
||||
let chapterText = $('.reading-content').html();
|
||||
const chapterName = loadedCheerio('h1#chapter-heading').text();
|
||||
let chapterText = loadedCheerio('.reading-content').html();
|
||||
const chapter = {
|
||||
sourceId: 22,
|
||||
novelUrl,
|
||||
@@ -154,15 +159,18 @@ const searchNovels = async searchTerm => {
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novels = [];
|
||||
|
||||
$('.c-tabs-item__content').each(function (result) {
|
||||
const novelName = $(this).find('.h4 > a').text();
|
||||
const novelCover = $(this).find('img').attr('data-src');
|
||||
loadedCheerio('.c-tabs-item__content').each(function () {
|
||||
const novelName = loadedCheerio(this).find('.h4 > a').text();
|
||||
const novelCover = loadedCheerio(this).find('img').attr('data-src');
|
||||
|
||||
let novelUrl = $(this).find('.h4 > a').attr('href').split('/')[4];
|
||||
let novelUrl = loadedCheerio(this)
|
||||
.find('.h4 > a')
|
||||
.attr('href')
|
||||
.split('/')[4];
|
||||
novelUrl += '/';
|
||||
const novel = {
|
||||
sourceId: 22,
|
||||
|
||||
@@ -9,15 +9,15 @@ const popularNovels = async page => {
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novels = [];
|
||||
|
||||
$('.li-row').each(function (result) {
|
||||
const novelName = $(this).find('.tit').text();
|
||||
const novelCover = $(this).find('img').attr('src');
|
||||
loadedCheerio('.li-row').each(function () {
|
||||
const novelName = loadedCheerio(this).find('.tit').text();
|
||||
const novelCover = loadedCheerio(this).find('img').attr('src');
|
||||
|
||||
let novelUrl = $(this)
|
||||
let novelUrl = loadedCheerio(this)
|
||||
.find('h3 > a')
|
||||
.attr('href')
|
||||
.replace('.html', '')
|
||||
@@ -42,7 +42,7 @@ const parseNovelAndChapters = async novelUrl => {
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novel = {};
|
||||
|
||||
@@ -54,43 +54,47 @@ const parseNovelAndChapters = async novelUrl => {
|
||||
|
||||
novel.novelUrl = novelUrl;
|
||||
|
||||
novel.novelName = $('h1.tit').text();
|
||||
novel.novelName = loadedCheerio('h1.tit').text();
|
||||
|
||||
novel.novelCover = $('.pic > img').attr('src');
|
||||
novel.novelCover = loadedCheerio('.pic > img').attr('src');
|
||||
|
||||
novel.genre = $('[title=Genre]')
|
||||
novel.genre = loadedCheerio('[title=Genre]')
|
||||
.next()
|
||||
.text()
|
||||
.replace(/[\t\n]/g, '');
|
||||
|
||||
novel.author = $('[title=Author]')
|
||||
novel.author = loadedCheerio('[title=Author]')
|
||||
.next()
|
||||
.text()
|
||||
.replace(/[\t\n]/g, '');
|
||||
|
||||
novel.artist = null;
|
||||
|
||||
novel.status = $('[title=Status]')
|
||||
novel.status = loadedCheerio('[title=Status]')
|
||||
.next()
|
||||
.text()
|
||||
.replace(/[\t\n]/g, '');
|
||||
|
||||
let novelSummary = $('.inner').text().trim();
|
||||
let novelSummary = loadedCheerio('.inner').text().trim();
|
||||
novel.summary = novelSummary;
|
||||
|
||||
let novelChapters = [];
|
||||
|
||||
let latestChapter;
|
||||
|
||||
$('h3.tit').each(function (res) {
|
||||
if ($(this).find('a').text() === novel.novelName) {
|
||||
latestChapter = $(this).next().find('span.s3').text().match(/\d+/);
|
||||
loadedCheerio('h3.tit').each(function (res) {
|
||||
if (loadedCheerio(this).find('a').text() === novel.novelName) {
|
||||
latestChapter = loadedCheerio(this)
|
||||
.next()
|
||||
.find('span.s3')
|
||||
.text()
|
||||
.match(/\d+/);
|
||||
}
|
||||
});
|
||||
|
||||
latestChapter = latestChapter[0];
|
||||
|
||||
for (let i = 1; i <= parseInt(latestChapter); i++) {
|
||||
for (let i = 1; i <= parseInt(latestChapter, 10); i++) {
|
||||
const chapterName = 'Chapter ' + i;
|
||||
|
||||
const releaseDate = null;
|
||||
@@ -115,11 +119,11 @@ const parseChapter = async (novelUrl, chapterUrl) => {
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
let chapterName = $('h1.tit').text();
|
||||
let chapterName = loadedCheerio('h1.tit').text();
|
||||
|
||||
let chapterText = $('div.txt').html();
|
||||
let chapterText = loadedCheerio('div.txt').html();
|
||||
|
||||
const chapter = {
|
||||
sourceId: 13,
|
||||
@@ -144,15 +148,17 @@ const searchNovels = async searchTerm => {
|
||||
});
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novels = [];
|
||||
|
||||
$('.li-row > .li > .con').each(function (result) {
|
||||
const novelName = $(this).find('.tit').text();
|
||||
const novelCover = $(this).find('.pic > a > img').attr('data-cfsrc');
|
||||
loadedCheerio('.li-row > .li > .con').each(function () {
|
||||
const novelName = loadedCheerio(this).find('.tit').text();
|
||||
const novelCover = loadedCheerio(this)
|
||||
.find('.pic > a > img')
|
||||
.attr('data-cfsrc');
|
||||
|
||||
let novelUrl = $(this)
|
||||
let novelUrl = loadedCheerio(this)
|
||||
.find('h3 > a')
|
||||
.attr('href')
|
||||
.replace('.html', '')
|
||||
|
||||
+13
-13
@@ -33,7 +33,7 @@ const parseNovelAndChapters = async novelUrl => {
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novel = {};
|
||||
|
||||
@@ -45,17 +45,17 @@ const parseNovelAndChapters = async novelUrl => {
|
||||
|
||||
novel.novelUrl = novelUrl;
|
||||
|
||||
novel.novelName = $('h1.book-sidebar__title').text();
|
||||
novel.novelName = loadedCheerio('h1.book-sidebar__title').text();
|
||||
|
||||
novel.novelCover = $('.book-sidebar').find('img').attr('src');
|
||||
novel.novelCover = loadedCheerio('.book-sidebar').find('img').attr('src');
|
||||
|
||||
$('.post-content_item').each(function (result) {
|
||||
detailName = $(this)
|
||||
loadedCheerio('.post-content_item').each(function () {
|
||||
const detailName = loadedCheerio(this)
|
||||
.find('.summary-heading > h5')
|
||||
.text()
|
||||
.replace(/[\t\n]/g, '')
|
||||
.trim();
|
||||
detail = $(this)
|
||||
const detail = loadedCheerio(this)
|
||||
.find('.summary-content')
|
||||
.text()
|
||||
.replace(/[\t\n]/g, '')
|
||||
@@ -64,19 +64,19 @@ const parseNovelAndChapters = async novelUrl => {
|
||||
novel[detailName] = detail;
|
||||
});
|
||||
|
||||
novel.summary = $('.main-book__synopsis').text();
|
||||
novel.summary = loadedCheerio('.main-book__synopsis').text();
|
||||
|
||||
novel.genre = '';
|
||||
|
||||
$('a.main-book__category').each(function (result) {
|
||||
novel.genre += $(this).text();
|
||||
loadedCheerio('a.main-book__category').each(function () {
|
||||
novel.genre += loadedCheerio(this).text();
|
||||
});
|
||||
|
||||
function capitalizeFirstLetter(string) {
|
||||
return string.charAt(0).toUpperCase() + string.slice(1);
|
||||
}
|
||||
|
||||
const info = $('.book-sidebar__author > .book-sidebar__info')
|
||||
const info = loadedCheerio('.book-sidebar__author > .book-sidebar__info')
|
||||
.text()
|
||||
.trim()
|
||||
.split('・');
|
||||
@@ -122,10 +122,10 @@ const parseChapter = async (novelUrl, chapterUrl) => {
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
const chapterName = $('.chapter-content__title').text();
|
||||
let chapterText = $('.chapter-content__content').html();
|
||||
const chapterName = loadedCheerio('.chapter-content__title').text();
|
||||
let chapterText = loadedCheerio('.chapter-content__content').html();
|
||||
novelUrl += '/';
|
||||
|
||||
const chapter = {
|
||||
|
||||
@@ -9,15 +9,15 @@ const popularNovels = async page => {
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novels = [];
|
||||
|
||||
$('.page-item-detail').each(function (result) {
|
||||
const novelName = $(this).find('h5 > a').text();
|
||||
const novelCover = $(this).find('img').attr('src');
|
||||
loadedCheerio('.page-item-detail').each(function () {
|
||||
const novelName = loadedCheerio(this).find('h5 > a').text();
|
||||
const novelCover = loadedCheerio(this).find('img').attr('src');
|
||||
|
||||
let novelUrl = $(this).find('h5 > a').attr('href');
|
||||
let novelUrl = loadedCheerio(this).find('h5 > a').attr('href');
|
||||
novelUrl = novelUrl.replace(`${baseUrl}novel/`, '');
|
||||
|
||||
const novel = {
|
||||
@@ -39,7 +39,7 @@ const parseNovelAndChapters = async novelUrl => {
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novel = {};
|
||||
|
||||
@@ -51,20 +51,20 @@ const parseNovelAndChapters = async novelUrl => {
|
||||
|
||||
novel.novelUrl = novelUrl;
|
||||
|
||||
novel.novelName = $('.post-title > h1')
|
||||
novel.novelName = loadedCheerio('.post-title > h1')
|
||||
.text()
|
||||
.replace(/[\t\n]/g, '')
|
||||
.trim();
|
||||
|
||||
novel.novelCover = $('.summary_image > a > img').attr('src');
|
||||
novel.novelCover = loadedCheerio('.summary_image > a > img').attr('src');
|
||||
|
||||
$('.post-content_item').each(function (result) {
|
||||
detailName = $(this)
|
||||
loadedCheerio('.post-content_item').each(function () {
|
||||
const detailName = loadedCheerio(this)
|
||||
.find('.summary-heading > h5')
|
||||
.text()
|
||||
.replace(/[\t\n]/g, '')
|
||||
.trim();
|
||||
detail = $(this)
|
||||
const detail = loadedCheerio(this)
|
||||
.find('.summary-content')
|
||||
.text()
|
||||
.replace(/[\t\n]/g, '')
|
||||
@@ -83,28 +83,33 @@ const parseNovelAndChapters = async novelUrl => {
|
||||
}
|
||||
});
|
||||
|
||||
$('.description-summary > div.summary__content').find('em').remove();
|
||||
loadedCheerio('.description-summary > div.summary__content')
|
||||
.find('em')
|
||||
.remove();
|
||||
|
||||
novel.summary = $('.description-summary > div.summary__content')
|
||||
novel.summary = loadedCheerio('.description-summary > div.summary__content')
|
||||
.text()
|
||||
.replace(/[\t\n]/g, '');
|
||||
|
||||
let novelChapters = [];
|
||||
|
||||
$('.wp-manga-chapter').each(function (result) {
|
||||
chapterName = $(this)
|
||||
loadedCheerio('.wp-manga-chapter').each(function () {
|
||||
const chapterName = loadedCheerio(this)
|
||||
.find('a')
|
||||
.text()
|
||||
.replace(/[\t\n]/g, '')
|
||||
.trim();
|
||||
|
||||
releaseDate = $(this)
|
||||
const releaseDate = loadedCheerio(this)
|
||||
.find('span')
|
||||
.text()
|
||||
.replace(/[\t\n]/g, '')
|
||||
.trim();
|
||||
|
||||
chapterUrl = $(this).find('a').attr('href').replace(url, '');
|
||||
const chapterUrl = loadedCheerio(this)
|
||||
.find('a')
|
||||
.attr('href')
|
||||
.replace(url, '');
|
||||
|
||||
novelChapters.push({chapterName, releaseDate, chapterUrl});
|
||||
});
|
||||
@@ -120,13 +125,13 @@ const parseChapter = async (novelUrl, chapterUrl) => {
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
$('#snippet-box').remove();
|
||||
loadedCheerio('#snippet-box').remove();
|
||||
|
||||
const chapterName = $('div.text-left > h4').text();
|
||||
const chapterName = loadedCheerio('div.text-left > h4').text();
|
||||
|
||||
let chapterText = $('.reading-content').html();
|
||||
let chapterText = loadedCheerio('.reading-content').html();
|
||||
const chapter = {
|
||||
sourceId: 11,
|
||||
novelUrl,
|
||||
@@ -144,15 +149,15 @@ const searchNovels = async searchTerm => {
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novels = [];
|
||||
|
||||
$('.c-tabs-item__content').each(function (result) {
|
||||
const novelName = $(this).find('h4 > a').text();
|
||||
const novelCover = $(this).find('img').attr('src');
|
||||
loadedCheerio('.c-tabs-item__content').each(function () {
|
||||
const novelName = loadedCheerio(this).find('h4 > a').text();
|
||||
const novelCover = loadedCheerio(this).find('img').attr('src');
|
||||
|
||||
let novelUrl = $(this).find('h4 > a').attr('href');
|
||||
let novelUrl = loadedCheerio(this).find('h4 > a').attr('href');
|
||||
novelUrl = novelUrl.replace(`${baseUrl}novel/`, '');
|
||||
|
||||
const novel = {
|
||||
|
||||
@@ -19,24 +19,24 @@ const popularNovels = async page => {
|
||||
});
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novels = [];
|
||||
|
||||
$('.novel-item.ads').remove();
|
||||
loadedCheerio('.novel-item.ads').remove();
|
||||
|
||||
$('.novel-item').each(function () {
|
||||
const novelName = $(this)
|
||||
loadedCheerio('.novel-item').each(function () {
|
||||
const novelName = loadedCheerio(this)
|
||||
.find('.novel-title')
|
||||
.text()
|
||||
.replace(/[\t\n]/g, '');
|
||||
|
||||
const novelCover = $(this).find('img').attr('data-src');
|
||||
const novelCover = loadedCheerio(this).find('img').attr('data-src');
|
||||
|
||||
let novelUrl = $(this)
|
||||
let novelUrl = loadedCheerio(this)
|
||||
.find('.novel-title > a')
|
||||
.attr('href')
|
||||
.replace(`/novel/`, '');
|
||||
.replace('/novel/', '');
|
||||
novelUrl += '/';
|
||||
|
||||
const novel = {
|
||||
@@ -68,7 +68,7 @@ const parseNovelAndChapters = async novelUrl => {
|
||||
});
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novel = {};
|
||||
|
||||
@@ -80,39 +80,42 @@ const parseNovelAndChapters = async novelUrl => {
|
||||
|
||||
novel.novelUrl = novelUrl;
|
||||
|
||||
novel.novelName = $('h1.novel-title')
|
||||
novel.novelName = loadedCheerio('h1.novel-title')
|
||||
.text()
|
||||
.replace(/[\t\n]/g, '')
|
||||
.trim();
|
||||
|
||||
novel.novelCover = $('figure.cover > img').attr('data-src');
|
||||
novel.novelCover = loadedCheerio('figure.cover > img').attr('data-src');
|
||||
|
||||
novel.genre = '';
|
||||
|
||||
$('div.categories > ul > li').each(function () {
|
||||
loadedCheerio('div.categories > ul > li').each(function () {
|
||||
novel.genre +=
|
||||
$(this)
|
||||
loadedCheerio(this)
|
||||
.text()
|
||||
.replace(/[\t\n]/g, '') + ',';
|
||||
});
|
||||
|
||||
$('div.header-stats > span').each(function () {
|
||||
if ($(this).find('small').text() === 'Status') {
|
||||
novel.status = $(this).find('strong').text();
|
||||
loadedCheerio('div.header-stats > span').each(function () {
|
||||
if (loadedCheerio(this).find('small').text() === 'Status') {
|
||||
novel.status = loadedCheerio(this).find('strong').text();
|
||||
}
|
||||
});
|
||||
|
||||
novel.genre = novel.genre.slice(0, -1);
|
||||
|
||||
novel.author = $('.author > a > span').text();
|
||||
novel.author = loadedCheerio('.author > a > span').text();
|
||||
|
||||
novel.summary = $('.summary > .content').text().trim();
|
||||
novel.summary = loadedCheerio('.summary > .content').text().trim();
|
||||
|
||||
let novelChapters = [];
|
||||
|
||||
let totalChapters;
|
||||
|
||||
totalChapters = $('.header-stats > span').first().text().match(/\d+/)[0];
|
||||
totalChapters = loadedCheerio('.header-stats > span')
|
||||
.first()
|
||||
.text()
|
||||
.match(/\d+/)[0];
|
||||
|
||||
for (let i = 1; i <= totalChapters; i++) {
|
||||
const chapterName = 'Chapter ' + i;
|
||||
@@ -146,10 +149,10 @@ const parseChapter = async (novelUrl, chapterUrl) => {
|
||||
headers: headers,
|
||||
});
|
||||
const body = await result.text();
|
||||
$ = cheerio.load(body);
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
const chapterName = $('h2').text();
|
||||
let chapterText = $('#chapter-container').html();
|
||||
const chapterName = loadedCheerio('h2').text();
|
||||
let chapterText = loadedCheerio('#chapter-container').html();
|
||||
const chapter = {
|
||||
sourceId: 15,
|
||||
novelUrl,
|
||||
@@ -177,19 +180,22 @@ const searchNovels = async searchTerm => {
|
||||
});
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
let loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novels = [];
|
||||
|
||||
let results = JSON.parse($('body').text());
|
||||
let results = JSON.parse(loadedCheerio('body').text());
|
||||
|
||||
$ = cheerio.load(results.resultview);
|
||||
loadedCheerio = cheerio.load(results.resultview);
|
||||
|
||||
$('.novel-item').each(function () {
|
||||
const novelName = $(this).find('h4.novel-title').text();
|
||||
const novelCover = $(this).find('img').attr('src');
|
||||
loadedCheerio('.novel-item').each(function () {
|
||||
const novelName = loadedCheerio(this).find('h4.novel-title').text();
|
||||
const novelCover = loadedCheerio(this).find('img').attr('src');
|
||||
|
||||
let novelUrl = $(this).find('a').attr('href').replace(`/novel/`, '');
|
||||
let novelUrl = loadedCheerio(this)
|
||||
.find('a')
|
||||
.attr('href')
|
||||
.replace('/novel/', '');
|
||||
novelUrl += '/';
|
||||
|
||||
const novel = {
|
||||
|
||||
@@ -12,14 +12,14 @@ const popularNovels = async page => {
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novels = [];
|
||||
|
||||
$('.page-item-detail').each(function () {
|
||||
const novelName = $(this).find('.h5 > a').text();
|
||||
const novelCover = $(this).find('img').attr('src');
|
||||
const novelUrl = $(this).find('.h5 > a').attr('href');
|
||||
loadedCheerio('.page-item-detail').each(function () {
|
||||
const novelName = loadedCheerio(this).find('.h5 > a').text();
|
||||
const novelCover = loadedCheerio(this).find('img').attr('src');
|
||||
const novelUrl = loadedCheerio(this).find('.h5 > a').attr('href');
|
||||
|
||||
const novel = {
|
||||
sourceId,
|
||||
@@ -37,23 +37,26 @@ const popularNovels = async page => {
|
||||
const parseNovelAndChapters = async novelUrl => {
|
||||
const url = novelUrl;
|
||||
|
||||
console.log(url);
|
||||
// console.log(url);
|
||||
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
let loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novel = {sourceId, sourceName, novelUrl, url};
|
||||
|
||||
novel.novelName = $('.post-title > h1').text().trim();
|
||||
novel.novelName = loadedCheerio('.post-title > h1').text().trim();
|
||||
novel.novelCover =
|
||||
$('.summary_image > a > img').attr('src') ||
|
||||
loadedCheerio('.summary_image > a > img').attr('src') ||
|
||||
'https://github.com/LNReader/lnreader-sources/blob/main/src/coverNotAvailable.jpg?raw=true';
|
||||
|
||||
$('.post-content_item').each(function (result) {
|
||||
detailName = $(this).find('.summary-heading > h5').text().trim();
|
||||
detail = $(this).find('.summary-content').text().trim();
|
||||
loadedCheerio('.post-content_item').each(function () {
|
||||
const detailName = loadedCheerio(this)
|
||||
.find('.summary-heading > h5')
|
||||
.text()
|
||||
.trim();
|
||||
const detail = loadedCheerio(this).find('.summary-content').text().trim();
|
||||
|
||||
switch (detailName) {
|
||||
case 'Genre(s)':
|
||||
@@ -68,11 +71,11 @@ const parseNovelAndChapters = async novelUrl => {
|
||||
}
|
||||
});
|
||||
|
||||
novel.summary = $('div.summary__content').text();
|
||||
novel.summary = loadedCheerio('div.summary__content').text();
|
||||
|
||||
let novelChapters = [];
|
||||
|
||||
const novelId = $('.rating-post-id').attr('value');
|
||||
const novelId = loadedCheerio('.rating-post-id').attr('value');
|
||||
|
||||
let formData = new FormData();
|
||||
formData.append('action', 'manga_get_chapters');
|
||||
@@ -87,12 +90,12 @@ const parseNovelAndChapters = async novelUrl => {
|
||||
);
|
||||
const text = await data.text();
|
||||
|
||||
$ = cheerio.load(text);
|
||||
loadedCheerio = cheerio.load(text);
|
||||
|
||||
$('.wp-manga-chapter').each(function () {
|
||||
const chapterName = $(this).find('a').text().trim();
|
||||
const releaseDate = $(this).find('span').text().trim();
|
||||
const chapterUrl = $(this).find('a').attr('href');
|
||||
loadedCheerio('.wp-manga-chapter').each(function () {
|
||||
const chapterName = loadedCheerio(this).find('a').text().trim();
|
||||
const releaseDate = loadedCheerio(this).find('span').text().trim();
|
||||
const chapterUrl = loadedCheerio(this).find('a').attr('href');
|
||||
|
||||
const chapter = {chapterName, releaseDate, chapterUrl};
|
||||
|
||||
@@ -127,14 +130,14 @@ const searchNovels = async searchTerm => {
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novels = [];
|
||||
|
||||
$('.c-tabs-item__content').each(function (result) {
|
||||
const novelName = $(this).find('.h4 > a').text();
|
||||
const novelCover = $(this).find('img').attr('src');
|
||||
const novelUrl = $(this).find('.h4 > a').attr('href');
|
||||
loadedCheerio('.c-tabs-item__content').each(function () {
|
||||
const novelName = loadedCheerio(this).find('.h4 > a').text();
|
||||
const novelCover = loadedCheerio(this).find('img').attr('src');
|
||||
const novelUrl = loadedCheerio(this).find('.h4 > a').attr('href');
|
||||
|
||||
const novel = {
|
||||
sourceId,
|
||||
|
||||
+20
-20
@@ -11,15 +11,15 @@ const popularNovels = async page => {
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novels = [];
|
||||
|
||||
$('.media').each(function (result) {
|
||||
const novelName = $(this).find('h4').text();
|
||||
const novelCover = $(this).find('img').attr('src');
|
||||
loadedCheerio('.media').each(function () {
|
||||
const novelName = loadedCheerio(this).find('h4').text();
|
||||
const novelCover = loadedCheerio(this).find('img').attr('src');
|
||||
|
||||
let novelUrl = $(this).find('h4 > a').attr('href');
|
||||
let novelUrl = loadedCheerio(this).find('h4 > a').attr('href');
|
||||
novelUrl = novelUrl.replace(baseUrl + 'novel/', '');
|
||||
|
||||
const novel = {
|
||||
@@ -43,7 +43,7 @@ const parseNovelAndChapters = async novelUrl => {
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novel = {};
|
||||
|
||||
@@ -55,23 +55,23 @@ const parseNovelAndChapters = async novelUrl => {
|
||||
|
||||
novel.novelUrl = novelUrl;
|
||||
|
||||
novel.novelName = $('.novel-name').text();
|
||||
novel.novelName = loadedCheerio('.novel-name').text();
|
||||
|
||||
novel.novelCover = $('div.novel').find('img').attr('src');
|
||||
novel.novelCover = loadedCheerio('div.novel').find('img').attr('src');
|
||||
|
||||
novel.summary = $('div.description').text().trim();
|
||||
novel.summary = loadedCheerio('div.description').text().trim();
|
||||
|
||||
novel.author = $(
|
||||
novel.author = loadedCheerio(
|
||||
'main > div:nth-child(3) > div > div.col-lg-3.col-md-4 > div:nth-child(2) > div.panel-body > dl:nth-child(1) > dd > span',
|
||||
).text();
|
||||
|
||||
novel.status = $(
|
||||
novel.status = loadedCheerio(
|
||||
'main > div:nth-child(3) > div > div.col-lg-3.col-md-4 > div:nth-child(2) > div.panel-body > dl:nth-child(2) > dd',
|
||||
)
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
novel.genre = $(
|
||||
novel.genre = loadedCheerio(
|
||||
'main > div.container > div > div.col-lg-3.col-md-4 > div:nth-child(4) > div.panel-body > ul',
|
||||
)
|
||||
.text()
|
||||
@@ -79,7 +79,7 @@ const parseNovelAndChapters = async novelUrl => {
|
||||
.replace(/\s\s/g, ',');
|
||||
|
||||
let volumes = JSON.parse(
|
||||
$('main')
|
||||
loadedCheerio('main')
|
||||
.next()
|
||||
.html()
|
||||
.match(/lnmtl.volumes = \[(.*?)\]/)[0]
|
||||
@@ -125,16 +125,16 @@ const parseChapter = async (novelUrl, chapterUrl) => {
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
let chapterName = $('h3 > span.chapter-title').text().trim();
|
||||
let chapterName = loadedCheerio('h3 > span.chapter-title').text().trim();
|
||||
|
||||
$('.original').remove();
|
||||
loadedCheerio('.original').remove();
|
||||
|
||||
let chapterText = $('.chapter-body').html();
|
||||
let chapterText = loadedCheerio('.chapter-body').html();
|
||||
|
||||
if (!chapterText) {
|
||||
chapterText = $('.alert.alert-warning').text();
|
||||
chapterText = loadedCheerio('.alert.alert-warning').text();
|
||||
}
|
||||
|
||||
chapterText =
|
||||
@@ -157,9 +157,9 @@ const searchNovels = async searchTerm => {
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novels = $('footer')
|
||||
let novels = loadedCheerio('footer')
|
||||
.next()
|
||||
.next()
|
||||
.html()
|
||||
|
||||
+27
-27
@@ -6,7 +6,7 @@ const popularNovels = async page => {
|
||||
let totalPages = 10;
|
||||
const url = `${baseUrl}/alltime-rank/page/${page}`;
|
||||
|
||||
console.log(url);
|
||||
// console.log(url);
|
||||
|
||||
let headers = new Headers({
|
||||
referer: 'https://www.mtlnovel.com/',
|
||||
@@ -20,15 +20,15 @@ const popularNovels = async page => {
|
||||
});
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novels = [];
|
||||
|
||||
$('div.box.wide').each(function (result) {
|
||||
const novelName = $(this).find('a.list-title').text().slice(4);
|
||||
const novelCover = $(this).find('amp-img').attr('src');
|
||||
loadedCheerio('div.box.wide').each(function () {
|
||||
const novelName = loadedCheerio(this).find('a.list-title').text().slice(4);
|
||||
const novelCover = loadedCheerio(this).find('amp-img').attr('src');
|
||||
|
||||
let novelUrl = $(this).find('a.list-title').attr('href');
|
||||
let novelUrl = loadedCheerio(this).find('a.list-title').attr('href');
|
||||
novelUrl = novelUrl.replace('https://www.mtlnovel.com/', '');
|
||||
|
||||
const novel = {
|
||||
@@ -59,7 +59,7 @@ const parseNovelAndChapters = async novelUrl => {
|
||||
});
|
||||
const body = await result.text();
|
||||
|
||||
const $ = cheerio.load(body);
|
||||
let loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novel = {};
|
||||
|
||||
@@ -71,31 +71,31 @@ const parseNovelAndChapters = async novelUrl => {
|
||||
|
||||
novel.novelUrl = novelUrl;
|
||||
|
||||
novel.novelName = $('h1.entry-title').text();
|
||||
novel.novelName = loadedCheerio('h1.entry-title').text();
|
||||
|
||||
novel.novelCover = $('.nov-head > amp-img').attr('src');
|
||||
novel.novelCover = loadedCheerio('.nov-head > amp-img').attr('src');
|
||||
|
||||
novel.summary = $('div.desc > h2').next().text().trim();
|
||||
novel.summary = loadedCheerio('div.desc > h2').next().text().trim();
|
||||
|
||||
novel.author = $('tr > td')
|
||||
novel.author = loadedCheerio('tr > td')
|
||||
.filter(function () {
|
||||
return $(this).prev().text().trim() === 'Author';
|
||||
return loadedCheerio(this).prev().text().trim() === 'Author';
|
||||
})
|
||||
.next()
|
||||
.text()
|
||||
.replace('Auhtor:', '');
|
||||
|
||||
novel.status = $('tr > td')
|
||||
novel.status = loadedCheerio('tr > td')
|
||||
.filter(function () {
|
||||
return $(this).prev().text().trim() === 'Status';
|
||||
return loadedCheerio(this).prev().text().trim() === 'Status';
|
||||
})
|
||||
.next()
|
||||
.text()
|
||||
.replace('Status:', '');
|
||||
|
||||
novel.genre = $('td')
|
||||
novel.genre = loadedCheerio('td')
|
||||
.filter(function () {
|
||||
return $(this).prev().text().trim() === 'Genre';
|
||||
return loadedCheerio(this).prev().text().trim() === 'Genre';
|
||||
})
|
||||
.next()
|
||||
.text()
|
||||
@@ -106,20 +106,20 @@ const parseNovelAndChapters = async novelUrl => {
|
||||
const chapterListUrl = url + '/chapter-list/';
|
||||
|
||||
const getChapters = async () => {
|
||||
const result = await fetch(chapterListUrl);
|
||||
const body = await result.text();
|
||||
const listResult = await fetch(chapterListUrl);
|
||||
const listBody = await listResult.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
loadedCheerio = cheerio.load(listBody);
|
||||
|
||||
let novelChapters = [];
|
||||
|
||||
$('div.ch-list')
|
||||
loadedCheerio('div.ch-list')
|
||||
.find('a.ch-link')
|
||||
.each(function (result) {
|
||||
const chapterName = $(this).text().replace('~ ', '');
|
||||
.each(function () {
|
||||
const chapterName = loadedCheerio(this).text().replace('~ ', '');
|
||||
const releaseDate = null;
|
||||
|
||||
let chapterUrl = $(this).attr('href');
|
||||
let chapterUrl = loadedCheerio(this).attr('href');
|
||||
chapterUrl = chapterUrl.replace(
|
||||
`https://www.mtlnovel.com/${novelUrl}`,
|
||||
'',
|
||||
@@ -141,15 +141,15 @@ const parseNovelAndChapters = async novelUrl => {
|
||||
|
||||
const parseChapter = async (novelUrl, chapterUrl) => {
|
||||
const url = `${baseUrl}/${novelUrl}${chapterUrl}`;
|
||||
console.log(url);
|
||||
// console.log(url);
|
||||
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
const chapterName = $('h1.main-title').text();
|
||||
let chapterText = $('div.par').html();
|
||||
const chapterName = loadedCheerio('h1.main-title').text();
|
||||
let chapterText = loadedCheerio('div.par').html();
|
||||
const chapter = {
|
||||
sourceId: 5,
|
||||
novelUrl,
|
||||
|
||||
+62
-58
@@ -9,32 +9,34 @@ const popularNovels = async page => {
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novels = [];
|
||||
|
||||
$('div.col-truyen-main > div.list-truyen > .row').each(function (result) {
|
||||
const novelName = $(this).find('h3.truyen-title > a').text();
|
||||
loadedCheerio('div.col-truyen-main > div.list-truyen > .row').each(
|
||||
function () {
|
||||
const novelName = loadedCheerio(this).find('h3.truyen-title > a').text();
|
||||
|
||||
let novelCover = $(this).find('img').attr('src');
|
||||
novelCover = baseUrl + novelCover;
|
||||
let novelCover = loadedCheerio(this).find('img').attr('src');
|
||||
novelCover = baseUrl + novelCover;
|
||||
|
||||
let novelUrl = $(this)
|
||||
.find('h3.truyen-title > a')
|
||||
.attr('href')
|
||||
.replace('.html', '')
|
||||
.substring(1);
|
||||
novelUrl = `${novelUrl}/`;
|
||||
let novelUrl = loadedCheerio(this)
|
||||
.find('h3.truyen-title > a')
|
||||
.attr('href')
|
||||
.replace('.html', '')
|
||||
.substring(1);
|
||||
novelUrl = `${novelUrl}/`;
|
||||
|
||||
const novel = {
|
||||
sourceId: 8,
|
||||
novelUrl,
|
||||
novelName,
|
||||
novelCover,
|
||||
};
|
||||
const novel = {
|
||||
sourceId: 8,
|
||||
novelUrl,
|
||||
novelName,
|
||||
novelCover,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
novels.push(novel);
|
||||
},
|
||||
);
|
||||
|
||||
return {totalPages, novels};
|
||||
};
|
||||
@@ -45,7 +47,7 @@ const parseNovelAndChapters = async novelUrl => {
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
let loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novel = {};
|
||||
|
||||
@@ -57,51 +59,51 @@ const parseNovelAndChapters = async novelUrl => {
|
||||
|
||||
novel.novelUrl = novelUrl;
|
||||
|
||||
novel.novelName = $('div.book > img').attr('alt');
|
||||
novel.novelName = loadedCheerio('div.book > img').attr('alt');
|
||||
|
||||
novel.novelCover = baseUrl + $('div.book > img').attr('src');
|
||||
novel.novelCover = baseUrl + loadedCheerio('div.book > img').attr('src');
|
||||
|
||||
novel.summary = $('div.desc-text').text().trim();
|
||||
novel.summary = loadedCheerio('div.desc-text').text().trim();
|
||||
|
||||
novel.author = $('div.info > div > h3')
|
||||
novel.author = loadedCheerio('div.info > div > h3')
|
||||
.filter(function () {
|
||||
return $(this).text().trim() === 'Author:';
|
||||
return loadedCheerio(this).text().trim() === 'Author:';
|
||||
})
|
||||
.siblings()
|
||||
.text();
|
||||
|
||||
novel.genre = $('div.info > div')
|
||||
novel.genre = loadedCheerio('div.info > div')
|
||||
.filter(function () {
|
||||
return $(this).find('h3').text().trim() === 'Genre:';
|
||||
return loadedCheerio(this).find('h3').text().trim() === 'Genre:';
|
||||
})
|
||||
.text()
|
||||
.replace('Genre:', '');
|
||||
|
||||
novel.artist = null;
|
||||
|
||||
novel.status = $('div.info > div > h3')
|
||||
novel.status = loadedCheerio('div.info > div > h3')
|
||||
.filter(function () {
|
||||
return $(this).text().trim() === 'Status:';
|
||||
return loadedCheerio(this).text().trim() === 'Status:';
|
||||
})
|
||||
.next()
|
||||
.text();
|
||||
|
||||
const novelId = $('#rating').attr('data-novel-id');
|
||||
const novelId = loadedCheerio('#rating').attr('data-novel-id');
|
||||
|
||||
const getChapters = async novelId => {
|
||||
const chapterListUrl = baseUrl + '/ajax/chapter-option?novelId=' + novelId;
|
||||
const getChapters = async id => {
|
||||
const chapterListUrl = baseUrl + '/ajax/chapter-option?novelId=' + id;
|
||||
|
||||
const data = await fetch(chapterListUrl);
|
||||
const chapters = await data.text();
|
||||
|
||||
$ = cheerio.load(chapters);
|
||||
loadedCheerio = cheerio.load(chapters);
|
||||
|
||||
let novelChapters = [];
|
||||
|
||||
$('select > option').each(function (result) {
|
||||
let chapterName = $(this).text();
|
||||
loadedCheerio('select > option').each(function () {
|
||||
let chapterName = loadedCheerio(this).text();
|
||||
let releaseDate = null;
|
||||
let chapterUrl = $(this).attr('value');
|
||||
let chapterUrl = loadedCheerio(this).attr('value');
|
||||
chapterUrl = chapterUrl.replace(`/${novelUrl}`, '');
|
||||
|
||||
novelChapters.push({
|
||||
@@ -124,10 +126,10 @@ const parseChapter = async (novelUrl, chapterUrl) => {
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
const chapterName = $('.chapter-title').attr('title');
|
||||
let chapterText = $('#chapter-content').html();
|
||||
const chapterName = loadedCheerio('.chapter-title').attr('title');
|
||||
let chapterText = loadedCheerio('#chapter-content').html();
|
||||
const chapter = {
|
||||
sourceId: 8,
|
||||
novelUrl,
|
||||
@@ -140,37 +142,39 @@ const parseChapter = async (novelUrl, chapterUrl) => {
|
||||
};
|
||||
|
||||
const searchNovels = async searchTerm => {
|
||||
const searchUrl = `https://novelfull.com/search?keyword=`;
|
||||
const searchUrl = 'https://novelfull.com/search?keyword=';
|
||||
|
||||
const url = `${searchUrl}${searchTerm}`;
|
||||
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novels = [];
|
||||
|
||||
$('div.col-truyen-main > div.list-truyen > .row').each(function (result) {
|
||||
let novelUrl = $(this)
|
||||
.find('h3.truyen-title > a')
|
||||
.attr('href')
|
||||
.replace('.html', '')
|
||||
.substring(1);
|
||||
novelUrl = `${novelUrl}/`;
|
||||
loadedCheerio('div.col-truyen-main > div.list-truyen > .row').each(
|
||||
function () {
|
||||
let novelUrl = loadedCheerio(this)
|
||||
.find('h3.truyen-title > a')
|
||||
.attr('href')
|
||||
.replace('.html', '')
|
||||
.substring(1);
|
||||
novelUrl = `${novelUrl}/`;
|
||||
|
||||
const novelName = $(this).find('h3.truyen-title > a').text();
|
||||
const novelCover = baseUrl + $(this).find('img').attr('src');
|
||||
const novelName = loadedCheerio(this).find('h3.truyen-title > a').text();
|
||||
const novelCover = baseUrl + loadedCheerio(this).find('img').attr('src');
|
||||
|
||||
const novel = {
|
||||
sourceId: 8,
|
||||
novelUrl,
|
||||
novelName,
|
||||
novelCover,
|
||||
};
|
||||
const novel = {
|
||||
sourceId: 8,
|
||||
novelUrl,
|
||||
novelName,
|
||||
novelCover,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
novels.push(novel);
|
||||
},
|
||||
);
|
||||
|
||||
return novels;
|
||||
};
|
||||
|
||||
+33
-26
@@ -7,16 +7,16 @@ const popularNovels = async page => {
|
||||
const result = await fetch(baseUrl);
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novels = [];
|
||||
|
||||
$('div.section1')
|
||||
loadedCheerio('div.section1')
|
||||
.find('li')
|
||||
.each(function (result) {
|
||||
const novelName = $(this).find('.book-info > h2 > a').text();
|
||||
const novelCover = $(this).find('img').attr('src');
|
||||
const novelUrl = $(this).find('a').attr('href').substring(1);
|
||||
.each(function () {
|
||||
const novelName = loadedCheerio(this).find('.book-info > h2 > a').text();
|
||||
const novelCover = loadedCheerio(this).find('img').attr('src');
|
||||
const novelUrl = loadedCheerio(this).find('a').attr('href').substring(1);
|
||||
|
||||
const novel = {
|
||||
sourceId: 6,
|
||||
@@ -37,7 +37,7 @@ const parseNovelAndChapters = async novelUrl => {
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novel = {};
|
||||
|
||||
@@ -49,32 +49,39 @@ const parseNovelAndChapters = async novelUrl => {
|
||||
|
||||
novel.novelUrl = novelUrl;
|
||||
|
||||
novel.novelName = $('h1').text();
|
||||
novel.novelName = loadedCheerio('h1').text();
|
||||
|
||||
novel.novelCover = $('div.book-img > img').attr('src');
|
||||
novel.novelCover = loadedCheerio('div.book-img > img').attr('src');
|
||||
|
||||
novel.summary = $('div.intro')
|
||||
novel.summary = loadedCheerio('div.intro')
|
||||
.text()
|
||||
.replace(/[\t\n]/g, '');
|
||||
|
||||
novel.author = $('span.blue').first().text().replace('Author:', '');
|
||||
novel.author = loadedCheerio('span.blue')
|
||||
.first()
|
||||
.text()
|
||||
.replace('Author:', '');
|
||||
|
||||
novel.genre = $('a.red').text();
|
||||
novel.genre = loadedCheerio('a.red').text();
|
||||
|
||||
novel.artist = null;
|
||||
|
||||
novel.status = $('span.blue').first().next().text().replace('Status:', '');
|
||||
novel.status = loadedCheerio('span.blue')
|
||||
.first()
|
||||
.next()
|
||||
.text()
|
||||
.replace('Status:', '');
|
||||
|
||||
let novelChapters = [];
|
||||
|
||||
$('div.book-catalog.hidden-xs#morelist')
|
||||
loadedCheerio('div.book-catalog.hidden-xs#morelist')
|
||||
.find('li.post-11')
|
||||
.each(function (result) {
|
||||
let chapterName = $(this).find('a').text();
|
||||
.each(function () {
|
||||
let chapterName = loadedCheerio(this).find('a').text();
|
||||
|
||||
let releaseDate = null;
|
||||
|
||||
let chapterUrl = $(this).find('a').attr('href');
|
||||
let chapterUrl = loadedCheerio(this).find('a').attr('href');
|
||||
|
||||
if (chapterUrl) {
|
||||
chapterUrl = chapterUrl.replace(`/${novelUrl}/`, '');
|
||||
@@ -100,11 +107,11 @@ const parseChapter = async (novelUrl, chapterUrl) => {
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
const chapterName = $('h1').text();
|
||||
let chapterText = $('div.entry-content').html();
|
||||
chapter = {
|
||||
const chapterName = loadedCheerio('h1').text();
|
||||
const chapterText = loadedCheerio('div.entry-content').html();
|
||||
const chapter = {
|
||||
sourceId: 6,
|
||||
novelUrl,
|
||||
chapterUrl,
|
||||
@@ -123,22 +130,22 @@ const searchNovels = async searchTerm => {
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novels = [];
|
||||
|
||||
$('tr').each(function (result) {
|
||||
let novelName = $(this).find('td:nth-child(2)').text();
|
||||
loadedCheerio('tr').each(function () {
|
||||
let novelName = loadedCheerio(this).find('td:nth-child(2)').text();
|
||||
novelName = novelName.replace(/[\t\n]/g, '');
|
||||
|
||||
const novelCover = 'https://cdn.novelupdates.com/imgmid/noimagemid.jpg';
|
||||
|
||||
let novelUrl = $(this).find('td:nth-child(2) >').attr('href');
|
||||
let novelUrl = loadedCheerio(this).find('td:nth-child(2) >').attr('href');
|
||||
if (novelUrl) {
|
||||
novelUrl = novelUrl.slice(1);
|
||||
}
|
||||
|
||||
novel = {
|
||||
const novel = {
|
||||
sourceId: 6,
|
||||
novelName,
|
||||
novelCover,
|
||||
|
||||
@@ -13,15 +13,15 @@ const popularNovels = async page => {
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novels = [];
|
||||
|
||||
$('.update_item.list_category').each(function () {
|
||||
const novelName = $(this).find('h3').text().trim();
|
||||
const novelCover = $(this).find('img').attr('src');
|
||||
loadedCheerio('.update_item.list_category').each(function () {
|
||||
const novelName = loadedCheerio(this).find('h3').text().trim();
|
||||
const novelCover = loadedCheerio(this).find('img').attr('src');
|
||||
|
||||
let novelUrl = $(this).find('h3 > a').attr('href');
|
||||
let novelUrl = loadedCheerio(this).find('h3 > a').attr('href');
|
||||
novelUrl = novelUrl.replace(baseUrl + 'novel/', '');
|
||||
|
||||
const novel = {
|
||||
@@ -43,46 +43,48 @@ const parseNovelAndChapters = async novelUrl => {
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novel = {sourceId, sourceName, url, novelUrl};
|
||||
|
||||
novel.novelName = $('h1').text().trim();
|
||||
novel.novelName = loadedCheerio('h1').text().trim();
|
||||
|
||||
novel.novelCover = $('.info_image > img').attr('src');
|
||||
novel.novelCover = loadedCheerio('.info_image > img').attr('src');
|
||||
|
||||
novel.summary = $('#noidungm').text().trim();
|
||||
novel.summary = loadedCheerio('#noidungm').text().trim();
|
||||
|
||||
novel.genre = $('div.truyen_if_wrap > ul > li:nth-child(3)')
|
||||
novel.genre = loadedCheerio('div.truyen_if_wrap > ul > li:nth-child(3)')
|
||||
.text()
|
||||
.replace('GENRES: ', '')
|
||||
.replace(/ - /g, ',')
|
||||
.trim();
|
||||
|
||||
console.log(novel.genre);
|
||||
// console.log(novel.genre);
|
||||
|
||||
novel.status =
|
||||
$(' div.truyen_if_wrap > ul > li:nth-child(4) > a')
|
||||
loadedCheerio(' div.truyen_if_wrap > ul > li:nth-child(4) > a')
|
||||
.text()
|
||||
.replace('STATUS', '')
|
||||
.trim() === 'ONGOING'
|
||||
? Status.ONGOING
|
||||
: Status.COMPLETED;
|
||||
|
||||
novel.author = $('div.truyen_if_wrap > ul > li:nth-child(2)')
|
||||
novel.author = loadedCheerio('div.truyen_if_wrap > ul > li:nth-child(2)')
|
||||
.text()
|
||||
.replace('Author(s):', '')
|
||||
.trim();
|
||||
|
||||
let novelChapters = [];
|
||||
|
||||
$('.chapter-list')
|
||||
loadedCheerio('.chapter-list')
|
||||
.find('.row')
|
||||
.each(function () {
|
||||
const releaseDate = $(this).find('span:nth-child(2)').text();
|
||||
const releaseDate = loadedCheerio(this).find('span:nth-child(2)').text();
|
||||
|
||||
const chapterName = $(this).find('span:nth-child(1) > a').text();
|
||||
const chapterUrl = $(this).find('a').attr('href');
|
||||
const chapterName = loadedCheerio(this)
|
||||
.find('span:nth-child(1) > a')
|
||||
.text();
|
||||
const chapterUrl = loadedCheerio(this).find('a').attr('href');
|
||||
|
||||
novelChapters.push({
|
||||
chapterName,
|
||||
@@ -102,10 +104,10 @@ const parseChapter = async (novelUrl, chapterUrl) => {
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
let chapterName = $('.name_chapter').text();
|
||||
let chapterText = $('#vung_doc').html();
|
||||
let chapterName = loadedCheerio('.name_chapter').text();
|
||||
let chapterText = loadedCheerio('#vung_doc').html();
|
||||
|
||||
const chapter = {
|
||||
sourceId,
|
||||
@@ -124,15 +126,15 @@ const searchNovels = async searchTerm => {
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novels = [];
|
||||
|
||||
$('.update_item.list_category').each(function () {
|
||||
const novelName = $(this).find('h3').text();
|
||||
const novelCover = $(this).find('img').attr('src');
|
||||
loadedCheerio('.update_item.list_category').each(function () {
|
||||
const novelName = loadedCheerio(this).find('h3').text();
|
||||
const novelCover = loadedCheerio(this).find('img').attr('src');
|
||||
|
||||
let novelUrl = $(this).find('h3 > a').attr('href');
|
||||
let novelUrl = loadedCheerio(this).find('h3 > a').attr('href');
|
||||
novelUrl = novelUrl.replace(baseUrl + 'novel/', '');
|
||||
|
||||
const novel = {
|
||||
|
||||
@@ -11,18 +11,19 @@ const popularNovels = async page => {
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novels = [];
|
||||
|
||||
$('div.j_bookList.lis-mn.ddc')
|
||||
loadedCheerio('div.j_bookList.lis-mn.ddc')
|
||||
.find('li')
|
||||
.each(function (result) {
|
||||
const novelName = $(this).find('h3').text();
|
||||
.each(function () {
|
||||
const novelName = loadedCheerio(this).find('h3').text();
|
||||
const novelCover =
|
||||
'https://www.novelpassion.com' + $(this).find('img').attr('src');
|
||||
'https://www.novelpassion.com' +
|
||||
loadedCheerio(this).find('img').attr('src');
|
||||
|
||||
let novelUrl = $(this).find('div.pr > a').attr('href');
|
||||
let novelUrl = loadedCheerio(this).find('div.pr > a').attr('href');
|
||||
novelUrl = novelUrl.replace('/novel/', '');
|
||||
|
||||
const novel = {
|
||||
@@ -44,7 +45,7 @@ const parseNovelAndChapters = async novelUrl => {
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novel = {};
|
||||
|
||||
@@ -56,25 +57,25 @@ const parseNovelAndChapters = async novelUrl => {
|
||||
|
||||
novel.novelUrl = novelUrl;
|
||||
|
||||
novelName = $('h2.mh').text();
|
||||
const novelName = loadedCheerio('h2.mh').text();
|
||||
novel.novelName = novelName;
|
||||
|
||||
novel.novelCover = baseUrl + $('i.g_thumb > img').attr('src');
|
||||
novel.novelCover = baseUrl + loadedCheerio('i.g_thumb > img').attr('src');
|
||||
|
||||
let novelSummary = $('div.j_synopsis').text().trim();
|
||||
let novelSummary = loadedCheerio('div.j_synopsis').text().trim();
|
||||
novel.summary = novelSummary;
|
||||
|
||||
$('address.lh20.m14.pr').each(function (result) {
|
||||
detailName = $(this).find('p.ell.dib.vam').text().trim();
|
||||
loadedCheerio('address.lh20.m14.pr').each(function () {
|
||||
const detailName = loadedCheerio(this).find('p.ell.dib.vam').text().trim();
|
||||
|
||||
detail = $(this).find('div.dns').text().trim();
|
||||
const detail = loadedCheerio(this).find('div.dns').text().trim();
|
||||
|
||||
switch (detailName) {
|
||||
case 'Categories:':
|
||||
novel.genre = detail.trim().replace(/ - /g, ',');
|
||||
novel.genre = detail.trim().replace(/ - {2}/g, ',');
|
||||
break;
|
||||
case 'Author:':
|
||||
novel.author = detail.trim().replace(/ - /g, ', ');
|
||||
novel.author = detail.trim().replace(/ - {2}/g, ', ');
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -85,15 +86,15 @@ const parseNovelAndChapters = async novelUrl => {
|
||||
|
||||
let novelChapters = [];
|
||||
|
||||
$('.content-list')
|
||||
loadedCheerio('.content-list')
|
||||
.find('li')
|
||||
.each(function (result) {
|
||||
const chapterName = $(this).find('span.sp1').text();
|
||||
.each(function () {
|
||||
const chapterName = loadedCheerio(this).find('span.sp1').text();
|
||||
|
||||
let releaseDate = $(this).find('i.sp2').text();
|
||||
let releaseDate = loadedCheerio(this).find('i.sp2').text();
|
||||
releaseDate = moment(new Date(releaseDate)).format('MM/DD/YY');
|
||||
|
||||
const chapterUrl = $(this)
|
||||
const chapterUrl = loadedCheerio(this)
|
||||
.find('a')
|
||||
.attr('href')
|
||||
.replace('/novel/' + novelUrl + '/', '');
|
||||
@@ -116,11 +117,11 @@ const parseChapter = async (novelUrl, chapterUrl) => {
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
let chapterName = $('div.cha-content').find('strong').text();
|
||||
let chapterName = loadedCheerio('div.cha-content').find('strong').text();
|
||||
|
||||
let chapterText = $('div.cha-content').html();
|
||||
let chapterText = loadedCheerio('div.cha-content').html();
|
||||
const chapter = {
|
||||
sourceId: 33,
|
||||
novelUrl,
|
||||
@@ -138,18 +139,19 @@ const searchNovels = async searchTerm => {
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novels = [];
|
||||
|
||||
$('div.j_bookList.lis-mn.ddc')
|
||||
loadedCheerio('div.j_bookList.lis-mn.ddc')
|
||||
.find('li')
|
||||
.each(function (result) {
|
||||
const novelName = $(this).find('h3').text();
|
||||
.each(function () {
|
||||
const novelName = loadedCheerio(this).find('h3').text();
|
||||
const novelCover =
|
||||
'https://www.novelpassion.com' + $(this).find('img').attr('src');
|
||||
'https://www.novelpassion.com' +
|
||||
loadedCheerio(this).find('img').attr('src');
|
||||
|
||||
let novelUrl = $(this).find('div.pr > a').attr('href');
|
||||
let novelUrl = loadedCheerio(this).find('div.pr > a').attr('href');
|
||||
novelUrl = novelUrl.replace('/novel/', '');
|
||||
|
||||
const novel = {
|
||||
|
||||
@@ -9,15 +9,15 @@ const popularNovels = async page => {
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novels = [];
|
||||
|
||||
$('.page-item-detail').each(function (result) {
|
||||
const novelName = $(this).find('.h5 > a').text();
|
||||
const novelCover = $(this).find('img').attr('data-src');
|
||||
loadedCheerio('.page-item-detail').each(function () {
|
||||
const novelName = loadedCheerio(this).find('.h5 > a').text();
|
||||
const novelCover = loadedCheerio(this).find('img').attr('data-src');
|
||||
|
||||
let novelUrl = $(this).find('.h5 > a').attr('href');
|
||||
let novelUrl = loadedCheerio(this).find('.h5 > a').attr('href');
|
||||
novelUrl = novelUrl.replace(`${baseUrl}manga/`, '');
|
||||
|
||||
const novel = {
|
||||
@@ -39,7 +39,7 @@ const parseNovelAndChapters = async novelUrl => {
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novel = {};
|
||||
|
||||
@@ -51,20 +51,20 @@ const parseNovelAndChapters = async novelUrl => {
|
||||
|
||||
novel.novelUrl = novelUrl;
|
||||
|
||||
novel.novelName = $('.post-title > h1')
|
||||
novel.novelName = loadedCheerio('.post-title > h1')
|
||||
.text()
|
||||
.replace(/[\t\n]/g, '')
|
||||
.trim();
|
||||
|
||||
novel.novelCover = $('.summary_image > a > img').attr('data-src');
|
||||
novel.novelCover = loadedCheerio('.summary_image > a > img').attr('data-src');
|
||||
|
||||
$('.post-content_item').each(function (result) {
|
||||
detailName = $(this)
|
||||
loadedCheerio('.post-content_item').each(function () {
|
||||
const detailName = loadedCheerio(this)
|
||||
.find('.summary-heading > h5')
|
||||
.text()
|
||||
.replace(/[\t\n]/g, '')
|
||||
.trim();
|
||||
detail = $(this)
|
||||
const detail = loadedCheerio(this)
|
||||
.find('.summary-content')
|
||||
.text()
|
||||
.replace(/[\t\n]/g, '')
|
||||
@@ -83,28 +83,33 @@ const parseNovelAndChapters = async novelUrl => {
|
||||
}
|
||||
});
|
||||
|
||||
$('.description-summary > div.summary__content').find('em').remove();
|
||||
loadedCheerio('.description-summary > div.summary__content')
|
||||
.find('em')
|
||||
.remove();
|
||||
|
||||
novel.summary = $('.description-summary > div.summary__content')
|
||||
novel.summary = loadedCheerio('.description-summary > div.summary__content')
|
||||
.text()
|
||||
.replace(/[\t\n]/g, '');
|
||||
|
||||
let novelChapters = [];
|
||||
|
||||
$('.wp-manga-chapter').each(function (result) {
|
||||
chapterName = $(this)
|
||||
loadedCheerio('.wp-manga-chapter').each(function () {
|
||||
const chapterName = loadedCheerio(this)
|
||||
.find('a')
|
||||
.text()
|
||||
.replace(/[\t\n]/g, '')
|
||||
.trim();
|
||||
|
||||
releaseDate = $(this)
|
||||
const releaseDate = loadedCheerio(this)
|
||||
.find('span')
|
||||
.text()
|
||||
.replace(/[\t\n]/g, '')
|
||||
.trim();
|
||||
|
||||
chapterUrl = $(this).find('a').attr('href').replace(url, '');
|
||||
const chapterUrl = loadedCheerio(this)
|
||||
.find('a')
|
||||
.attr('href')
|
||||
.replace(url, '');
|
||||
novelChapters.push({chapterName, releaseDate, chapterUrl});
|
||||
});
|
||||
|
||||
@@ -119,10 +124,10 @@ const parseChapter = async (novelUrl, chapterUrl) => {
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
const chapterName = $('h1#chapter-heading').text();
|
||||
let chapterText = $('.reading-content').html();
|
||||
const chapterName = loadedCheerio('h1#chapter-heading').text();
|
||||
let chapterText = loadedCheerio('.reading-content').html();
|
||||
const chapter = {
|
||||
sourceId: 9,
|
||||
novelUrl,
|
||||
@@ -140,15 +145,15 @@ const searchNovels = async searchTerm => {
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novels = [];
|
||||
|
||||
$('.c-tabs-item__content').each(function (result) {
|
||||
const novelName = $(this).find('.h4 > a').text();
|
||||
const novelCover = $(this).find('img').attr('data-src');
|
||||
loadedCheerio('.c-tabs-item__content').each(function () {
|
||||
const novelName = loadedCheerio(this).find('.h4 > a').text();
|
||||
const novelCover = loadedCheerio(this).find('img').attr('data-src');
|
||||
|
||||
let novelUrl = $(this).find('.h4 > a').attr('href');
|
||||
let novelUrl = loadedCheerio(this).find('.h4 > a').attr('href');
|
||||
novelUrl = novelUrl.replace(`${baseUrl}manga/`, '');
|
||||
|
||||
const novel = {
|
||||
|
||||
@@ -21,14 +21,14 @@ const popularNovels = async page => {
|
||||
});
|
||||
const body = await result.text();
|
||||
|
||||
const $ = cheerio.load(body);
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
const novels = [];
|
||||
|
||||
$('div.search_main_box_nu').each(function (res) {
|
||||
const novelCover = $(this).find('img').attr('src');
|
||||
const novelName = $(this).find('.search_title > a').text();
|
||||
const novelUrl = $(this)
|
||||
loadedCheerio('div.search_main_box_nu').each(function (res) {
|
||||
const novelCover = loadedCheerio(this).find('img').attr('src');
|
||||
const novelName = loadedCheerio(this).find('.search_title > a').text();
|
||||
const novelUrl = loadedCheerio(this)
|
||||
.find('.search_title > a')
|
||||
.attr('href')
|
||||
.split('/')[4];
|
||||
@@ -55,7 +55,7 @@ const parseNovelAndChapters = async novelUrl => {
|
||||
});
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
let loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novel = {
|
||||
sourceId,
|
||||
@@ -64,32 +64,32 @@ const parseNovelAndChapters = async novelUrl => {
|
||||
novelUrl,
|
||||
};
|
||||
|
||||
novel.novelName = $('.seriestitlenu').text();
|
||||
novel.novelName = loadedCheerio('.seriestitlenu').text();
|
||||
|
||||
novel.novelCover = $('.seriesimg > img').attr('src');
|
||||
novel.novelCover = loadedCheerio('.seriesimg > img').attr('src');
|
||||
|
||||
novel.author = $('#showauthors').text().trim();
|
||||
novel.author = loadedCheerio('#showauthors').text().trim();
|
||||
|
||||
novel.genre = $('#seriesgenre').text().trim().replace(/\s/g, ',');
|
||||
novel.genre = loadedCheerio('#seriesgenre').text().trim().replace(/\s/g, ',');
|
||||
|
||||
novel.status = $('#editstatus').text().includes('Ongoing')
|
||||
novel.status = loadedCheerio('#editstatus').text().includes('Ongoing')
|
||||
? 'Ongoing'
|
||||
: 'Completed';
|
||||
|
||||
let type = $('#showtype').text().trim();
|
||||
let type = loadedCheerio('#showtype').text().trim();
|
||||
|
||||
let summary = $('#editdescription').text().trim();
|
||||
let summary = loadedCheerio('#editdescription').text().trim();
|
||||
|
||||
novel.summary = summary + `\n\nType: ${type}`;
|
||||
|
||||
let novelChapters = [];
|
||||
|
||||
const novelId = $('input#mypostid').attr('value');
|
||||
const novelId = loadedCheerio('input#mypostid').attr('value');
|
||||
|
||||
let formData = new FormData();
|
||||
formData.append('action', 'nd_getchapters');
|
||||
formData.append('mygrr', 0);
|
||||
formData.append('mypostid', parseInt(novelId));
|
||||
formData.append('mypostid', parseInt(novelId, 10));
|
||||
|
||||
const data = await fetch(
|
||||
'https://www.novelupdates.com/wp-admin/admin-ajax.php',
|
||||
@@ -101,14 +101,15 @@ const parseNovelAndChapters = async novelUrl => {
|
||||
);
|
||||
const text = await data.text();
|
||||
|
||||
$ = cheerio.load(text);
|
||||
loadedCheerio = cheerio.load(text);
|
||||
|
||||
$('li.sp_li_chp').each(function () {
|
||||
const chapterName = $(this).text().trim();
|
||||
loadedCheerio('li.sp_li_chp').each(function () {
|
||||
const chapterName = loadedCheerio(this).text().trim();
|
||||
|
||||
const releaseDate = null;
|
||||
|
||||
const chapterUrl = 'https:' + $(this).find('a').first().next().attr('href');
|
||||
const chapterUrl =
|
||||
'https:' + loadedCheerio(this).find('a').first().next().attr('href');
|
||||
|
||||
novelChapters.push({chapterName, releaseDate, chapterUrl});
|
||||
});
|
||||
@@ -120,7 +121,7 @@ const parseNovelAndChapters = async novelUrl => {
|
||||
|
||||
function getLocation(href) {
|
||||
var match = href.match(
|
||||
/^(https?\:)\/\/(([^:\/?#]*)(?:\:([0-9]+))?)([\/]{0,1}[^?#]*)(\?[^#]*|)(#.*|)$/,
|
||||
/^(https?:)\/\/(([^:/?#]*)(?::([0-9]+))?)([/]{0,1}[^?#]*)(\?[^#]*|)(#.*|)$/,
|
||||
);
|
||||
return match && `${match[1]}//${match[3]}`;
|
||||
}
|
||||
@@ -134,6 +135,8 @@ const parseChapter = async (novelUrl, chapterUrl) => {
|
||||
|
||||
let chapterName = '';
|
||||
|
||||
let chapterText = '';
|
||||
|
||||
try {
|
||||
result = await fetch(url, {
|
||||
method: 'GET',
|
||||
@@ -145,7 +148,7 @@ const parseChapter = async (novelUrl, chapterUrl) => {
|
||||
|
||||
// console.log("Redirected URL: ", result.url);
|
||||
|
||||
$ = cheerio.load(body);
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
let isWuxiaWorld = result.url.toLowerCase().includes('wuxiaworld');
|
||||
|
||||
@@ -157,13 +160,14 @@ const parseChapter = async (novelUrl, chapterUrl) => {
|
||||
* Checks if its a wwordpress site
|
||||
*/
|
||||
let isWordPress =
|
||||
$('meta[name="generator"]').attr('content') || $('footer').text();
|
||||
loadedCheerio('meta[name="generator"]').attr('content') ||
|
||||
loadedCheerio('footer').text();
|
||||
|
||||
if (isWordPress) {
|
||||
isWordPress =
|
||||
isWordPress.toLowerCase().includes('wordpress') ||
|
||||
isWordPress.includes('Site Kit by Google') ||
|
||||
$('.powered-by').text().toLowerCase().includes('wordpress');
|
||||
loadedCheerio('.powered-by').text().toLowerCase().includes('wordpress');
|
||||
}
|
||||
|
||||
let isRainOfSnow = result.url.toLowerCase().includes('rainofsnow');
|
||||
@@ -175,19 +179,19 @@ const parseChapter = async (novelUrl, chapterUrl) => {
|
||||
let isScribbleHub = result.url.toLowerCase().includes('scribblehub');
|
||||
|
||||
if (isWuxiaWorld) {
|
||||
chapterText = $('#chapter-content').html();
|
||||
chapterText = loadedCheerio('#chapter-content').html();
|
||||
} else if (isRainOfSnow) {
|
||||
chapterText = $('div.content').html();
|
||||
chapterText = loadedCheerio('div.content').html();
|
||||
} else if (isTumblr) {
|
||||
chapterText = $('.post').html();
|
||||
chapterText = loadedCheerio('.post').html();
|
||||
} else if (isBlogspot) {
|
||||
$('.post-share-buttons').remove();
|
||||
loadedCheerio('.post-share-buttons').remove();
|
||||
|
||||
chapterText = $('.entry-content').html();
|
||||
chapterText = loadedCheerio('.entry-content').html();
|
||||
} else if (isHostedNovel) {
|
||||
chapterText = $('.chapter').html();
|
||||
chapterText = loadedCheerio('.chapter').html();
|
||||
} else if (isScribbleHub) {
|
||||
chapterText = $('div.chp_raw').html();
|
||||
chapterText = loadedCheerio('div.chp_raw').html();
|
||||
} else if (isWordPress) {
|
||||
/**
|
||||
* Remove wordpress bloat tags
|
||||
@@ -209,21 +213,21 @@ const parseChapter = async (novelUrl, chapterUrl) => {
|
||||
'.ezoic-ad',
|
||||
];
|
||||
|
||||
bloatClasses.map(tag => $(tag).remove());
|
||||
bloatClasses.map(tag => loadedCheerio(tag).remove());
|
||||
|
||||
chapterText =
|
||||
$('.entry-content').html() ||
|
||||
$('.single_post').html() ||
|
||||
$('.post-entry').html() ||
|
||||
$('.main-content').html() ||
|
||||
$('article.post').html() ||
|
||||
$('.content').html() ||
|
||||
$('#content').html();
|
||||
loadedCheerio('.entry-content').html() ||
|
||||
loadedCheerio('.single_post').html() ||
|
||||
loadedCheerio('.post-entry').html() ||
|
||||
loadedCheerio('.main-content').html() ||
|
||||
loadedCheerio('article.post').html() ||
|
||||
loadedCheerio('.content').html() ||
|
||||
loadedCheerio('#content').html();
|
||||
} else if (isWebNovel) {
|
||||
chapterText = $('.cha-words').html();
|
||||
chapterText = loadedCheerio('.cha-words').html();
|
||||
|
||||
if (!chapterText) {
|
||||
chapterText = $('._content').html();
|
||||
chapterText = loadedCheerio('._content').html();
|
||||
}
|
||||
} else {
|
||||
/**
|
||||
@@ -231,9 +235,9 @@ const parseChapter = async (novelUrl, chapterUrl) => {
|
||||
*/
|
||||
const tags = ['nav', 'header', 'footer', '.hidden'];
|
||||
|
||||
tags.map(tag => $(tag).remove());
|
||||
tags.map(tag => loadedCheerio(tag).remove());
|
||||
|
||||
chapterText = $('body').html();
|
||||
chapterText = loadedCheerio('body').html();
|
||||
}
|
||||
|
||||
if (!chapterText) {
|
||||
@@ -273,14 +277,14 @@ const searchNovels = async searchTerm => {
|
||||
});
|
||||
const body = await res.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novels = [];
|
||||
|
||||
$('div.search_main_box_nu').each(function (res) {
|
||||
const novelCover = $(this).find('img').attr('src');
|
||||
const novelName = $(this).find('.search_title > a').text();
|
||||
const novelUrl = $(this)
|
||||
loadedCheerio('div.search_main_box_nu').each(function () {
|
||||
const novelCover = loadedCheerio(this).find('img').attr('src');
|
||||
const novelName = loadedCheerio(this).find('.search_title > a').text();
|
||||
const novelUrl = loadedCheerio(this)
|
||||
.find('.search_title > a')
|
||||
.attr('href')
|
||||
.split('/')[4];
|
||||
|
||||
@@ -7,15 +7,15 @@ const popularNovels = async page => {
|
||||
const result = await fetch(baseUrl);
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novels = [];
|
||||
|
||||
$('.section-item').each(function (result) {
|
||||
const novelName = $(this).find('.book-name').text();
|
||||
const novelCover = $(this).find('img').attr('src');
|
||||
loadedCheerio('.section-item').each(function () {
|
||||
const novelName = loadedCheerio(this).find('.book-name').text();
|
||||
const novelCover = loadedCheerio(this).find('img').attr('src');
|
||||
|
||||
let novelUrl = $(this).find('a').attr('href').slice(1);
|
||||
let novelUrl = loadedCheerio(this).find('a').attr('href').slice(1);
|
||||
|
||||
const novel = {
|
||||
sourceId: 18,
|
||||
@@ -36,7 +36,7 @@ const parseNovelAndChapters = async novelUrl => {
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novel = {};
|
||||
|
||||
@@ -48,25 +48,25 @@ const parseNovelAndChapters = async novelUrl => {
|
||||
|
||||
novel.novelUrl = novelUrl;
|
||||
|
||||
novel.novelName = $('.book-name').text();
|
||||
novel.novelName = loadedCheerio('.book-name').text();
|
||||
|
||||
novel.novelCover = $('div.book-img > img').attr('src');
|
||||
novel.novelCover = loadedCheerio('div.book-img > img').attr('src');
|
||||
|
||||
novel.genre = $('div.book-catalog > span.txt').text();
|
||||
novel.genre = loadedCheerio('div.book-catalog > span.txt').text();
|
||||
|
||||
novel.status = $('div.book-state > span.txt').text();
|
||||
novel.status = loadedCheerio('div.book-state > span.txt').text();
|
||||
|
||||
novel.author = $('div.author > span.name').text();
|
||||
novel.author = loadedCheerio('div.author > span.name').text();
|
||||
|
||||
novelSummary = $('div.content > p.desc').text();
|
||||
const novelSummary = loadedCheerio('div.content > p.desc').text();
|
||||
novel.summary = novelSummary.trim();
|
||||
|
||||
let novelChapters = [];
|
||||
|
||||
$('.chapter-item').each(function (result) {
|
||||
const chapterName = $(this).find('.chapter-name').text();
|
||||
loadedCheerio('.chapter-item').each(function () {
|
||||
const chapterName = loadedCheerio(this).find('.chapter-name').text();
|
||||
const releaseDate = null;
|
||||
const chapterUrl = $(this).attr('href').slice(1);
|
||||
const chapterUrl = loadedCheerio(this).attr('href').slice(1);
|
||||
|
||||
novelChapters.push({
|
||||
chapterName,
|
||||
@@ -86,10 +86,10 @@ const parseChapter = async (novelUrl, chapterUrl) => {
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
const chapterName = $('h1.chapter-title').text();
|
||||
let chapterText = $('div.chapter-entity').html();
|
||||
const chapterName = loadedCheerio('h1.chapter-title').text();
|
||||
let chapterText = loadedCheerio('div.chapter-entity').html();
|
||||
const chapter = {
|
||||
sourceId: 18,
|
||||
novelUrl,
|
||||
@@ -107,17 +107,17 @@ const searchNovels = async searchTerm => {
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novels = [];
|
||||
|
||||
$('.list-item').each(function (result) {
|
||||
$(this).find('font').remove();
|
||||
loadedCheerio('.list-item').each(function () {
|
||||
loadedCheerio(this).find('font').remove();
|
||||
|
||||
const novelName = $(this).find('.book-name').text();
|
||||
const novelCover = $(this).find('img').attr('src');
|
||||
const novelName = loadedCheerio(this).find('.book-name').text();
|
||||
const novelCover = loadedCheerio(this).find('img').attr('src');
|
||||
|
||||
let novelUrl = $(this).find('a').attr('href').slice(1);
|
||||
let novelUrl = loadedCheerio(this).find('a').attr('href').slice(1);
|
||||
|
||||
const novel = {
|
||||
sourceId: 18,
|
||||
|
||||
@@ -15,14 +15,14 @@ const popularNovels = async page => {
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novels = [];
|
||||
|
||||
$('.minbox').each(function () {
|
||||
const novelName = $(this).find('h3').text();
|
||||
const novelCover = $(this).find('img').attr('data-src');
|
||||
const novelUrl = $(this).find('h3 > a').attr('href');
|
||||
loadedCheerio('.minbox').each(function () {
|
||||
const novelName = loadedCheerio(this).find('h3').text();
|
||||
const novelCover = loadedCheerio(this).find('img').attr('data-src');
|
||||
const novelUrl = loadedCheerio(this).find('h3 > a').attr('href');
|
||||
|
||||
const novel = {
|
||||
sourceId,
|
||||
@@ -43,23 +43,23 @@ const parseNovelAndChapters = async novelUrl => {
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novel = {sourceId, sourceName, url, novelUrl};
|
||||
|
||||
novel.novelName = $('h2').text().trim();
|
||||
novel.novelName = loadedCheerio('h2').text().trim();
|
||||
|
||||
novel.novelCover = $('.imagboca1 > img').attr('data-src');
|
||||
novel.novelCover = loadedCheerio('.imagboca1 > img').attr('data-src');
|
||||
|
||||
novel.summary = $('#synop').text().trim();
|
||||
novel.summary = loadedCheerio('#synop').text().trim();
|
||||
|
||||
novel.genre = $(
|
||||
novel.genre = loadedCheerio(
|
||||
'body > div.queen > div > div > div.row > div.col-md-12.col-lg-7 > div > div.backcolor1 > ul > li:nth-child(5) > small',
|
||||
)
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
novel.author = $(
|
||||
novel.author = loadedCheerio(
|
||||
'body > div.queen > div > div > div.row > div.col-md-12.col-lg-7 > div > div.backcolor1 > ul > li:nth-child(2) > small',
|
||||
).text();
|
||||
|
||||
@@ -67,12 +67,16 @@ const parseNovelAndChapters = async novelUrl => {
|
||||
|
||||
let novelChapters = [];
|
||||
|
||||
$('#chapter')
|
||||
loadedCheerio('#chapter')
|
||||
.find('li')
|
||||
.each(function () {
|
||||
const chapterName = $(this).find('.chapter').first().text().trim();
|
||||
const releaseDate = $(this).find('small').text();
|
||||
const chapterUrl = $(this).find('a').attr('href');
|
||||
const chapterName = loadedCheerio(this)
|
||||
.find('.chapter')
|
||||
.first()
|
||||
.text()
|
||||
.trim();
|
||||
const releaseDate = loadedCheerio(this).find('small').text();
|
||||
const chapterUrl = loadedCheerio(this).find('a').attr('href');
|
||||
|
||||
novelChapters.push({chapterName, releaseDate, chapterUrl});
|
||||
});
|
||||
@@ -86,10 +90,10 @@ const parseChapter = async (novelUrl, chapterUrl) => {
|
||||
const result = await fetch(chapterUrl);
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
let chapterName = $('.content > h2').text();
|
||||
let chapterText = $('.content').html();
|
||||
let chapterName = loadedCheerio('.content > h2').text();
|
||||
let chapterText = loadedCheerio('.content').html();
|
||||
|
||||
const chapter = {
|
||||
sourceId,
|
||||
@@ -108,14 +112,14 @@ const searchNovels = async searchTerm => {
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novels = [];
|
||||
|
||||
$('.minbox').each(function () {
|
||||
const novelName = $(this).find('h3').text();
|
||||
const novelCover = $(this).find('img').attr('data-src');
|
||||
const novelUrl = $(this).find('h3 > a').attr('href');
|
||||
loadedCheerio('.minbox').each(function () {
|
||||
const novelName = loadedCheerio(this).find('h3').text();
|
||||
const novelCover = loadedCheerio(this).find('img').attr('data-src');
|
||||
const novelUrl = loadedCheerio(this).find('h3 > a').attr('href');
|
||||
|
||||
const novel = {
|
||||
sourceId,
|
||||
|
||||
+24
-22
@@ -22,15 +22,15 @@ const popularNovels = async page => {
|
||||
const result = await fetch(url, {method: 'GET', headers: headers});
|
||||
const body = await result.text();
|
||||
|
||||
let $ = cheerio.load(body);
|
||||
let loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novels = [];
|
||||
|
||||
$('article.block.story.shortstory.mod-poster').each(function () {
|
||||
const novelName = $(this).find('h2.title').text();
|
||||
let novelCover = $(this).find('figure').attr('style');
|
||||
loadedCheerio('article.block.story.shortstory.mod-poster').each(function () {
|
||||
const novelName = loadedCheerio(this).find('h2.title').text();
|
||||
let novelCover = loadedCheerio(this).find('figure').attr('style');
|
||||
|
||||
let novelUrl = $(this)
|
||||
let novelUrl = loadedCheerio(this)
|
||||
.find('a')
|
||||
.attr('href')
|
||||
.replace(baseUrl + 'novels/', '');
|
||||
@@ -58,7 +58,7 @@ const parseNovelAndChapters = async novelUrl => {
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
|
||||
let $ = cheerio.load(body);
|
||||
let loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novel = {
|
||||
sourceId,
|
||||
@@ -67,20 +67,22 @@ const parseNovelAndChapters = async novelUrl => {
|
||||
novelUrl,
|
||||
};
|
||||
|
||||
novel.novelName = $('meta[property="og:title"]').attr('content');
|
||||
novel.novelName = loadedCheerio('meta[property="og:title"]').attr('content');
|
||||
|
||||
novel.novelCover = baseUrl + $('.poster > a > img').attr('src');
|
||||
novel.novelCover = baseUrl + loadedCheerio('.poster > a > img').attr('src');
|
||||
|
||||
novel.author = $('dl.author > dd').text();
|
||||
novel.author = loadedCheerio('dl.author > dd').text();
|
||||
|
||||
novel.genre = $('.book-generes').text().trim();
|
||||
novel.genre = loadedCheerio('.book-generes').text().trim();
|
||||
|
||||
novel.summary = $('div[itemprop="description"]').text().trim();
|
||||
novel.summary = loadedCheerio('div[itemprop="description"]').text().trim();
|
||||
|
||||
novel.author = $('span[itemprop="author"]').text();
|
||||
novel.genre = $('span[itemprop="genre"]').text().replace(', ', ',');
|
||||
novel.author = loadedCheerio('span[itemprop="author"]').text();
|
||||
novel.genre = loadedCheerio('span[itemprop="genre"]')
|
||||
.text()
|
||||
.replace(', ', ',');
|
||||
|
||||
let tempNovelUrl = $('.r-fullstory-chapters-foot')
|
||||
let tempNovelUrl = loadedCheerio('.r-fullstory-chapters-foot')
|
||||
.find('a')
|
||||
.next()
|
||||
.next()
|
||||
@@ -92,18 +94,18 @@ const parseNovelAndChapters = async novelUrl => {
|
||||
const chaptersHtml = await fetch(chapterListUrl);
|
||||
const chapterHtmlToString = await chaptersHtml.text();
|
||||
|
||||
$ = cheerio.load(chapterHtmlToString);
|
||||
loadedCheerio = cheerio.load(chapterHtmlToString);
|
||||
|
||||
// let lastPage = $("div.pages > a").last().text();
|
||||
|
||||
let novelChapters = [];
|
||||
|
||||
$('#dle-content > div.cat_block.cat_line').each(function () {
|
||||
const chapterName = $(this).find('.title').text();
|
||||
loadedCheerio('#dle-content > div.cat_block.cat_line').each(function () {
|
||||
const chapterName = loadedCheerio(this).find('.title').text();
|
||||
|
||||
let releaseDate = new Date();
|
||||
|
||||
let timeAgo = $(this).find('small').text();
|
||||
let timeAgo = loadedCheerio(this).find('small').text();
|
||||
|
||||
timeAgo = timeAgo.match(/\d+/)[0];
|
||||
|
||||
@@ -121,7 +123,7 @@ const parseNovelAndChapters = async novelUrl => {
|
||||
|
||||
releaseDate = moment(releaseDate).format('MM/DD/YY');
|
||||
|
||||
const chapterUrl = $(this)
|
||||
const chapterUrl = loadedCheerio(this)
|
||||
.find('a')
|
||||
.attr('href')
|
||||
.replace(baseUrl + 'up/', '');
|
||||
@@ -191,11 +193,11 @@ const parseChapter = async (novelUrl, chapterUrl) => {
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
let chapterName = $('h1.title').text();
|
||||
let chapterName = loadedCheerio('h1.title').text();
|
||||
|
||||
let chapterText = $('#arrticle').html();
|
||||
let chapterText = loadedCheerio('#arrticle').html();
|
||||
const chapter = {
|
||||
sourceId,
|
||||
novelUrl,
|
||||
|
||||
@@ -4,8 +4,6 @@ const sourceId = 2;
|
||||
|
||||
const sourceName = 'ReadLightNovel';
|
||||
|
||||
const lang = 'en';
|
||||
|
||||
const baseUrl = 'https://www.readlightnovel.me';
|
||||
|
||||
const searchUrl = 'https://www.readlightnovel.me/detailed-search';
|
||||
@@ -17,14 +15,14 @@ const popularNovels = async page => {
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
|
||||
const $ = cheerio.load(body);
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
const novels = [];
|
||||
|
||||
$('.top-novel-block').each(function (result) {
|
||||
const novelName = $(this).find('h2 > a').text();
|
||||
const novelCover = $(this).find('img').attr('src');
|
||||
const novelUrl = $(this)
|
||||
loadedCheerio('.top-novel-block').each(function () {
|
||||
const novelName = loadedCheerio(this).find('h2 > a').text();
|
||||
const novelCover = loadedCheerio(this).find('img').attr('src');
|
||||
const novelUrl = loadedCheerio(this)
|
||||
.find('h2 > a')
|
||||
.attr('href')
|
||||
.replace(`${baseUrl}/`, '');
|
||||
@@ -48,19 +46,21 @@ const parseNovelAndChapters = async novelUrl => {
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novel;
|
||||
|
||||
const novelName = $('.block-title > h1').text();
|
||||
const novelName = loadedCheerio('.block-title > h1').text();
|
||||
|
||||
const novelCover = $('.novel-cover > a > img').attr('src');
|
||||
const novelCover = loadedCheerio('.novel-cover > a > img').attr('src');
|
||||
|
||||
let author, artist, genre, summary, status;
|
||||
|
||||
$('.novel-detail-item').each(function (result) {
|
||||
const detailName = $(this).find('.novel-detail-header > h6').text();
|
||||
const detail = $(this).find('.novel-detail-body').text().trim();
|
||||
loadedCheerio('.novel-detail-item').each(function () {
|
||||
const detailName = loadedCheerio(this)
|
||||
.find('.novel-detail-header > h6')
|
||||
.text();
|
||||
const detail = loadedCheerio(this).find('.novel-detail-body').text().trim();
|
||||
|
||||
switch (detailName) {
|
||||
case 'Genre':
|
||||
@@ -84,17 +84,17 @@ const parseNovelAndChapters = async novelUrl => {
|
||||
|
||||
let chapters = [];
|
||||
|
||||
$('.panel').each(function () {
|
||||
let volumeName = $(this).find('h4.panel-title').text();
|
||||
loadedCheerio('.panel').each(function () {
|
||||
let volumeName = loadedCheerio(this).find('h4.panel-title').text();
|
||||
|
||||
$(this)
|
||||
loadedCheerio(this)
|
||||
.find('ul.chapter-chs > li')
|
||||
.each(function () {
|
||||
let chapterName = $(this).find('a').text();
|
||||
let chapterName = loadedCheerio(this).find('a').text();
|
||||
|
||||
const releaseDate = null;
|
||||
|
||||
const chapterUrl = $(this)
|
||||
const chapterUrl = loadedCheerio(this)
|
||||
.find('a')
|
||||
.attr('href')
|
||||
.replace(`${baseUrl}/${novelUrl}/`, '');
|
||||
@@ -137,24 +137,28 @@ const parseChapter = async (novelUrl, chapterUrl) => {
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
$('.block-title > h1').find('a').remove();
|
||||
loadedCheerio('.block-title > h1').find('a').remove();
|
||||
|
||||
const chapterName = $('.block-title > h1').text().replace(' - ', '');
|
||||
const chapterName = loadedCheerio('.block-title > h1')
|
||||
.text()
|
||||
.replace(' - ', '');
|
||||
|
||||
$('.alert').remove();
|
||||
$('.hidden').remove();
|
||||
$('iframe').remove();
|
||||
$('button').remove();
|
||||
$('.hid').remove();
|
||||
$('center').remove();
|
||||
$(
|
||||
loadedCheerio('.alert').remove();
|
||||
loadedCheerio('.hidden').remove();
|
||||
loadedCheerio('iframe').remove();
|
||||
loadedCheerio('button').remove();
|
||||
loadedCheerio('.hid').remove();
|
||||
loadedCheerio('center').remove();
|
||||
loadedCheerio(
|
||||
'div[style="float: left; margin-top: 20px; font-style: italic;margin-left: 50px; font-size: 14px;"]',
|
||||
).remove();
|
||||
$('div[style="float:left;margin-top:15px;margin-bottom:15px;"]').remove();
|
||||
loadedCheerio(
|
||||
'div[style="float:left;margin-top:15px;margin-bottom:15px;"]',
|
||||
).remove();
|
||||
|
||||
let chapterText = $('.desc').html();
|
||||
let chapterText = loadedCheerio('.desc').html();
|
||||
|
||||
const chapter = {
|
||||
sourceId: 2,
|
||||
@@ -178,15 +182,17 @@ const searchNovels = async searchTerm => {
|
||||
});
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novels = [];
|
||||
|
||||
$('.top-novel-block').each(function (result) {
|
||||
const novelName = $(this).find('.top-novel-header > h2 > a').text();
|
||||
const novelCover = $(this).find('img').attr('src');
|
||||
loadedCheerio('.top-novel-block').each(function () {
|
||||
const novelName = loadedCheerio(this)
|
||||
.find('.top-novel-header > h2 > a')
|
||||
.text();
|
||||
const novelCover = loadedCheerio(this).find('img').attr('src');
|
||||
|
||||
const novelUrl = $(this)
|
||||
const novelUrl = loadedCheerio(this)
|
||||
.find('.top-novel-header > h2 > a')
|
||||
.attr('href')
|
||||
.replace(`${baseUrl}/`, '');
|
||||
|
||||
@@ -7,15 +7,15 @@ const popularNovels = async page => {
|
||||
const result = await fetch(baseUrl);
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novels = [];
|
||||
|
||||
$('.section-item').each(function (result) {
|
||||
const novelName = $(this).find('.book-name').text();
|
||||
const novelCover = $(this).find('img').attr('src');
|
||||
loadedCheerio('.section-item').each(function () {
|
||||
const novelName = loadedCheerio(this).find('.book-name').text();
|
||||
const novelCover = loadedCheerio(this).find('img').attr('src');
|
||||
|
||||
let novelUrl = $(this).find('a').attr('href').slice(1);
|
||||
let novelUrl = loadedCheerio(this).find('a').attr('href').slice(1);
|
||||
|
||||
const novel = {
|
||||
sourceId: 19,
|
||||
@@ -36,7 +36,7 @@ const parseNovelAndChapters = async novelUrl => {
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novel = {};
|
||||
|
||||
@@ -48,25 +48,25 @@ const parseNovelAndChapters = async novelUrl => {
|
||||
|
||||
novel.novelUrl = novelUrl;
|
||||
|
||||
novel.novelName = $('.book-name').text();
|
||||
novel.novelName = loadedCheerio('.book-name').text();
|
||||
|
||||
novel.novelCover = $('div.book-img > img').attr('src');
|
||||
novel.novelCover = loadedCheerio('div.book-img > img').attr('src');
|
||||
|
||||
novel.genre = $('div.book-catalog > span.txt').text();
|
||||
novel.genre = loadedCheerio('div.book-catalog > span.txt').text();
|
||||
|
||||
novel.status = $('div.book-state > span.txt').text();
|
||||
novel.status = loadedCheerio('div.book-state > span.txt').text();
|
||||
|
||||
novel.author = $('div.author > span.name').text();
|
||||
novel.author = loadedCheerio('div.author > span.name').text();
|
||||
|
||||
novelSummary = $('div.content > p.desc').text();
|
||||
const novelSummary = loadedCheerio('div.content > p.desc').text();
|
||||
novel.summary = novelSummary.trim();
|
||||
|
||||
let novelChapters = [];
|
||||
|
||||
$('.chapter-item').each(function (result) {
|
||||
const chapterName = $(this).find('.chapter-name').text();
|
||||
loadedCheerio('.chapter-item').each(function () {
|
||||
const chapterName = loadedCheerio(this).find('.chapter-name').text();
|
||||
const releaseDate = null;
|
||||
const chapterUrl = $(this).attr('href').slice(1);
|
||||
const chapterUrl = loadedCheerio(this).attr('href').slice(1);
|
||||
|
||||
novelChapters.push({
|
||||
chapterName,
|
||||
@@ -86,10 +86,10 @@ const parseChapter = async (novelUrl, chapterUrl) => {
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
const chapterName = $('h1.chapter-title').text();
|
||||
let chapterText = $('div.chapter-entity').html();
|
||||
const chapterName = loadedCheerio('h1.chapter-title').text();
|
||||
let chapterText = loadedCheerio('div.chapter-entity').html();
|
||||
const chapter = {
|
||||
sourceId: 19,
|
||||
novelUrl,
|
||||
@@ -107,17 +107,17 @@ const searchNovels = async searchTerm => {
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novels = [];
|
||||
|
||||
$('.list-item').each(function (result) {
|
||||
$(this).find('font').remove();
|
||||
loadedCheerio('.list-item').each(function () {
|
||||
loadedCheerio(this).find('font').remove();
|
||||
|
||||
const novelName = $(this).find('.book-name').text();
|
||||
const novelCover = $(this).find('img').attr('src');
|
||||
const novelName = loadedCheerio(this).find('.book-name').text();
|
||||
const novelCover = loadedCheerio(this).find('img').attr('src');
|
||||
|
||||
let novelUrl = $(this).find('a').attr('href').slice(1);
|
||||
let novelUrl = loadedCheerio(this).find('a').attr('href').slice(1);
|
||||
|
||||
const novel = {
|
||||
sourceId: 19,
|
||||
|
||||
@@ -9,20 +9,20 @@ const popularNovels = async page => {
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novels = [];
|
||||
|
||||
$('div.col-novel-main > div.list-novel > .row').each(function (result) {
|
||||
let novelUrl = $(this)
|
||||
loadedCheerio('div.col-novel-main > div.list-novel > .row').each(function () {
|
||||
let novelUrl = loadedCheerio(this)
|
||||
.find('h3.novel-title > a')
|
||||
.attr('href')
|
||||
.replace('.html', '')
|
||||
.substring(1);
|
||||
novelUrl = `${novelUrl}/`;
|
||||
|
||||
const novelName = $(this).find('h3.novel-title > a').text();
|
||||
const novelCover = $(this).find('img').attr('src');
|
||||
const novelName = loadedCheerio(this).find('h3.novel-title > a').text();
|
||||
const novelCover = loadedCheerio(this).find('img').attr('src');
|
||||
|
||||
const novel = {
|
||||
sourceId: 4,
|
||||
@@ -43,7 +43,7 @@ const parseNovelAndChapters = async novelUrl => {
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
let loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novel = {};
|
||||
|
||||
@@ -55,54 +55,54 @@ const parseNovelAndChapters = async novelUrl => {
|
||||
|
||||
novel.novelUrl = novelUrl;
|
||||
|
||||
novel.novelName = $('div.book > img').attr('alt');
|
||||
novel.novelName = loadedCheerio('div.book > img').attr('alt');
|
||||
|
||||
novel.novelCover = $('div.book > img').attr('src');
|
||||
novel.novelCover = loadedCheerio('div.book > img').attr('src');
|
||||
|
||||
novel.summary = $('div.desc-text').text().trim();
|
||||
novel.summary = loadedCheerio('div.desc-text').text().trim();
|
||||
|
||||
novel.author = $('li > h3')
|
||||
novel.author = loadedCheerio('li > h3')
|
||||
.filter(function () {
|
||||
return $(this).text().trim() === 'Author:';
|
||||
return loadedCheerio(this).text().trim() === 'Author:';
|
||||
})
|
||||
.siblings()
|
||||
.text();
|
||||
|
||||
novel.genre = $('li')
|
||||
novel.genre = loadedCheerio('li')
|
||||
.filter(function () {
|
||||
return $(this).find('h3').text().trim() === 'Genre:';
|
||||
return loadedCheerio(this).find('h3').text().trim() === 'Genre:';
|
||||
})
|
||||
.text()
|
||||
.replace('Genre:', '');
|
||||
|
||||
novel.artist = null;
|
||||
|
||||
novel.status = $('li > h3')
|
||||
novel.status = loadedCheerio('li > h3')
|
||||
.filter(function () {
|
||||
return $(this).text().trim() === 'Status:';
|
||||
return loadedCheerio(this).text().trim() === 'Status:';
|
||||
})
|
||||
.siblings()
|
||||
.text();
|
||||
|
||||
const novelId = $('#rating').attr('data-novel-id');
|
||||
const novelId = loadedCheerio('#rating').attr('data-novel-id');
|
||||
|
||||
const getChapters = async novelId => {
|
||||
const getChapters = async id => {
|
||||
const chapterListUrl =
|
||||
'https://readnovelfull.com/ajax/chapter-archive?novelId=' + novelId;
|
||||
'https://readnovelfull.com/ajax/chapter-archive?novelId=' + id;
|
||||
|
||||
const data = await fetch(chapterListUrl);
|
||||
const chapters = await data.text();
|
||||
|
||||
$ = cheerio.load(chapters);
|
||||
loadedCheerio = cheerio.load(chapters);
|
||||
|
||||
let novelChapters = [];
|
||||
|
||||
$('.panel-body')
|
||||
loadedCheerio('.panel-body')
|
||||
.find('li')
|
||||
.each(function (result) {
|
||||
let chapterName = $(this).find('a').attr('title');
|
||||
.each(function () {
|
||||
let chapterName = loadedCheerio(this).find('a').attr('title');
|
||||
let releaseDate = null;
|
||||
let chapterUrl = $(this).find('a').attr('href');
|
||||
let chapterUrl = loadedCheerio(this).find('a').attr('href');
|
||||
chapterUrl = chapterUrl.replace(`/${novelUrl}`, '');
|
||||
|
||||
novelChapters.push({
|
||||
@@ -125,10 +125,10 @@ const parseChapter = async (novelUrl, chapterUrl) => {
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
const chapterName = $('.chr-title').attr('title');
|
||||
let chapterText = $('#chr-content').html();
|
||||
const chapterName = loadedCheerio('.chr-title').attr('title');
|
||||
let chapterText = loadedCheerio('#chr-content').html();
|
||||
const chapter = {
|
||||
sourceId: 4,
|
||||
novelUrl,
|
||||
@@ -141,27 +141,27 @@ const parseChapter = async (novelUrl, chapterUrl) => {
|
||||
};
|
||||
|
||||
const searchNovels = async searchTerm => {
|
||||
const searchUrl = `https://readnovelfull.com/search?keyword=`;
|
||||
const searchUrl = 'https://readnovelfull.com/search?keyword=';
|
||||
|
||||
const url = `${searchUrl}${searchTerm}`;
|
||||
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novels = [];
|
||||
|
||||
$('div.col-novel-main > div.list-novel > .row').each(function (result) {
|
||||
let novelUrl = $(this)
|
||||
loadedCheerio('div.col-novel-main > div.list-novel > .row').each(function () {
|
||||
let novelUrl = loadedCheerio(this)
|
||||
.find('h3.novel-title > a')
|
||||
.attr('href')
|
||||
.replace('.html', '')
|
||||
.substring(1);
|
||||
novelUrl = `${novelUrl}/`;
|
||||
|
||||
const novelName = $(this).find('h3.novel-title > a').text();
|
||||
const novelCover = $(this).find('img').attr('src');
|
||||
const novelName = loadedCheerio(this).find('h3.novel-title > a').text();
|
||||
const novelCover = loadedCheerio(this).find('img').attr('src');
|
||||
|
||||
const novel = {
|
||||
sourceId: 4,
|
||||
|
||||
+34
-25
@@ -19,18 +19,22 @@ const popularNovels = async page => {
|
||||
const result = await fetch(url, {method: 'GET', headers});
|
||||
const body = await result.text();
|
||||
|
||||
console.log(body);
|
||||
// console.log(body);
|
||||
|
||||
$ = cheerio.load(body);
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novels = [];
|
||||
|
||||
$('li.novel-item').each(function () {
|
||||
const novelName = $(this).find('h4').text();
|
||||
const novelUrl = $(this).find('a').attr('href').split('/').pop();
|
||||
loadedCheerio('li.novel-item').each(function () {
|
||||
const novelName = loadedCheerio(this).find('h4').text();
|
||||
const novelUrl = loadedCheerio(this)
|
||||
.find('a')
|
||||
.attr('href')
|
||||
.split('/')
|
||||
.pop();
|
||||
|
||||
const novelCover =
|
||||
baseUrl + $(this).find('.novel-cover > img').attr('data-src');
|
||||
baseUrl + loadedCheerio(this).find('.novel-cover > img').attr('data-src');
|
||||
|
||||
const novel = {
|
||||
sourceId,
|
||||
@@ -55,7 +59,7 @@ const parseNovelAndChapters = async novelUrl => {
|
||||
const result = await fetch(url, {method: 'GET', headers});
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novel = {
|
||||
sourceId,
|
||||
@@ -66,33 +70,34 @@ const parseNovelAndChapters = async novelUrl => {
|
||||
|
||||
novel.novelUrl = novelUrl;
|
||||
|
||||
novel.novelName = $('h1.novel-title').text();
|
||||
novel.novelName = loadedCheerio('h1.novel-title').text();
|
||||
|
||||
novel.novelCover = baseUrl + $('figure.cover > img').attr('data-src');
|
||||
novel.novelCover =
|
||||
baseUrl + loadedCheerio('figure.cover > img').attr('data-src');
|
||||
|
||||
novel.summary = $('p.description').text().trim();
|
||||
novel.summary = loadedCheerio('p.description').text().trim();
|
||||
|
||||
novel.genre = '';
|
||||
|
||||
$('div.categories > ul > li').each(function () {
|
||||
novel.genre += $(this).text().trim() + ',';
|
||||
loadedCheerio('div.categories > ul > li').each(function () {
|
||||
novel.genre += loadedCheerio(this).text().trim() + ',';
|
||||
});
|
||||
|
||||
$('div.header-stats > span').each(function () {
|
||||
if ($(this).find('small').text() === 'Status') {
|
||||
novel.status = $(this).find('strong').text();
|
||||
loadedCheerio('div.header-stats > span').each(function () {
|
||||
if (loadedCheerio(this).find('small').text() === 'Status') {
|
||||
novel.status = loadedCheerio(this).find('strong').text();
|
||||
}
|
||||
});
|
||||
|
||||
novel.genre = novel.genre.slice(0, -1);
|
||||
|
||||
novel.author = $('span[itemprop=author]').text();
|
||||
novel.author = loadedCheerio('span[itemprop=author]').text();
|
||||
|
||||
let novelChapters = [];
|
||||
|
||||
const novelId = novelUrl.split('/').pop().replace('.html', '');
|
||||
|
||||
const latestChapterNumber = $('.header-stats')
|
||||
const latestChapterNumber = loadedCheerio('.header-stats')
|
||||
.find('span > strong')
|
||||
.first()
|
||||
.text()
|
||||
@@ -124,10 +129,10 @@ const parseChapter = async (novelUrl, chapterUrl) => {
|
||||
const result = await fetch(url, {method: 'GET', headers});
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
const chapterName = $('.titles > h2').text();
|
||||
let chapterText = $('.chapter-content').html();
|
||||
const chapterName = loadedCheerio('.titles > h2').text();
|
||||
let chapterText = loadedCheerio('.chapter-content').html();
|
||||
|
||||
const chapter = {
|
||||
sourceId,
|
||||
@@ -161,14 +166,18 @@ const searchNovels = async searchTerm => {
|
||||
});
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novels = [];
|
||||
|
||||
$('li.novel-item').each(function () {
|
||||
const novelName = $(this).find('h4').text();
|
||||
const novelCover = baseUrl + $(this).find('img').attr('src');
|
||||
const novelUrl = $(this).find('a').attr('href').split('/').pop();
|
||||
loadedCheerio('li.novel-item').each(function () {
|
||||
const novelName = loadedCheerio(this).find('h4').text();
|
||||
const novelCover = baseUrl + loadedCheerio(this).find('img').attr('src');
|
||||
const novelUrl = loadedCheerio(this)
|
||||
.find('a')
|
||||
.attr('href')
|
||||
.split('/')
|
||||
.pop();
|
||||
|
||||
const novel = {
|
||||
sourceId,
|
||||
|
||||
@@ -13,15 +13,20 @@ const popularNovels = async page => {
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novels = [];
|
||||
|
||||
$('.page-item-detail').each(function (result) {
|
||||
const novelName = $(this).find('.item-summary h3').text().trim();
|
||||
const novelCover = $(this).find('.img-responsive').attr('data-src');
|
||||
loadedCheerio('.page-item-detail').each(function () {
|
||||
const novelName = loadedCheerio(this)
|
||||
.find('.item-summary h3')
|
||||
.text()
|
||||
.trim();
|
||||
const novelCover = loadedCheerio(this)
|
||||
.find('.img-responsive')
|
||||
.attr('data-src');
|
||||
|
||||
let novelUrl = $(this).find('div > a').attr('href');
|
||||
let novelUrl = loadedCheerio(this).find('div > a').attr('href');
|
||||
novelUrl = novelUrl.replace(`${baseUrl}/`, '');
|
||||
|
||||
const novel = {
|
||||
@@ -43,21 +48,24 @@ const parseNovelAndChapters = async novelUrl => {
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novel = {sourceId, url, sourceName};
|
||||
|
||||
$('.post-title > h3 > span').remove();
|
||||
loadedCheerio('.post-title > h3 > span').remove();
|
||||
|
||||
novel.novelUrl = novelUrl;
|
||||
|
||||
novel.novelName = $('.post-title > h1').text().trim();
|
||||
novel.novelName = loadedCheerio('.post-title > h1').text().trim();
|
||||
|
||||
novel.novelCover = $('.summary_image > a > img').attr('data-src');
|
||||
novel.novelCover = loadedCheerio('.summary_image > a > img').attr('data-src');
|
||||
|
||||
$('.post-content_item').each(function () {
|
||||
const detailName = $(this).find('.summary-heading > h5').text().trim();
|
||||
const detail = $(this).find('.summary-content').text().trim();
|
||||
loadedCheerio('.post-content_item').each(function () {
|
||||
const detailName = loadedCheerio(this)
|
||||
.find('.summary-heading > h5')
|
||||
.text()
|
||||
.trim();
|
||||
const detail = loadedCheerio(this).find('.summary-content').text().trim();
|
||||
|
||||
switch (detailName) {
|
||||
case 'Genre(s)':
|
||||
@@ -74,20 +82,25 @@ const parseNovelAndChapters = async novelUrl => {
|
||||
}
|
||||
});
|
||||
|
||||
$('.description-summary > div.summary__content').find('em').remove();
|
||||
$('.premium-block').remove();
|
||||
loadedCheerio('.description-summary > div.summary__content')
|
||||
.find('em')
|
||||
.remove();
|
||||
loadedCheerio('.premium-block').remove();
|
||||
|
||||
novel.summary = $('div.summary__content').text().trim();
|
||||
novel.summary = loadedCheerio('div.summary__content').text().trim();
|
||||
|
||||
let novelChapters = [];
|
||||
|
||||
$('.wp-manga-chapter').each(function (result) {
|
||||
$('i').remove();
|
||||
loadedCheerio('.wp-manga-chapter').each(function () {
|
||||
loadedCheerio('i').remove();
|
||||
|
||||
const chapterName = $(this).find('a').text().trim();
|
||||
const chapterName = loadedCheerio(this).find('a').text().trim();
|
||||
const releaseDate = null;
|
||||
|
||||
const chapterUrl = $(this).find('a').attr('href').replace(url, '');
|
||||
const chapterUrl = loadedCheerio(this)
|
||||
.find('a')
|
||||
.attr('href')
|
||||
.replace(url, '');
|
||||
|
||||
const chapter = {chapterName, releaseDate, chapterUrl};
|
||||
|
||||
@@ -105,10 +118,10 @@ const parseChapter = async (novelUrl, chapterUrl) => {
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
const chapterName = $('#chapter-heading').text();
|
||||
let chapterText = $('.reading-content').html();
|
||||
const chapterName = loadedCheerio('#chapter-heading').text();
|
||||
let chapterText = loadedCheerio('.reading-content').html();
|
||||
const chapter = {
|
||||
sourceId,
|
||||
novelUrl,
|
||||
@@ -126,15 +139,20 @@ const searchNovels = async searchTerm => {
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novels = [];
|
||||
|
||||
$('.c-tabs-item__content').each(function (result) {
|
||||
const novelName = $(this).find('.post-title > h3').text().trim();
|
||||
const novelCover = $(this).find('div > div > a > img').attr('data-src');
|
||||
loadedCheerio('.c-tabs-item__content').each(function () {
|
||||
const novelName = loadedCheerio(this)
|
||||
.find('.post-title > h3')
|
||||
.text()
|
||||
.trim();
|
||||
const novelCover = loadedCheerio(this)
|
||||
.find('div > div > a > img')
|
||||
.attr('data-src');
|
||||
|
||||
let novelUrl = $(this).find('div > div > a').attr('href');
|
||||
let novelUrl = loadedCheerio(this).find('div > div > a').attr('href');
|
||||
novelUrl = novelUrl.replace(`${baseUrl}/`, '');
|
||||
|
||||
const novel = {
|
||||
|
||||
+37
-24
@@ -12,19 +12,22 @@ const popularNovels = async page => {
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novels = [];
|
||||
|
||||
$('div.fiction-list-item.row').each(function () {
|
||||
const novelName = $(this).find('h2.fiction-title').text().trim();
|
||||
let novelCover = $(this).find('img').attr('src');
|
||||
loadedCheerio('div.fiction-list-item.row').each(function () {
|
||||
const novelName = loadedCheerio(this)
|
||||
.find('h2.fiction-title')
|
||||
.text()
|
||||
.trim();
|
||||
let novelCover = loadedCheerio(this).find('img').attr('src');
|
||||
|
||||
if (novelCover === '/Content/Images/nocover-new-min.png') {
|
||||
novelCover =
|
||||
'https://github.com/LNReader/lnreader-sources/blob/main/src/coverNotAvailable.jpg?raw=true';
|
||||
}
|
||||
let novelUrl = $(this)
|
||||
let novelUrl = loadedCheerio(this)
|
||||
.find('h2.fiction-title > a')
|
||||
.attr('href')
|
||||
.replace('/fiction/', '');
|
||||
@@ -48,7 +51,7 @@ const parseNovelAndChapters = async novelUrl => {
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novel = {};
|
||||
|
||||
@@ -60,10 +63,10 @@ const parseNovelAndChapters = async novelUrl => {
|
||||
|
||||
novel.novelUrl = novelUrl;
|
||||
|
||||
novelName = $('h1').text();
|
||||
let novelName = loadedCheerio('h1').text();
|
||||
novel.novelName = novelName;
|
||||
|
||||
let novelCover = $('img.thumbnail').attr('src');
|
||||
let novelCover = loadedCheerio('img.thumbnail').attr('src');
|
||||
|
||||
if (novelCover === '/Content/Images/nocover-new-min.png') {
|
||||
novelCover =
|
||||
@@ -72,12 +75,14 @@ const parseNovelAndChapters = async novelUrl => {
|
||||
|
||||
novel.novelCover = novelCover;
|
||||
|
||||
novel.summary = $('div.description').text().trim();
|
||||
novel.summary = loadedCheerio('div.description').text().trim();
|
||||
|
||||
novel.author = $('h1').next().text().replace('by ', '').trim();
|
||||
novel.genre = $('span.tags').text().trim().replace(/\n\s+/g, ',');
|
||||
novel.author = loadedCheerio('h1').next().text().replace('by ', '').trim();
|
||||
novel.genre = loadedCheerio('span.tags').text().trim().replace(/\n\s+/g, ',');
|
||||
novel.status =
|
||||
$('div.fiction-info > div.portlet > .col-md-8 > .margin-bottom-10 > span')
|
||||
loadedCheerio(
|
||||
'div.fiction-info > div.portlet > .col-md-8 > .margin-bottom-10 > span',
|
||||
)
|
||||
.first()
|
||||
.next()
|
||||
.text()
|
||||
@@ -87,14 +92,19 @@ const parseNovelAndChapters = async novelUrl => {
|
||||
|
||||
let novelChapters = [];
|
||||
|
||||
$('table#chapters > tbody')
|
||||
loadedCheerio('table#chapters > tbody')
|
||||
.find('tr')
|
||||
.each(function () {
|
||||
const chapterName = $(this).find('td').first().text().trim();
|
||||
let releaseDate = $(this).find('td').first().next().text().trim();
|
||||
const chapterName = loadedCheerio(this).find('td').first().text().trim();
|
||||
let releaseDate = loadedCheerio(this)
|
||||
.find('td')
|
||||
.first()
|
||||
.next()
|
||||
.text()
|
||||
.trim();
|
||||
releaseDate = releaseDate && parseMadaraDate(releaseDate);
|
||||
|
||||
const chapterUrl = $(this)
|
||||
const chapterUrl = loadedCheerio(this)
|
||||
.find('td')
|
||||
.first()
|
||||
.find('a')
|
||||
@@ -119,11 +129,11 @@ const parseChapter = async (novelUrl, chapterUrl) => {
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
let chapterName = $('div.chapter-content').find('strong').text();
|
||||
let chapterName = loadedCheerio('div.chapter-content').find('strong').text();
|
||||
|
||||
let chapterText = $('div.chapter-content').html();
|
||||
let chapterText = loadedCheerio('div.chapter-content').html();
|
||||
|
||||
const chapter = {
|
||||
sourceId: 34,
|
||||
@@ -142,19 +152,22 @@ const searchNovels = async searchTerm => {
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novels = [];
|
||||
|
||||
$('div.fiction-list-item.row').each(function () {
|
||||
const novelName = $(this).find('h2.fiction-title').text().trim();
|
||||
let novelCover = $(this).find('img').attr('src');
|
||||
loadedCheerio('div.fiction-list-item.row').each(function () {
|
||||
const novelName = loadedCheerio(this)
|
||||
.find('h2.fiction-title')
|
||||
.text()
|
||||
.trim();
|
||||
let novelCover = loadedCheerio(this).find('img').attr('src');
|
||||
|
||||
if (novelCover.includes('Content')) {
|
||||
novelCover = baseUrl + novelCover;
|
||||
}
|
||||
|
||||
let novelUrl = $(this)
|
||||
let novelUrl = loadedCheerio(this)
|
||||
.find('h2.fiction-title > a')
|
||||
.attr('href')
|
||||
.replace('/fiction/', '');
|
||||
|
||||
@@ -9,15 +9,19 @@ const popularNovels = async page => {
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novels = [];
|
||||
|
||||
$('div.search_main_box').each(function (result) {
|
||||
const novelName = $(this).find('div.search_title > a').text();
|
||||
const novelCover = $(this).find('div.search_img > img').attr('src');
|
||||
loadedCheerio('div.search_main_box').each(function () {
|
||||
const novelName = loadedCheerio(this).find('div.search_title > a').text();
|
||||
const novelCover = loadedCheerio(this)
|
||||
.find('div.search_img > img')
|
||||
.attr('src');
|
||||
|
||||
let novelUrl = $(this).find('div.search_title > a').attr('href');
|
||||
let novelUrl = loadedCheerio(this)
|
||||
.find('div.search_title > a')
|
||||
.attr('href');
|
||||
novelUrl = novelUrl.split('/');
|
||||
novelUrl = novelUrl[4] + '-' + novelUrl[5];
|
||||
|
||||
@@ -40,7 +44,7 @@ const parseNovelAndChapters = async novelUrl => {
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
let loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novel = {};
|
||||
|
||||
@@ -52,27 +56,30 @@ const parseNovelAndChapters = async novelUrl => {
|
||||
|
||||
novel.novelUrl = novelUrl;
|
||||
|
||||
novel.novelName = $('div.fic_title').text();
|
||||
novel.novelName = loadedCheerio('div.fic_title').text();
|
||||
|
||||
novel.novelCover = $('div.fic_image > img').attr('src');
|
||||
novel.novelCover = loadedCheerio('div.fic_image > img').attr('src');
|
||||
|
||||
novel.summary = $('div.wi_fic_desc').text();
|
||||
novel.summary = loadedCheerio('div.wi_fic_desc').text();
|
||||
|
||||
novel.genre = '';
|
||||
$('span.wi_fic_genre')
|
||||
loadedCheerio('span.wi_fic_genre')
|
||||
.find('span')
|
||||
.each(function (res) {
|
||||
novel.genre += $(this).text() + ',';
|
||||
novel.genre += loadedCheerio(this).text() + ',';
|
||||
});
|
||||
if (novel.genre) {
|
||||
novel.genre = novel.genre.slice(0, -1);
|
||||
}
|
||||
|
||||
novel.status = $('span.rnd_stats').next().text().includes('Ongoing')
|
||||
novel.status = loadedCheerio('span.rnd_stats')
|
||||
.next()
|
||||
.text()
|
||||
.includes('Ongoing')
|
||||
? 'Ongoing'
|
||||
: 'Completed';
|
||||
|
||||
novel.author = $('span.auth_name_fic').text();
|
||||
novel.author = loadedCheerio('span.auth_name_fic').text();
|
||||
|
||||
let formData = new FormData();
|
||||
formData.append('action', 'wi_getreleases_pagination');
|
||||
@@ -88,15 +95,15 @@ const parseNovelAndChapters = async novelUrl => {
|
||||
);
|
||||
const text = await data.text();
|
||||
|
||||
$ = cheerio.load(text);
|
||||
loadedCheerio = cheerio.load(text);
|
||||
|
||||
let novelChapters = [];
|
||||
|
||||
$('.toc_w').each(function (result) {
|
||||
const chapterName = $(this).find('.toc_a').text();
|
||||
const releaseDate = $(this).find('.fic_date_pub').text();
|
||||
loadedCheerio('.toc_w').each(function () {
|
||||
const chapterName = loadedCheerio(this).find('.toc_a').text();
|
||||
const releaseDate = loadedCheerio(this).find('.fic_date_pub').text();
|
||||
|
||||
const chapterUrl = $(this).find('a').attr('href').split('/')[6];
|
||||
const chapterUrl = loadedCheerio(this).find('a').attr('href').split('/')[6];
|
||||
// .replace("/novel/" + novelUrl + "/", "");
|
||||
|
||||
novelChapters.push({
|
||||
@@ -117,11 +124,11 @@ const parseChapter = async (novelUrl, chapterUrl) => {
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
let chapterName = $('div.chapter-title').text();
|
||||
let chapterName = loadedCheerio('div.chapter-title').text();
|
||||
|
||||
let chapterText = $('div.chp_raw').html();
|
||||
let chapterText = loadedCheerio('div.chp_raw').html();
|
||||
const chapter = {
|
||||
sourceId: 35,
|
||||
novelUrl,
|
||||
@@ -140,15 +147,19 @@ const searchNovels = async searchTerm => {
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novels = [];
|
||||
|
||||
$('div.search_main_box').each(function (result) {
|
||||
const novelName = $(this).find('div.search_title > a').text();
|
||||
const novelCover = $(this).find('div.search_img > img').attr('src');
|
||||
loadedCheerio('div.search_main_box').each(function () {
|
||||
const novelName = loadedCheerio(this).find('div.search_title > a').text();
|
||||
const novelCover = loadedCheerio(this)
|
||||
.find('div.search_img > img')
|
||||
.attr('src');
|
||||
|
||||
let novelUrl = $(this).find('div.search_title > a').attr('href');
|
||||
let novelUrl = loadedCheerio(this)
|
||||
.find('div.search_title > a')
|
||||
.attr('href');
|
||||
novelUrl = novelUrl.split('/');
|
||||
novelUrl = novelUrl[4] + '-' + novelUrl[5];
|
||||
|
||||
|
||||
+17
-17
@@ -2,10 +2,10 @@ import cheerio from 'react-native-cheerio';
|
||||
|
||||
const baseUrl = 'http://www.tapread.com';
|
||||
|
||||
let headers = new Headers({
|
||||
'User-Agent':
|
||||
"'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.116 Safari/537.36",
|
||||
});
|
||||
// let headers = new Headers({
|
||||
// 'User-Agent':
|
||||
// "'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.116 Safari/537.36",
|
||||
// });
|
||||
|
||||
const popularNovels = async page => {
|
||||
let totalPages = 0;
|
||||
@@ -13,14 +13,14 @@ const popularNovels = async page => {
|
||||
const result = await fetch(baseUrl);
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novels = [];
|
||||
|
||||
$('.section-item[data-classify="1"]').each(function (result) {
|
||||
const novelName = $(this).find('.book-name').text();
|
||||
const novelCover = 'http:' + $(this).find('img').attr('src');
|
||||
let novelUrl = $(this).attr('data-id');
|
||||
loadedCheerio('.section-item[data-classify="1"]').each(function () {
|
||||
const novelName = loadedCheerio(this).find('.book-name').text();
|
||||
const novelCover = 'http:' + loadedCheerio(this).find('img').attr('src');
|
||||
let novelUrl = loadedCheerio(this).attr('data-id');
|
||||
|
||||
const novel = {
|
||||
sourceId: 17,
|
||||
@@ -38,12 +38,12 @@ const popularNovels = async page => {
|
||||
const parseNovelAndChapters = async novelUrl => {
|
||||
const url = `${baseUrl}/book/detail/${novelUrl}`;
|
||||
|
||||
console.log(url);
|
||||
// console.log(url);
|
||||
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novel = {};
|
||||
|
||||
@@ -55,17 +55,17 @@ const parseNovelAndChapters = async novelUrl => {
|
||||
|
||||
novel.novelUrl = novelUrl;
|
||||
|
||||
novel.novelName = $('.book-name').text();
|
||||
novel.novelName = loadedCheerio('.book-name').text();
|
||||
|
||||
novel.novelCover = 'http:' + $('div.book-img > img').attr('src');
|
||||
novel.novelCover = 'http:' + loadedCheerio('div.book-img > img').attr('src');
|
||||
|
||||
novel.genre = $('div.book-catalog > span.txt').text();
|
||||
novel.genre = loadedCheerio('div.book-catalog > span.txt').text();
|
||||
|
||||
novel.status = $('div.book-state > span.txt').text();
|
||||
novel.status = loadedCheerio('div.book-state > span.txt').text();
|
||||
|
||||
novel.author = $('div.author > span.name').text();
|
||||
novel.author = loadedCheerio('div.author > span.name').text();
|
||||
|
||||
novel.summary = $('div.content > p.desc').text();
|
||||
novel.summary = loadedCheerio('div.content > p.desc').text();
|
||||
|
||||
const getChapters = async novelId => {
|
||||
const chapterListUrl = 'http://www.tapread.com/ajax/book/contents';
|
||||
|
||||
@@ -18,14 +18,15 @@ const popularNovels = async page => {
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novels = [];
|
||||
|
||||
$('.group').each(function () {
|
||||
const novelName = $(this).find('h3').text();
|
||||
const novelCover = 'https://' + $(this).find('img').attr('data-src');
|
||||
const novelUrl = $(this).find(' a').attr('href');
|
||||
loadedCheerio('.group').each(function () {
|
||||
const novelName = loadedCheerio(this).find('h3').text();
|
||||
const novelCover =
|
||||
'https://' + loadedCheerio(this).find('img').attr('data-src');
|
||||
const novelUrl = loadedCheerio(this).find(' a').attr('href');
|
||||
|
||||
const novel = {
|
||||
sourceId,
|
||||
@@ -46,41 +47,48 @@ const parseNovelAndChapters = async novelUrl => {
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novel = {sourceId, sourceName, url, novelUrl};
|
||||
|
||||
novel.novelName = $('h1').text().trim();
|
||||
novel.novelName = loadedCheerio('h1').text().trim();
|
||||
|
||||
novel.novelCover = 'https://' + $('img.object-cover').attr('data-src');
|
||||
novel.novelCover =
|
||||
'https://' + loadedCheerio('img.object-cover').attr('data-src');
|
||||
|
||||
novel.summary = $('div[property=description]').text().trim();
|
||||
novel.summary = loadedCheerio('div[property=description]').text().trim();
|
||||
|
||||
novel.genre = '';
|
||||
|
||||
$('div.flex.flex-col.mt-3.text-center > ul > li').each(function () {
|
||||
novel.genre +=
|
||||
$(this)
|
||||
.text()
|
||||
.replace(/[\t\n]/g, '') + ',';
|
||||
});
|
||||
$('div.header-stats > span').each(function () {
|
||||
if ($(this).find('small').text() === 'Status') {
|
||||
novel.status = $(this).find('strong').text();
|
||||
loadedCheerio('div.flex.flex-col.mt-3.text-center > ul > li').each(
|
||||
function () {
|
||||
novel.genre +=
|
||||
loadedCheerio(this)
|
||||
.text()
|
||||
.replace(/[\t\n]/g, '') + ',';
|
||||
},
|
||||
);
|
||||
loadedCheerio('div.header-stats > span').each(function () {
|
||||
if (loadedCheerio(this).find('small').text() === 'Status') {
|
||||
novel.status = loadedCheerio(this).find('strong').text();
|
||||
}
|
||||
});
|
||||
|
||||
novel.genre = novel.genre.slice(0, -1);
|
||||
|
||||
novel.author = $('.author > a > span').text();
|
||||
novel.author = loadedCheerio('.author > a > span').text();
|
||||
let novelChapters = [];
|
||||
|
||||
$('.tab_content > ul.grid')
|
||||
loadedCheerio('.tab_content > ul.grid')
|
||||
.find('li')
|
||||
.each(function () {
|
||||
const chapterName = $(this).find('span').first().text().trim();
|
||||
const chapterName = loadedCheerio(this)
|
||||
.find('span')
|
||||
.first()
|
||||
.text()
|
||||
.trim();
|
||||
const releaseDate = null;
|
||||
const chapterUrl = $(this).find('a').attr('href');
|
||||
const chapterUrl = loadedCheerio(this).find('a').attr('href');
|
||||
|
||||
novelChapters.push({chapterName, releaseDate, chapterUrl});
|
||||
});
|
||||
@@ -94,9 +102,9 @@ const parseChapter = async (novelUrl, chapterUrl) => {
|
||||
const result = await fetch(chapterUrl);
|
||||
let body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
const chapterId = $('input[name=id]').attr('value');
|
||||
const chapterId = loadedCheerio('input[name=id]').attr('value');
|
||||
|
||||
const url = 'https://travistranslations.com/wp-json/wp/v2/posts/' + chapterId;
|
||||
|
||||
@@ -123,14 +131,15 @@ const searchNovels = async searchTerm => {
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novels = [];
|
||||
|
||||
$('.group').each(function () {
|
||||
const novelName = $(this).find('h3').text();
|
||||
const novelCover = 'https://' + $(this).find('img').attr('data-src');
|
||||
const novelUrl = $(this).find(' a').attr('href');
|
||||
loadedCheerio('.group').each(function () {
|
||||
const novelName = loadedCheerio(this).find('h3').text();
|
||||
const novelCover =
|
||||
'https://' + loadedCheerio(this).find('img').attr('data-src');
|
||||
const novelUrl = loadedCheerio(this).find(' a').attr('href');
|
||||
|
||||
const novel = {
|
||||
sourceId,
|
||||
|
||||
+34
-29
@@ -9,15 +9,15 @@ const popularNovels = async page => {
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novels = [];
|
||||
|
||||
$('.page-item-detail').each(function (result) {
|
||||
const novelName = $(this).find('.h5 > a').text();
|
||||
const novelCover = $(this).find('img').attr('src');
|
||||
loadedCheerio('.page-item-detail').each(function () {
|
||||
const novelName = loadedCheerio(this).find('.h5 > a').text();
|
||||
const novelCover = loadedCheerio(this).find('img').attr('src');
|
||||
|
||||
let novelUrl = $(this).find('.h5 > a').attr('href');
|
||||
let novelUrl = loadedCheerio(this).find('.h5 > a').attr('href');
|
||||
novelUrl = novelUrl.replace(`${baseUrl}vipnovel/`, '');
|
||||
|
||||
const novel = {
|
||||
@@ -36,12 +36,12 @@ const popularNovels = async page => {
|
||||
const parseNovelAndChapters = async novelUrl => {
|
||||
const url = `${baseUrl}vipnovel/${novelUrl}`;
|
||||
|
||||
console.log(url);
|
||||
// console.log(url);
|
||||
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novel = {};
|
||||
|
||||
@@ -53,19 +53,19 @@ const parseNovelAndChapters = async novelUrl => {
|
||||
|
||||
novel.novelUrl = novelUrl;
|
||||
|
||||
novel.novelName = $('.post-title > h3')
|
||||
novel.novelName = loadedCheerio('.post-title > h3')
|
||||
.text()
|
||||
.replace(/[\t\n]/g, '')
|
||||
.trim();
|
||||
|
||||
novel.novelCover = $('.summary_image > a > img').attr('src');
|
||||
$('.post-content_item').each(function (result) {
|
||||
detailName = $(this)
|
||||
novel.novelCover = loadedCheerio('.summary_image > a > img').attr('src');
|
||||
loadedCheerio('.post-content_item').each(function () {
|
||||
let detailName = loadedCheerio(this)
|
||||
.find('.summary-heading > h5')
|
||||
.text()
|
||||
.replace(/[\t\n]/g, '')
|
||||
.trim();
|
||||
detail = $(this)
|
||||
let detail = loadedCheerio(this)
|
||||
.find('.summary-content')
|
||||
.text()
|
||||
.replace(/[\t\n]/g, '')
|
||||
@@ -84,9 +84,11 @@ const parseNovelAndChapters = async novelUrl => {
|
||||
}
|
||||
});
|
||||
|
||||
$('.summary__content > p').first().remove();
|
||||
loadedCheerio('.summary__content > p').first().remove();
|
||||
|
||||
let novelSummary = $('.description-summary > div.summary__content')
|
||||
let novelSummary = loadedCheerio(
|
||||
'.description-summary > div.summary__content',
|
||||
)
|
||||
.text()
|
||||
.replace('Synopsis', '');
|
||||
|
||||
@@ -94,24 +96,27 @@ const parseNovelAndChapters = async novelUrl => {
|
||||
|
||||
let novelChapters = [];
|
||||
|
||||
$('.wp-manga-chapter').each(function (result) {
|
||||
const chapterName = $(this)
|
||||
loadedCheerio('.wp-manga-chapter').each(function () {
|
||||
const chapterName = loadedCheerio(this)
|
||||
.find('a')
|
||||
.text()
|
||||
.replace(/[\t\n]/g, '')
|
||||
.trim();
|
||||
|
||||
const releaseDate = $(this)
|
||||
const releaseDate = loadedCheerio(this)
|
||||
.find('span')
|
||||
.text()
|
||||
.replace(/[\t\n]/g, '')
|
||||
.trim();
|
||||
|
||||
const chapterUrl = $(this).find('a').attr('href').replace(url, '');
|
||||
const chapterUrl = loadedCheerio(this)
|
||||
.find('a')
|
||||
.attr('href')
|
||||
.replace(url, '');
|
||||
|
||||
const chapter = {chapterName, releaseDate, chapterUrl};
|
||||
|
||||
console.log(chapterUrl);
|
||||
// console.log(chapterUrl);
|
||||
|
||||
novelChapters.push(chapter);
|
||||
});
|
||||
@@ -124,20 +129,20 @@ const parseNovelAndChapters = async novelUrl => {
|
||||
const parseChapter = async (novelUrl, chapterUrl) => {
|
||||
const url = baseUrl + 'vipnovel/' + novelUrl + chapterUrl;
|
||||
|
||||
console.log(url);
|
||||
// console.log(url);
|
||||
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
let chapterName = $('.text-center').text();
|
||||
let chapterName = loadedCheerio('.text-center').text();
|
||||
|
||||
if (!chapterName) {
|
||||
chapterName = $('.text-left > div> h3').text();
|
||||
chapterName = loadedCheerio('.text-left > div> h3').text();
|
||||
}
|
||||
|
||||
let chapterText = $('.text-left').html();
|
||||
let chapterText = loadedCheerio('.text-left').html();
|
||||
const chapter = {
|
||||
sourceId: 10,
|
||||
novelUrl,
|
||||
@@ -155,15 +160,15 @@ const searchNovels = async searchTerm => {
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novels = [];
|
||||
|
||||
$('.c-tabs-item__content').each(function (result) {
|
||||
const novelName = $(this).find('h4 > a').text();
|
||||
const novelCover = $(this).find('img').attr('src');
|
||||
loadedCheerio('.c-tabs-item__content').each(function () {
|
||||
const novelName = loadedCheerio(this).find('h4 > a').text();
|
||||
const novelCover = loadedCheerio(this).find('img').attr('src');
|
||||
|
||||
let novelUrl = $(this).find('h4 > a').attr('href');
|
||||
let novelUrl = loadedCheerio(this).find('h4 > a').attr('href');
|
||||
novelUrl = novelUrl.replace(`${baseUrl}vipnovel/`, '');
|
||||
|
||||
const novel = {
|
||||
|
||||
@@ -23,19 +23,20 @@ const popularNovels = async page => {
|
||||
});
|
||||
const body = await result.text();
|
||||
|
||||
const $ = cheerio.load(body);
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
const novels = [];
|
||||
|
||||
$('table').find('tr').first().remove();
|
||||
loadedCheerio('table').find('tr').first().remove();
|
||||
|
||||
$('tr').each(function (res) {
|
||||
loadedCheerio('tr').each(function (res) {
|
||||
const novelCover =
|
||||
'https://github.com/LNReader/lnreader-sources/blob/main/src/coverNotAvailable.jpg?raw=true';
|
||||
|
||||
const novelName = $(this).find('td > a').text();
|
||||
const novelName = loadedCheerio(this).find('td > a').text();
|
||||
const novelUrl =
|
||||
'https://www.wlnupdates.com' + $(this).find('td > a').attr('href');
|
||||
'https://www.wlnupdates.com' +
|
||||
loadedCheerio(this).find('td > a').attr('href');
|
||||
|
||||
const novel = {
|
||||
sourceId,
|
||||
@@ -59,7 +60,7 @@ const parseNovelAndChapters = async novelUrl => {
|
||||
});
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novel = {
|
||||
sourceId,
|
||||
@@ -68,47 +69,53 @@ const parseNovelAndChapters = async novelUrl => {
|
||||
novelUrl,
|
||||
};
|
||||
|
||||
novel.novelName = $('h2').text();
|
||||
novel.novelName = loadedCheerio('h2').text();
|
||||
|
||||
novel.novelCover =
|
||||
'https://github.com/LNReader/lnreader-sources/blob/main/src/coverNotAvailable.jpg?raw=true';
|
||||
|
||||
novel.author = $('.multiitem#author')
|
||||
novel.author = loadedCheerio('.multiitem#author')
|
||||
.text()
|
||||
.trim()
|
||||
.replace(/[\t\n]/g, '');
|
||||
|
||||
novel.genre = $('.multiitem#genre')
|
||||
novel.genre = loadedCheerio('.multiitem#genre')
|
||||
.text()
|
||||
.trim()
|
||||
.replace(/[\t\n]/g, '');
|
||||
|
||||
novel.status = Status.UNKNOWN;
|
||||
|
||||
let summary = $('#description').text().trim();
|
||||
let summary = loadedCheerio('#description').text().trim();
|
||||
|
||||
novel.summary = summary;
|
||||
|
||||
let novelChapters = [];
|
||||
|
||||
$('#release-entry').each(function () {
|
||||
loadedCheerio('#release-entry').each(function () {
|
||||
let chapterName;
|
||||
|
||||
if ($(this).find('td.numeric').length > 1) {
|
||||
if (loadedCheerio(this).find('td.numeric').length > 1) {
|
||||
chapterName =
|
||||
'Volume ' +
|
||||
$(this).find(' td:nth-child(3)').text().trim() +
|
||||
loadedCheerio(this).find(' td:nth-child(3)').text().trim() +
|
||||
' Chapter ' +
|
||||
$(this).find(' td:nth-child(4)').text().trim();
|
||||
} else if ($(this).find('td.numeric').length > 0) {
|
||||
chapterName = 'Chapter ' + $(this).find('td.numeric').text().trim();
|
||||
loadedCheerio(this).find(' td:nth-child(4)').text().trim();
|
||||
} else if (loadedCheerio(this).find('td.numeric').length > 0) {
|
||||
chapterName =
|
||||
'Chapter ' + loadedCheerio(this).find('td.numeric').text().trim();
|
||||
} else {
|
||||
chapterName = $(this).find('td.postfix').text().trim();
|
||||
chapterName = loadedCheerio(this).find('td.postfix').text().trim();
|
||||
}
|
||||
|
||||
const releaseDate = $(this).find('.release-entry-cell').text().trim();
|
||||
const releaseDate = loadedCheerio(this)
|
||||
.find('.release-entry-cell')
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
const chapterUrl = $(this).find('td:nth-child(1) > a').attr('href');
|
||||
const chapterUrl = loadedCheerio(this)
|
||||
.find('td:nth-child(1) > a')
|
||||
.attr('href');
|
||||
|
||||
novelChapters.push({chapterName, releaseDate, chapterUrl});
|
||||
});
|
||||
@@ -144,16 +151,17 @@ const searchNovels = async searchTerm => {
|
||||
});
|
||||
const body = await res.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novels = [];
|
||||
|
||||
$('tr').each(function (res) {
|
||||
loadedCheerio('tr').each(function () {
|
||||
const novelCover =
|
||||
'https://github.com/LNReader/lnreader-sources/blob/main/src/coverNotAvailable.jpg?raw=true';
|
||||
const novelName = $(this).find('td > a').text();
|
||||
const novelName = loadedCheerio(this).find('td > a').text();
|
||||
const novelUrl =
|
||||
'https://www.wlnupdates.com' + $(this).find('td > a').attr('href');
|
||||
'https://www.wlnupdates.com' +
|
||||
loadedCheerio(this).find('td > a').attr('href');
|
||||
|
||||
const novel = {
|
||||
sourceId,
|
||||
|
||||
+38
-26
@@ -9,15 +9,15 @@ const popularNovels = async page => {
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
|
||||
const $ = cheerio.load(body);
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novels = [];
|
||||
|
||||
$('.page-item-detail').each(function () {
|
||||
const novelName = $(this).find('.h5 > a').text();
|
||||
const novelCover = $(this).find('img').attr('data-src');
|
||||
loadedCheerio('.page-item-detail').each(function () {
|
||||
const novelName = loadedCheerio(this).find('.h5 > a').text();
|
||||
const novelCover = loadedCheerio(this).find('img').attr('data-src');
|
||||
|
||||
let novelUrl = $(this).find('.h5 > a').attr('href');
|
||||
let novelUrl = loadedCheerio(this).find('.h5 > a').attr('href');
|
||||
novelUrl = novelUrl.replace(baseUrl + 'series/', '');
|
||||
|
||||
const novel = {
|
||||
@@ -39,7 +39,7 @@ const parseNovelAndChapters = async novelUrl => {
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
|
||||
let $ = cheerio.load(body);
|
||||
let loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novel = {};
|
||||
|
||||
@@ -51,16 +51,19 @@ const parseNovelAndChapters = async novelUrl => {
|
||||
|
||||
novel.novelUrl = novelUrl;
|
||||
|
||||
novel.novelName = $('.post-title > h1')
|
||||
novel.novelName = loadedCheerio('.post-title > h1')
|
||||
.text()
|
||||
.replace(/[\t\n]/g, '')
|
||||
.trim();
|
||||
|
||||
novel.novelCover = $('.summary_image > a > img').attr('data-src');
|
||||
novel.novelCover = loadedCheerio('.summary_image > a > img').attr('data-src');
|
||||
|
||||
$('.post-content_item').each(function () {
|
||||
const detailName = $(this).find('.summary-heading > h5').text().trim();
|
||||
const detail = $(this).find('.summary-content').text().trim();
|
||||
loadedCheerio('.post-content_item').each(function () {
|
||||
const detailName = loadedCheerio(this)
|
||||
.find('.summary-heading > h5')
|
||||
.text()
|
||||
.trim();
|
||||
const detail = loadedCheerio(this).find('.summary-content').text().trim();
|
||||
|
||||
switch (detailName) {
|
||||
case 'Genre(s)':
|
||||
@@ -74,9 +77,11 @@ const parseNovelAndChapters = async novelUrl => {
|
||||
break;
|
||||
}
|
||||
});
|
||||
$('.description-summary > div.summary__content').find('em').remove();
|
||||
loadedCheerio('.description-summary > div.summary__content')
|
||||
.find('em')
|
||||
.remove();
|
||||
|
||||
novel.summary = $('.description-summary > div.summary__content')
|
||||
novel.summary = loadedCheerio('.description-summary > div.summary__content')
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
@@ -86,12 +91,19 @@ const parseNovelAndChapters = async novelUrl => {
|
||||
const data = await fetch(`${url}ajax/chapters/`, {method: 'POST'});
|
||||
const text = await data.text();
|
||||
|
||||
$ = cheerio.load(text);
|
||||
loadedCheerio = cheerio.load(text);
|
||||
|
||||
$('.wp-manga-chapter.free-chap').each(function () {
|
||||
const chapterName = $(this).find('a').text().trim();
|
||||
const releaseDate = $(this).find('span').text().replace('Free', '').trim();
|
||||
const chapterUrl = $(this).find('a').attr('href').replace(url, '');
|
||||
loadedCheerio('.wp-manga-chapter.free-chap').each(function () {
|
||||
const chapterName = loadedCheerio(this).find('a').text().trim();
|
||||
const releaseDate = loadedCheerio(this)
|
||||
.find('span')
|
||||
.text()
|
||||
.replace('Free', '')
|
||||
.trim();
|
||||
const chapterUrl = loadedCheerio(this)
|
||||
.find('a')
|
||||
.attr('href')
|
||||
.replace(url, '');
|
||||
|
||||
novelChapters.push({chapterName, releaseDate, chapterUrl});
|
||||
});
|
||||
@@ -107,11 +119,11 @@ const parseChapter = async (novelUrl, chapterUrl) => {
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
|
||||
const $ = cheerio.load(body);
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
const chapterName = $('h1#chapter-heading').text();
|
||||
const chapterName = loadedCheerio('h1#chapter-heading').text();
|
||||
|
||||
let chapterText = $('.reading-content').html();
|
||||
let chapterText = loadedCheerio('.reading-content').html();
|
||||
|
||||
const chapter = {
|
||||
sourceId: 21,
|
||||
@@ -130,15 +142,15 @@ const searchNovels = async searchTerm => {
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
|
||||
const $ = cheerio.load(body);
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novels = [];
|
||||
|
||||
$('.c-tabs-item__content').each(function () {
|
||||
const novelName = $(this).find('.h4 > a').text();
|
||||
const novelCover = $(this).find('img').attr('src');
|
||||
loadedCheerio('.c-tabs-item__content').each(function () {
|
||||
const novelName = loadedCheerio(this).find('.h4 > a').text();
|
||||
const novelCover = loadedCheerio(this).find('img').attr('src');
|
||||
|
||||
let novelUrl = $(this).find('.h4 > a').attr('href');
|
||||
let novelUrl = loadedCheerio(this).find('.h4 > a').attr('href');
|
||||
novelUrl = novelUrl.replace(`${baseUrl}series/`, '');
|
||||
|
||||
const novel = {
|
||||
|
||||
+38
-30
@@ -13,21 +13,21 @@ const popularNovels = async page => {
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novels = [];
|
||||
|
||||
$('div.panel-body > table')
|
||||
loadedCheerio('div.panel-body > table')
|
||||
.find('tr')
|
||||
.each(function () {
|
||||
const novelName = $(this).find('td.novel').text();
|
||||
const novelName = loadedCheerio(this).find('td.novel').text();
|
||||
|
||||
if (novelName) {
|
||||
const novelId = $(this).find('td:nth-child(1)').text();
|
||||
const novelId = loadedCheerio(this).find('td:nth-child(1)').text();
|
||||
|
||||
const novelCover = baseUrl + '/data/image/' + novelId + '.jpg';
|
||||
|
||||
let novelUrl = $(this)
|
||||
let novelUrl = loadedCheerio(this)
|
||||
.find('td.novel > a')
|
||||
.attr('href')
|
||||
.replace('/novel/', '');
|
||||
@@ -52,7 +52,7 @@ const parseNovelAndChapters = async novelUrl => {
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
let loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novel = {
|
||||
sourceId,
|
||||
@@ -61,31 +61,39 @@ const parseNovelAndChapters = async novelUrl => {
|
||||
novelUrl,
|
||||
};
|
||||
|
||||
novel.novelName = $(
|
||||
novel.novelName = loadedCheerio(
|
||||
'body > div.container-fluid.text-center > div.row.content > div.col-sm-8.text-left > div:nth-child(6) > div.panel-heading.clearfix > h4',
|
||||
).text();
|
||||
|
||||
novel.novelCover = $('img[itemprop="image"]').attr('src');
|
||||
novel.novelCover = loadedCheerio('img[itemprop="image"]').attr('src');
|
||||
|
||||
novel.author = $(
|
||||
novel.author = loadedCheerio(
|
||||
'div.col-md-6 > div > div:nth-child(2) > div > div:nth-child(2) > a',
|
||||
).text();
|
||||
|
||||
novel.genre = $('div.row > div.col-md-6 > div > a:nth-child(4)').text();
|
||||
novel.genre = loadedCheerio(
|
||||
'div.row > div.col-md-6 > div > a:nth-child(4)',
|
||||
).text();
|
||||
|
||||
novel.summary = $('div[itemprop="description"]').find('p').text().trim();
|
||||
novel.summary = loadedCheerio('div[itemprop="description"]')
|
||||
.find('p')
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
let novelChapters = [];
|
||||
|
||||
$('table#chplist > #chapters > tr').each(function () {
|
||||
const chapterName = $(this).find('a').text();
|
||||
loadedCheerio('table#chplist > #chapters > tr').each(function () {
|
||||
const chapterName = loadedCheerio(this).find('a').text();
|
||||
|
||||
const releaseDate = $(this)
|
||||
const releaseDate = loadedCheerio(this)
|
||||
.find('td:nth-child(2)')
|
||||
.text()
|
||||
.replace(/-/g, '/');
|
||||
|
||||
const chapterUrl = $(this).find('a').attr('href').replace(url, '');
|
||||
const chapterUrl = loadedCheerio(this)
|
||||
.find('a')
|
||||
.attr('href')
|
||||
.replace(url, '');
|
||||
|
||||
const chapter = {
|
||||
chapterName,
|
||||
@@ -99,22 +107,22 @@ const parseNovelAndChapters = async novelUrl => {
|
||||
let moreChaptersUrl =
|
||||
baseUrl +
|
||||
'temphtml/_tempChapterList_all_' +
|
||||
$('div#more').attr('data-nid') +
|
||||
loadedCheerio('div#more').attr('data-nid') +
|
||||
'.html';
|
||||
|
||||
let moreChapters = await fetch(moreChaptersUrl);
|
||||
let moreChaptersString = await moreChapters.text();
|
||||
|
||||
$ = cheerio.load(moreChaptersString);
|
||||
loadedCheerio = cheerio.load(moreChaptersString);
|
||||
|
||||
$('a').each(function () {
|
||||
const chapterName = $(this).text();
|
||||
loadedCheerio('a').each(function () {
|
||||
const chapterName = loadedCheerio(this).text();
|
||||
|
||||
const releaseDate = $(this)[0]
|
||||
const releaseDate = loadedCheerio(this)[0]
|
||||
.nextSibling.nodeValue.replace(/-/g, '/')
|
||||
.trim();
|
||||
|
||||
const chapterUrl = $(this).attr('href').replace(url, '');
|
||||
const chapterUrl = loadedCheerio(this).attr('href').replace(url, '');
|
||||
|
||||
const chapter = {
|
||||
chapterName,
|
||||
@@ -136,13 +144,13 @@ const parseChapter = async (novelUrl, chapterUrl) => {
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
let chapterName = $('div.panel-body.article').find('h4').text();
|
||||
let chapterName = loadedCheerio('div.panel-body.article').find('h4').text();
|
||||
|
||||
$('ul.pager').remove();
|
||||
loadedCheerio('ul.pager').remove();
|
||||
|
||||
let chapterText = $('div.panel-body.article')
|
||||
let chapterText = loadedCheerio('div.panel-body.article')
|
||||
.html()
|
||||
.replace(/<span(.*?)>(.*?)<\/span>/g, '');
|
||||
|
||||
@@ -163,19 +171,19 @@ const searchNovels = async searchTerm => {
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novels = [];
|
||||
|
||||
$('#table')
|
||||
loadedCheerio('#table')
|
||||
.find('tr')
|
||||
.each(function () {
|
||||
const novelName = $(this).find('a').text().trim();
|
||||
const novelName = loadedCheerio(this).find('a').text().trim();
|
||||
|
||||
if (novelName) {
|
||||
const novelCover = $(this).find('img').attr('src');
|
||||
const novelCover = loadedCheerio(this).find('img').attr('src');
|
||||
|
||||
let novelUrl = $(this)
|
||||
let novelUrl = loadedCheerio(this)
|
||||
.find('a')
|
||||
.attr('href')
|
||||
.replace(baseUrl + 'novel/', '');
|
||||
|
||||
+37
-24
@@ -15,14 +15,17 @@ const popularNovels = async page => {
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novels = [];
|
||||
|
||||
$('.section-item.card').each(function () {
|
||||
const novelName = $(this).find('.book-name').text();
|
||||
const novelCover = $(this).find('img').attr('src');
|
||||
const novelUrl = $(this).find('a').attr('href').replace('/book/', '');
|
||||
loadedCheerio('.section-item.card').each(function () {
|
||||
const novelName = loadedCheerio(this).find('.book-name').text();
|
||||
const novelCover = loadedCheerio(this).find('img').attr('src');
|
||||
const novelUrl = loadedCheerio(this)
|
||||
.find('a')
|
||||
.attr('href')
|
||||
.replace('/book/', '');
|
||||
|
||||
const novel = {
|
||||
sourceId,
|
||||
@@ -43,7 +46,7 @@ const parseNovelAndChapters = async novelUrl => {
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
|
||||
let $ = cheerio.load(body);
|
||||
let loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novel = {
|
||||
sourceId,
|
||||
@@ -52,27 +55,30 @@ const parseNovelAndChapters = async novelUrl => {
|
||||
novelUrl,
|
||||
};
|
||||
|
||||
novel.novelName = $('h1.book-name').text();
|
||||
novel.novelName = loadedCheerio('h1.book-name').text();
|
||||
|
||||
novel.novelCover = $('div.book-img > img').attr('src');
|
||||
novel.novelCover = loadedCheerio('div.book-img > img').attr('src');
|
||||
|
||||
novel.author = $('dl.author > dd').text();
|
||||
novel.author = loadedCheerio('dl.author > dd').text();
|
||||
|
||||
novel.genre = $('.book-generes').text().trim();
|
||||
novel.genre = loadedCheerio('.book-generes').text().trim();
|
||||
|
||||
novel.summary = $('.book-synopsis').text().replace('Synopsis', '').trim();
|
||||
novel.summary = loadedCheerio('.book-synopsis')
|
||||
.text()
|
||||
.replace('Synopsis', '')
|
||||
.trim();
|
||||
|
||||
const chapterListUrl = `${baseUrl}book/${novelUrl}/chapter-list`;
|
||||
|
||||
const chaptersHtml = await fetch(chapterListUrl);
|
||||
const chapterHtmlToString = await chaptersHtml.text();
|
||||
|
||||
$ = cheerio.load(chapterHtmlToString);
|
||||
loadedCheerio = cheerio.load(chapterHtmlToString);
|
||||
|
||||
let novelChapters = [];
|
||||
|
||||
$('ul.chapters > li').each(function () {
|
||||
const chapterName = $(this)
|
||||
loadedCheerio('ul.chapters > li').each(function () {
|
||||
const chapterName = loadedCheerio(this)
|
||||
.find('.chapter-name')
|
||||
.text()
|
||||
.trim()
|
||||
@@ -80,7 +86,7 @@ const parseNovelAndChapters = async novelUrl => {
|
||||
|
||||
let releaseDate = new Date();
|
||||
|
||||
let timeAgo = $(this).find('.chapter-time').text();
|
||||
let timeAgo = loadedCheerio(this).find('.chapter-time').text();
|
||||
|
||||
timeAgo = timeAgo.replace('one', 1);
|
||||
|
||||
@@ -96,7 +102,11 @@ const parseNovelAndChapters = async novelUrl => {
|
||||
|
||||
releaseDate = moment(releaseDate).format('MM/DD/YY');
|
||||
|
||||
const chapterUrl = $(this).find('a').attr('href').split('/').pop();
|
||||
const chapterUrl = loadedCheerio(this)
|
||||
.find('a')
|
||||
.attr('href')
|
||||
.split('/')
|
||||
.pop();
|
||||
|
||||
const chapter = {
|
||||
chapterName,
|
||||
@@ -118,11 +128,11 @@ const parseChapter = async (novelUrl, chapterUrl) => {
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
let chapterName = $('.chapter-name').text();
|
||||
let chapterName = loadedCheerio('.chapter-name').text();
|
||||
|
||||
let chapterText = $('.chapter-content').html();
|
||||
let chapterText = loadedCheerio('.chapter-content').html();
|
||||
const chapter = {
|
||||
sourceId,
|
||||
novelUrl,
|
||||
@@ -140,15 +150,18 @@ const searchNovels = async searchTerm => {
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novels = [];
|
||||
|
||||
$('.section-item').each(function () {
|
||||
const novelName = $(this).find('.book-name').text().trim();
|
||||
const novelCover = $(this).find('img').attr('src');
|
||||
loadedCheerio('.section-item').each(function () {
|
||||
const novelName = loadedCheerio(this).find('.book-name').text().trim();
|
||||
const novelCover = loadedCheerio(this).find('img').attr('src');
|
||||
|
||||
let novelUrl = $(this).find('a').attr('href').replace('/book/', '');
|
||||
let novelUrl = loadedCheerio(this)
|
||||
.find('a')
|
||||
.attr('href')
|
||||
.replace('/book/', '');
|
||||
|
||||
const novel = {
|
||||
sourceId,
|
||||
|
||||
@@ -33,7 +33,7 @@ const parseNovelAndChapters = async novelUrl => {
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novel = {};
|
||||
|
||||
@@ -45,31 +45,31 @@ const parseNovelAndChapters = async novelUrl => {
|
||||
|
||||
novel.novelUrl = novelUrl;
|
||||
|
||||
novel.novelName = $('h2').text();
|
||||
novel.novelName = loadedCheerio('h2').text();
|
||||
|
||||
novel.novelCover = $('img.img-thumbnail').attr('src');
|
||||
novel.novelCover = loadedCheerio('img.img-thumbnail').attr('src');
|
||||
|
||||
novel.summary = $('h3')
|
||||
novel.summary = loadedCheerio('h3')
|
||||
.filter(function () {
|
||||
return $(this).text().trim() === 'Synopsis';
|
||||
return loadedCheerio(this).text().trim() === 'Synopsis';
|
||||
})
|
||||
.next()
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
novel.author = $('div > dt')
|
||||
novel.author = loadedCheerio('div > dt')
|
||||
.filter(function () {
|
||||
return $(this).text().trim() === 'Author:';
|
||||
return loadedCheerio(this).text().trim() === 'Author:';
|
||||
})
|
||||
.next()
|
||||
.text();
|
||||
|
||||
let genres = [];
|
||||
|
||||
$('.genres')
|
||||
loadedCheerio('.genres')
|
||||
.find('div')
|
||||
.each(function (res) {
|
||||
genres.push($(this).find('a').text());
|
||||
genres.push(loadedCheerio(this).find('a').text());
|
||||
});
|
||||
|
||||
novel.genre = genres.join(',');
|
||||
@@ -78,19 +78,19 @@ const parseNovelAndChapters = async novelUrl => {
|
||||
|
||||
novel.status = null;
|
||||
|
||||
novel.status = $('div.fr-view.pt-10').text().includes('Complete')
|
||||
novel.status = loadedCheerio('div.fr-view.pt-10').text().includes('Complete')
|
||||
? 'Completed'
|
||||
: 'Ongoing';
|
||||
|
||||
let novelChapters = [];
|
||||
|
||||
$('.chapter-item').each(function (result) {
|
||||
let chapterName = $(this).text();
|
||||
loadedCheerio('.chapter-item').each(function () {
|
||||
let chapterName = loadedCheerio(this).text();
|
||||
chapterName = chapterName.replace(/[\t\n]/g, '');
|
||||
|
||||
const releaseDate = null;
|
||||
|
||||
let chapterUrl = $(this).find('a').attr('href');
|
||||
let chapterUrl = loadedCheerio(this).find('a').attr('href');
|
||||
chapterUrl = chapterUrl.replace(`/novel/${novelUrl}/`, '');
|
||||
|
||||
const chapter = {
|
||||
@@ -113,16 +113,16 @@ const parseChapter = async (novelUrl, chapterUrl) => {
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
$('.chapter-nav').remove();
|
||||
loadedCheerio('.chapter-nav').remove();
|
||||
|
||||
let chapterName = $('#sidebar-toggler-container').next().text();
|
||||
let chapterName = loadedCheerio('#sidebar-toggler-container').next().text();
|
||||
chapterName = chapterName.replace(/[\t\n]/g, '');
|
||||
|
||||
$('#chapter-content > script').remove();
|
||||
loadedCheerio('#chapter-content > script').remove();
|
||||
|
||||
let chapterText = $('#chapter-content').html();
|
||||
let chapterText = loadedCheerio('#chapter-content').html();
|
||||
|
||||
const chapter = {
|
||||
sourceId: 7,
|
||||
@@ -136,7 +136,7 @@ const parseChapter = async (novelUrl, chapterUrl) => {
|
||||
};
|
||||
|
||||
const searchNovels = async searchTerm => {
|
||||
const searchUrl = `https://www.wuxiaworld.com/api/novels/search?query=`;
|
||||
const searchUrl = 'https://www.wuxiaworld.com/api/novels/search?query=';
|
||||
|
||||
const url = `${searchUrl}${searchTerm}`;
|
||||
|
||||
|
||||
@@ -9,19 +9,19 @@ const popularNovels = async page => {
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novels = [];
|
||||
|
||||
$('div.col-novel-main > div.list-novel > .row').each(function (result) {
|
||||
let novelUrl = $(this)
|
||||
loadedCheerio('div.col-novel-main > div.list-novel > .row').each(function () {
|
||||
let novelUrl = loadedCheerio(this)
|
||||
.find('h3.novel-title > a')
|
||||
.attr('href')
|
||||
.replace(baseUrl + 'novel/', '');
|
||||
novelUrl = `${novelUrl}/`;
|
||||
|
||||
const novelName = $(this).find('h3.novel-title > a').text();
|
||||
const novelCover = $(this).find('img').attr('src');
|
||||
const novelName = loadedCheerio(this).find('h3.novel-title > a').text();
|
||||
const novelCover = loadedCheerio(this).find('img').attr('src');
|
||||
|
||||
const novel = {
|
||||
sourceId: 20,
|
||||
@@ -42,7 +42,7 @@ const parseNovelAndChapters = async novelUrl => {
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
let loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novel = {};
|
||||
|
||||
@@ -54,22 +54,22 @@ const parseNovelAndChapters = async novelUrl => {
|
||||
|
||||
novel.novelUrl = novelUrl;
|
||||
|
||||
novel.novelName = $('div.book > img').attr('alt');
|
||||
novel.novelName = loadedCheerio('div.book > img').attr('alt');
|
||||
|
||||
novel.novelCover = $('div.book > img').attr('src');
|
||||
novel.novelCover = loadedCheerio('div.book > img').attr('src');
|
||||
|
||||
novel.summary = $('div.desc-text').text().trim();
|
||||
novel.summary = loadedCheerio('div.desc-text').text().trim();
|
||||
|
||||
novel.author = $('div.info > div > h3')
|
||||
novel.author = loadedCheerio('div.info > div > h3')
|
||||
.filter(function () {
|
||||
return $(this).text().trim() === 'Author:';
|
||||
return loadedCheerio(this).text().trim() === 'Author:';
|
||||
})
|
||||
.siblings()
|
||||
.text();
|
||||
|
||||
novel.genre = $('div.info > div')
|
||||
novel.genre = loadedCheerio('div.info > div')
|
||||
.filter(function () {
|
||||
return $(this).find('h3').text().trim() === 'Genre:';
|
||||
return loadedCheerio(this).find('h3').text().trim() === 'Genre:';
|
||||
})
|
||||
.text()
|
||||
.replace('Genre:', '')
|
||||
@@ -77,30 +77,30 @@ const parseNovelAndChapters = async novelUrl => {
|
||||
|
||||
novel.artist = null;
|
||||
|
||||
novel.status = $('div.info > div')
|
||||
novel.status = loadedCheerio('div.info > div')
|
||||
.filter(function () {
|
||||
return $(this).find('h3').text().trim() === 'Status:';
|
||||
return loadedCheerio(this).find('h3').text().trim() === 'Status:';
|
||||
})
|
||||
.text()
|
||||
.replace('Status:', '')
|
||||
.replace(/\s/g, '');
|
||||
|
||||
const novelId = $('#rating').attr('data-novel-id');
|
||||
const novelId = loadedCheerio('#rating').attr('data-novel-id');
|
||||
|
||||
const getChapters = async novelId => {
|
||||
const chapterListUrl = baseUrl + 'ajax/chapter-option?novelId=' + novelId;
|
||||
const getChapters = async id => {
|
||||
const chapterListUrl = baseUrl + 'ajax/chapter-option?novelId=' + id;
|
||||
|
||||
const data = await fetch(chapterListUrl);
|
||||
const chapters = await data.text();
|
||||
|
||||
$ = cheerio.load(chapters);
|
||||
loadedCheerio = cheerio.load(chapters);
|
||||
|
||||
let novelChapters = [];
|
||||
|
||||
$('select > option').each(function (result) {
|
||||
let chapterName = $(this).text();
|
||||
loadedCheerio('select > option').each(function () {
|
||||
let chapterName = loadedCheerio(this).text();
|
||||
let releaseDate = null;
|
||||
let chapterUrl = $(this).attr('value');
|
||||
let chapterUrl = loadedCheerio(this).attr('value');
|
||||
chapterUrl = chapterUrl.replace(baseUrl, '');
|
||||
|
||||
novelChapters.push({
|
||||
@@ -125,10 +125,10 @@ const parseChapter = async (novelUrl, chapterUrl) => {
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
const chapterName = $('.chr-title').attr('title');
|
||||
let chapterText = $('#chr-content').html();
|
||||
const chapterName = loadedCheerio('.chr-title').attr('title');
|
||||
let chapterText = loadedCheerio('#chr-content').html();
|
||||
const chapter = {
|
||||
sourceId: 20,
|
||||
novelUrl,
|
||||
@@ -141,26 +141,26 @@ const parseChapter = async (novelUrl, chapterUrl) => {
|
||||
};
|
||||
|
||||
const searchNovels = async searchTerm => {
|
||||
const searchUrl = `http://wuxiaworld.cloud/search?keyword=`;
|
||||
const searchUrl = 'http://wuxiaworld.cloud/search?keyword=';
|
||||
|
||||
const url = `${searchUrl}${searchTerm}`;
|
||||
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novels = [];
|
||||
|
||||
$('div.col-novel-main > div.list-novel > .row').each(function (result) {
|
||||
let novelUrl = $(this)
|
||||
loadedCheerio('div.col-novel-main > div.list-novel > .row').each(function () {
|
||||
let novelUrl = loadedCheerio(this)
|
||||
.find('h3.novel-title > a')
|
||||
.attr('href')
|
||||
.replace(baseUrl + 'novel/', '');
|
||||
novelUrl = `${novelUrl}/`;
|
||||
|
||||
const novelName = $(this).find('h3.novel-title > a').text();
|
||||
const novelCover = $(this).find('img').attr('src');
|
||||
const novelName = loadedCheerio(this).find('h3.novel-title > a').text();
|
||||
const novelCover = loadedCheerio(this).find('img').attr('src');
|
||||
|
||||
const novel = {
|
||||
sourceId: 20,
|
||||
|
||||
@@ -7,15 +7,15 @@ const popularNovels = async page => {
|
||||
const result = await fetch(baseUrl);
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novels = [];
|
||||
|
||||
$('.section-item').each(function (result) {
|
||||
const novelName = $(this).find('.book-name').text();
|
||||
const novelCover = $(this).find('img').attr('src');
|
||||
loadedCheerio('.section-item').each(function () {
|
||||
const novelName = loadedCheerio(this).find('.book-name').text();
|
||||
const novelCover = loadedCheerio(this).find('img').attr('src');
|
||||
|
||||
let novelUrl = $(this).find('a').attr('href').slice(1);
|
||||
let novelUrl = loadedCheerio(this).find('a').attr('href').slice(1);
|
||||
|
||||
const novel = {
|
||||
sourceId: 16,
|
||||
@@ -36,7 +36,7 @@ const parseNovelAndChapters = async novelUrl => {
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novel = {};
|
||||
|
||||
@@ -48,25 +48,25 @@ const parseNovelAndChapters = async novelUrl => {
|
||||
|
||||
novel.novelUrl = novelUrl;
|
||||
|
||||
novel.novelName = $('.book-name').text();
|
||||
novel.novelName = loadedCheerio('.book-name').text();
|
||||
|
||||
novel.novelCover = $('div.book-img > img').attr('src');
|
||||
novel.novelCover = loadedCheerio('div.book-img > img').attr('src');
|
||||
|
||||
novel.genre = $('div.book-catalog > span.txt').text();
|
||||
novel.genre = loadedCheerio('div.book-catalog > span.txt').text();
|
||||
|
||||
novel.status = $('div.book-state > span.txt').text();
|
||||
novel.status = loadedCheerio('div.book-state > span.txt').text();
|
||||
|
||||
novel.author = $('div.author > span.name').text();
|
||||
novel.author = loadedCheerio('div.author > span.name').text();
|
||||
|
||||
novelSummary = $('div.content > p.desc').html();
|
||||
const novelSummary = loadedCheerio('div.content > p.desc').html();
|
||||
novel.summary = novelSummary.trim();
|
||||
|
||||
let novelChapters = [];
|
||||
|
||||
$('.chapter-item').each(function (result) {
|
||||
const chapterName = $(this).find('.chapter-name').text();
|
||||
loadedCheerio('.chapter-item').each(function () {
|
||||
const chapterName = loadedCheerio(this).find('.chapter-name').text();
|
||||
const releaseDate = null;
|
||||
const chapterUrl = $(this).attr('href').split('/')[2];
|
||||
const chapterUrl = loadedCheerio(this).attr('href').split('/')[2];
|
||||
|
||||
novelChapters.push({
|
||||
chapterName,
|
||||
@@ -86,10 +86,10 @@ const parseChapter = async (novelUrl, chapterUrl) => {
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
const chapterName = $('h1.chapter-title').text();
|
||||
let chapterText = $('div.chapter-entity').html();
|
||||
const chapterName = loadedCheerio('h1.chapter-title').text();
|
||||
let chapterText = loadedCheerio('div.chapter-entity').html();
|
||||
const chapter = {
|
||||
sourceId: 16,
|
||||
novelUrl,
|
||||
@@ -107,17 +107,17 @@ const searchNovels = async searchTerm => {
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novels = [];
|
||||
|
||||
$('.list-item').each(function (result) {
|
||||
$(this).find('font').remove();
|
||||
loadedCheerio('.list-item').each(function () {
|
||||
loadedCheerio(this).find('font').remove();
|
||||
|
||||
const novelName = $(this).find('.book-name').text();
|
||||
const novelCover = $(this).find('img').attr('src');
|
||||
const novelName = loadedCheerio(this).find('.book-name').text();
|
||||
const novelCover = loadedCheerio(this).find('img').attr('src');
|
||||
|
||||
let novelUrl = $(this).find('a').attr('href').slice(1);
|
||||
let novelUrl = loadedCheerio(this).find('a').attr('href').slice(1);
|
||||
|
||||
const novel = {
|
||||
sourceId: 16,
|
||||
|
||||
@@ -5,7 +5,7 @@ const searchUrl = 'https://wuxiaworldsite.co/search/';
|
||||
|
||||
const popularNovels = async page => {
|
||||
let totalPages = 222;
|
||||
const url = `https://wuxiaworldsite.co/ajax-story-power.ajax`;
|
||||
const url = 'https://wuxiaworldsite.co/ajax-story-power.ajax';
|
||||
|
||||
const formData = new FormData();
|
||||
formData.append('page', page);
|
||||
@@ -19,16 +19,16 @@ const popularNovels = async page => {
|
||||
const result = await fetch(url, {method: 'POST', body: formData});
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novels = [];
|
||||
|
||||
$('.a_item').each((i, el) => {
|
||||
const novelName = $(el).find('a').attr('title');
|
||||
const novelCover = baseUrl + $(el).find('a > img').attr('src');
|
||||
loadedCheerio('.a_item').each((i, el) => {
|
||||
const novelName = loadedCheerio(el).find('a').attr('title');
|
||||
const novelCover = baseUrl + loadedCheerio(el).find('a > img').attr('src');
|
||||
|
||||
let novelUrl = $(el).find('.name_views > a').attr('href');
|
||||
novelId = novelUrl.split('/');
|
||||
let novelUrl = loadedCheerio(el).find('.name_views > a').attr('href');
|
||||
const novelId = novelUrl.split('/');
|
||||
novelUrl = novelId[2] + '/';
|
||||
|
||||
const novel = {
|
||||
@@ -50,9 +50,9 @@ const parseNovelAndChapters = async novelUrl => {
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
let loadedCheerio = cheerio.load(body);
|
||||
|
||||
$('.category_list').remove();
|
||||
loadedCheerio('.category_list').remove();
|
||||
|
||||
let novel = {};
|
||||
|
||||
@@ -64,20 +64,20 @@ const parseNovelAndChapters = async novelUrl => {
|
||||
|
||||
novel.novelUrl = novelUrl;
|
||||
|
||||
novel.novelName = $('.content-reading > h1').text().trim();
|
||||
novel.novelName = loadedCheerio('.content-reading > h1').text().trim();
|
||||
|
||||
novel.novelCover = baseUrl + $('.img-read> img').attr('src');
|
||||
novel.novelCover = baseUrl + loadedCheerio('.img-read> img').attr('src');
|
||||
|
||||
novel.summary = $('.story-introduction-content').text();
|
||||
novel.summary = loadedCheerio('.story-introduction-content').text();
|
||||
|
||||
novel.author = $('.content-reading > p').text().trim();
|
||||
novel.author = loadedCheerio('.content-reading > p').text().trim();
|
||||
|
||||
novel.artist = null;
|
||||
|
||||
novel.genre = '';
|
||||
|
||||
$('.a_tag_item').each((i, el) => {
|
||||
novel.genre += $(el).text() + ',';
|
||||
loadedCheerio('.a_tag_item').each((i, el) => {
|
||||
novel.genre += loadedCheerio(el).text() + ',';
|
||||
});
|
||||
|
||||
novel.genre = novel.genre.split(',');
|
||||
@@ -87,31 +87,31 @@ const parseNovelAndChapters = async novelUrl => {
|
||||
|
||||
novel.genre = novel.genre.join(',');
|
||||
|
||||
const novelID = $('.show-more-list').attr('data-id');
|
||||
const novelID = loadedCheerio('.show-more-list').attr('data-id');
|
||||
|
||||
const getChapters = async novelID => {
|
||||
const chapterListUrl = baseUrl + '/get-full-list.ajax?id=' + novelID;
|
||||
const getChapters = async id => {
|
||||
const chapterListUrl = baseUrl + '/get-full-list.ajax?id=' + id;
|
||||
|
||||
const data = await fetch(chapterListUrl);
|
||||
const chapters = await data.text();
|
||||
|
||||
$ = cheerio.load(chapters);
|
||||
loadedCheerio = cheerio.load(chapters);
|
||||
|
||||
let novelChapters = [];
|
||||
|
||||
$('.new-update-content').each((i, el) => {
|
||||
let chapterName = $(el).text().split(/\t+/);
|
||||
loadedCheerio('.new-update-content').each((i, el) => {
|
||||
let chapterName = loadedCheerio(el).text().split(/\t+/);
|
||||
const releaseDate = chapterName.pop();
|
||||
chapterName = chapterName[0];
|
||||
let chapterUrl = $(el).attr('href');
|
||||
let chapterUrl = loadedCheerio(el).attr('href');
|
||||
chapterUrl = chapterUrl.split('/').pop();
|
||||
|
||||
const novel = {
|
||||
const chapter = {
|
||||
chapterName,
|
||||
releaseDate,
|
||||
chapterUrl,
|
||||
};
|
||||
novelChapters.push(novel);
|
||||
novelChapters.push(chapter);
|
||||
});
|
||||
return novelChapters;
|
||||
};
|
||||
@@ -127,10 +127,10 @@ const parseChapter = async (novelUrl, chapterUrl) => {
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
let chapterName = $('h1.text-center.heading_read').text();
|
||||
let chapterText = $('.content-story').html();
|
||||
let chapterName = loadedCheerio('h1.text-center.heading_read').text();
|
||||
let chapterText = loadedCheerio('.content-story').html();
|
||||
|
||||
novelUrl += '/';
|
||||
chapterUrl += '/';
|
||||
@@ -152,15 +152,15 @@ const searchNovels = async searchTerm => {
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novels = [];
|
||||
|
||||
$('.a_item').each((i, el) => {
|
||||
const novelName = $(el).find('.name_views > a').attr('title');
|
||||
const novelCover = baseUrl + $(el).find('a > img').attr('src');
|
||||
let novelUrl = $(el).find('.name_views > a').attr('href');
|
||||
novelId = novelUrl.split('/');
|
||||
loadedCheerio('.a_item').each((i, el) => {
|
||||
const novelName = loadedCheerio(el).find('.name_views > a').attr('title');
|
||||
const novelCover = baseUrl + loadedCheerio(el).find('a > img').attr('src');
|
||||
let novelUrl = loadedCheerio(el).find('.name_views > a').attr('href');
|
||||
const novelId = novelUrl.split('/');
|
||||
novelUrl = novelId[2] + '/';
|
||||
|
||||
const novel = {
|
||||
|
||||
@@ -9,15 +9,15 @@ const popularNovels = async page => {
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
let loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novels = [];
|
||||
|
||||
$('.wp-block-media-text').each(function (result) {
|
||||
const novelName = $(this).find('a').text();
|
||||
const novelCover = $(this).find('img').attr('src');
|
||||
loadedCheerio('.wp-block-media-text').each(function () {
|
||||
const novelName = loadedCheerio(this).find('a').text();
|
||||
const novelCover = loadedCheerio(this).find('img').attr('src');
|
||||
|
||||
let novelUrl = $(this)
|
||||
let novelUrl = loadedCheerio(this)
|
||||
.find('.wp-block-media-text__content')
|
||||
.find('a')
|
||||
.attr('href');
|
||||
@@ -42,7 +42,7 @@ const parseNovelAndChapters = async novelUrl => {
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
let loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novel = {};
|
||||
|
||||
@@ -54,44 +54,59 @@ const parseNovelAndChapters = async novelUrl => {
|
||||
|
||||
novel.novelUrl = novelUrl;
|
||||
|
||||
novel.novelName = $('h1').text();
|
||||
novel.novelName = loadedCheerio('h1').text();
|
||||
|
||||
novel.novelCover = $('img').attr('src');
|
||||
novel.novelCover = loadedCheerio('img').attr('src');
|
||||
|
||||
$('.wp-block-columns')
|
||||
loadedCheerio('.wp-block-columns')
|
||||
.find('li')
|
||||
.each(function (result) {
|
||||
if ($(this).text().includes('Autor:')) {
|
||||
novel.author = $(this).text().replace('Autor:', '').slice(0, -1);
|
||||
.each(function () {
|
||||
if (loadedCheerio(this).text().includes('Autor:')) {
|
||||
novel.author = loadedCheerio(this)
|
||||
.text()
|
||||
.replace('Autor:', '')
|
||||
.slice(0, -1);
|
||||
}
|
||||
if ($(this).text().includes('Ilustrador: ')) {
|
||||
novel.artist = $(this).text().replace('Ilustrador: ', '').slice(0, -1);
|
||||
if (loadedCheerio(this).text().includes('Ilustrador: ')) {
|
||||
novel.artist = loadedCheerio(this)
|
||||
.text()
|
||||
.replace('Ilustrador: ', '')
|
||||
.slice(0, -1);
|
||||
}
|
||||
if ($(this).text().includes('Estado: ')) {
|
||||
novel.status = $(this).text().replace('Estado: ', '').slice(0, -1);
|
||||
if (loadedCheerio(this).text().includes('Estado: ')) {
|
||||
novel.status = loadedCheerio(this)
|
||||
.text()
|
||||
.replace('Estado: ', '')
|
||||
.slice(0, -1);
|
||||
}
|
||||
});
|
||||
|
||||
novel.genre = $('.post-content > h6')
|
||||
novel.genre = loadedCheerio('.post-content > h6')
|
||||
.text()
|
||||
.replace(/GÉNEROS: /, '')
|
||||
.replace(/,\s/g, ',');
|
||||
|
||||
let novelSummary = $('.post-content > .has-text-align-center').html();
|
||||
let novelSummary = loadedCheerio(
|
||||
'.post-content > .has-text-align-center',
|
||||
).html();
|
||||
|
||||
novel.summary = novelSummary.trim();
|
||||
|
||||
let novelChapters = [];
|
||||
|
||||
$('.wp-block-media-text')
|
||||
loadedCheerio('.wp-block-media-text')
|
||||
.find('p')
|
||||
.each(function (result) {
|
||||
if ($(this).find('a').text()) {
|
||||
const chapterName = $(this).text();
|
||||
.each(function () {
|
||||
if (loadedCheerio(this).find('a').text()) {
|
||||
const chapterName = loadedCheerio(this).text();
|
||||
const releaseDate = null;
|
||||
let chapterUrl = $(this).find('a').attr('href').replace(baseUrl, '');
|
||||
if (chapterUrl.includes(novelUrl + '/'))
|
||||
let chapterUrl = loadedCheerio(this)
|
||||
.find('a')
|
||||
.attr('href')
|
||||
.replace(baseUrl, '');
|
||||
if (chapterUrl.includes(novelUrl + '/')) {
|
||||
chapterUrl = chapterUrl.replace(novelUrl + '/', '');
|
||||
}
|
||||
|
||||
const chapter = {chapterName, releaseDate, chapterUrl};
|
||||
|
||||
@@ -110,11 +125,11 @@ const parseChapter = async (novelUrl, chapterUrl) => {
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
let loadedCheerio = cheerio.load(body);
|
||||
|
||||
let chapterName = $('h1.post-title').text();
|
||||
let chapterName = loadedCheerio('h1.post-title').text();
|
||||
|
||||
let chapterText = $('.post-content').html();
|
||||
let chapterText = loadedCheerio('.post-content').html();
|
||||
novelUrl = novelUrl + '/';
|
||||
chapterUrl = chapterUrl + '/';
|
||||
|
||||
@@ -135,22 +150,28 @@ const searchNovels = async searchTerm => {
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novels = [];
|
||||
|
||||
$('.post-container')
|
||||
loadedCheerio('.post-container')
|
||||
.find('div.type-page')
|
||||
.each(function (result) {
|
||||
const novelName = $(this).find('.post-header').text().replace(/\n/g, '');
|
||||
.each(function () {
|
||||
const novelName = loadedCheerio(this)
|
||||
.find('.post-header')
|
||||
.text()
|
||||
.replace(/\n/g, '');
|
||||
if (
|
||||
!novelName.includes('EPUBs') &&
|
||||
!novelName.includes('Proyectos Activos') &&
|
||||
!novelName.includes('Chapter')
|
||||
) {
|
||||
const novelCover = $(this).find('img').attr('src');
|
||||
const novelCover = loadedCheerio(this).find('img').attr('src');
|
||||
|
||||
let novelUrl = $(this).find('a').attr('href').replace(baseUrl, '');
|
||||
let novelUrl = loadedCheerio(this)
|
||||
.find('a')
|
||||
.attr('href')
|
||||
.replace(baseUrl, '');
|
||||
|
||||
const novel = {
|
||||
sourceId: 25,
|
||||
|
||||
+25
-23
@@ -9,15 +9,17 @@ const popularNovels = async page => {
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
let loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novels = [];
|
||||
|
||||
$('div.wp-block-columns').each(function (result) {
|
||||
const novelName = $(this).find('.wp-block-button').text();
|
||||
const novelCover = $(this).find('img').attr('src');
|
||||
loadedCheerio('div.wp-block-columns').each(function () {
|
||||
const novelName = loadedCheerio(this).find('.wp-block-button').text();
|
||||
const novelCover = loadedCheerio(this).find('img').attr('src');
|
||||
|
||||
let novelUrl = $(this).find('.wp-block-button > a').attr('href');
|
||||
let novelUrl = loadedCheerio(this)
|
||||
.find('.wp-block-button > a')
|
||||
.attr('href');
|
||||
novelUrl = novelUrl.replace(baseUrl, '');
|
||||
|
||||
const novel = {
|
||||
@@ -39,7 +41,7 @@ const parseNovelAndChapters = async novelUrl => {
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
let loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novel = {};
|
||||
|
||||
@@ -51,13 +53,13 @@ const parseNovelAndChapters = async novelUrl => {
|
||||
|
||||
novel.novelUrl = novelUrl;
|
||||
|
||||
novel.novelName = $('.post-header').text();
|
||||
novel.novelName = loadedCheerio('.post-header').text();
|
||||
|
||||
novel.novelCover = $('.featured-media > img').attr('src');
|
||||
novel.novelCover = loadedCheerio('.featured-media > img').attr('src');
|
||||
|
||||
let details = $('.post-content').find('p').html();
|
||||
let details = loadedCheerio('.post-content').find('p').html();
|
||||
|
||||
detailName = details.match(/<strong>(.|\n)*?<\/strong>/g);
|
||||
const detailName = details.match(/<strong>(.|\n)*?<\/strong>/g);
|
||||
details = details.match(/<\/strong>(.|\n)*?<br>/g);
|
||||
details = details.map(detail => detail.replace(/<\/strong>|<br>/g, ''));
|
||||
|
||||
@@ -75,19 +77,19 @@ const parseNovelAndChapters = async novelUrl => {
|
||||
}
|
||||
});
|
||||
|
||||
let novelSummary = $('.post-content').find('p').html();
|
||||
let novelSummary = loadedCheerio('.post-content').find('p').html();
|
||||
novel.summary = novelSummary;
|
||||
|
||||
let novelChapters = [];
|
||||
|
||||
$('.wp-block-media-text__content')
|
||||
loadedCheerio('.wp-block-media-text__content')
|
||||
.find('a')
|
||||
.each(function (result) {
|
||||
const chapterName = $(this).text().trim();
|
||||
.each(function () {
|
||||
const chapterName = loadedCheerio(this).text().trim();
|
||||
|
||||
const releaseDate = null;
|
||||
|
||||
let chapterUrl = $(this).attr('href').split('/');
|
||||
let chapterUrl = loadedCheerio(this).attr('href').split('/');
|
||||
chapterUrl = chapterUrl[chapterUrl.length - 2];
|
||||
|
||||
const chapter = {chapterName, releaseDate, chapterUrl};
|
||||
@@ -106,11 +108,11 @@ const parseChapter = async (novelUrl, chapterUrl) => {
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
let loadedCheerio = cheerio.load(body);
|
||||
|
||||
let chapterName = $('.post-title').text();
|
||||
let chapterName = loadedCheerio('.post-title').text();
|
||||
|
||||
let chapterText = $('.post-content').html();
|
||||
let chapterText = loadedCheerio('.post-content').html();
|
||||
novelUrl = novelUrl + '/';
|
||||
chapterUrl = chapterUrl;
|
||||
|
||||
@@ -131,20 +133,20 @@ const searchNovels = async searchTerm => {
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
let loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novels = [];
|
||||
|
||||
$('.post-container ').each(function (result) {
|
||||
const novelName = $(this).find('.post-header').text();
|
||||
loadedCheerio('.post-container ').each(function () {
|
||||
const novelName = loadedCheerio(this).find('.post-header').text();
|
||||
if (
|
||||
!novelName.includes('Cap') &&
|
||||
!novelName.includes('Vol') &&
|
||||
!novelName.includes('Light Novels')
|
||||
) {
|
||||
const novelCover = $(this).find('img').attr('src');
|
||||
const novelCover = loadedCheerio(this).find('img').attr('src');
|
||||
|
||||
let novelUrl = $(this).find('a').attr('href');
|
||||
let novelUrl = loadedCheerio(this).find('a').attr('href');
|
||||
novelUrl = novelUrl.replace(baseUrl, '');
|
||||
|
||||
const novel = {
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user