diff --git a/README.md b/README.md
index b2f6ead..5d24c60 100644
--- a/README.md
+++ b/README.md
@@ -1,14 +1,10 @@
-
-
-
# shallty
-Aplikasi untuk meng-crawl situs fastsub/fanshare Indonesia. Tujuan utamanya adalah untuk melewati berbagai halaman redirect dan mengambil tautan unduh aslinya. Saat ini Shallty telah mendukung crawling untuk ~~Meownime~~, Samehadaku, Neonime, Kusonime dan Oploverz.
+Aplikasi untuk meng-crawl situs fastsub/fanshare Indonesia. Tujuan utamanya adalah untuk melewati berbagai halaman redirect dan mengambil tautan unduh aslinya. Saat ini Shallty telah mendukung crawling untuk ~~Meownime~~, Samehadaku, Neonime, Kusonime dan Oploverz. **Shallty juga mendukung crawling untuk satu situs baca manga, Kiryuu.**
-
+Kunjungi https://shallty.moe/ untuk melihat satu contoh yang bisa dicapai menggunakan aplikasi ini.
## Instalasi
-
1. Instal [node.js](https://nodejs.org/en/).
2. Jalankan `npm install`.
@@ -17,26 +13,72 @@ Aplikasi untuk meng-crawl situs fastsub/fanshare Indonesia. Tujuan utamanya adal
4. Sesuaikan `config.json`.
-5. Jalankan `node index.js` untuk memulai aplikasi.
+5. Jalankan `node index.js` untuk memulai aplikasi. Kamu akan mendapatkan pesan server dan crawler ready jika tidak ada masalah.
-6. Kunjungi localhost:8080 (default port) di browser, kamu akan melihat `hello world` jika tidak ada masalah.
-
-
## Penggunaan
-
### Dasar
- API path: `localhost:8080/api` (default port)
-- Semua request melalui via GET method
+- Semua request melalui GET method
- Semua parameter `url` harus di-encode terlebih dahulu
-
-
### Endpoint
+**/kiryuu/mangaList**
+
+Keterangan: Mengambil daftar manga.
+
+Contoh: `/kiryuu/mangaList`
+
+
+
+**/kiryuu/mangaInfo?link={url}**
+
+Keterangan: Mengambil informasi manga.
+
+Parameter:
+
+- `url` - url halaman manga tanpa domain (Contoh: /manga/iron-ladies/)
+
+Contoh: `/kiryuu/mangaInfo?link=%2Fmanga%2Firon-ladies%2F`
+
+
+
+**/kiryuu/chapters?link={url}**
+
+Keterangan: Mengambil daftar chapter manga.
+
+Parameter:
+
+- `url` - url halaman manga tanpa domain (Contoh: /manga/iron-ladies/)
+
+Contoh: `/kiryuu/chapters?link=%2Fmanga%2Firon-ladies`
+
+
+
+**/kiryuu/images?link={url}**
+
+Keterangan: Mengambil daftar gambar dari satu chapter manga.
+
+Parameter:
+
+- `url` - url halaman chapter manga tanpa domain (Contoh: /iron-ladies-chapter-99-bahasa-indonesia/)
+
+Contoh: `/kiryuu/images?link=%2Firon-ladies-chapter-99-bahasa-indonesia%2F`
+
+
+
+**/kiryuu/newReleases**
+
+Keterangan: Mengambil daftar rilisan terbaru dari Kiryuu.
+
+Contoh: `/kiryuu/newReleases`
+
+
+
**/samehadaku/anime?link={url}**
Keterangan: Mengambil daftar episode untuk 1 halaman kategori anime.
@@ -236,8 +278,6 @@ Parameter:
Contoh: `/kusonime/semrawut?link=https%3A%2F%2Fkepoow.me%2F%3Fr%3DaHR0cHM6Ly9kcml2ZS5nb29nbGUuY29tL2ZpbGUvZC8xQjNlY2h4dEYwMFNUbVRRWklEcW8xUVJ3a1RHTmFSaXkvdmlldw%3D%3D`
-
-
-## Bantuan
+## Bantuan, Lapor Bug, dan Kritik dan Saran
-Discord server: http://discord.gg/Ur4xJ4t
+Server Discord: http://discord.gg/Ur4xJ4t
diff --git a/controllers/KiryuuController.js b/controllers/KiryuuController.js
index ab644c7..49004ac 100644
--- a/controllers/KiryuuController.js
+++ b/controllers/KiryuuController.js
@@ -1,5 +1,5 @@
const Browser = require('../services/Browser')
-const Kiryuu = require('../services/Kiryuu')
+const Kiryuu = new (require('../services/Kiryuu'))(Browser)
class KiryuuController {
constructor() {
@@ -11,7 +11,7 @@ class KiryuuController {
}
async mangaList(req, res) {
- const manga = await new Kiryuu(Browser.browser).getMangaList()
+ const manga = await Kiryuu.getMangaList()
if (manga.error) {
res.status(500).json({
status: 500,
@@ -27,7 +27,7 @@ class KiryuuController {
}
async mangaInfo(req, res) {
- const result = await new Kiryuu(Browser.browser).getMangaInfo(req.query.link)
+ const result = await Kiryuu.getMangaInfo(req.query.link)
if (result.error) {
res.status(500).json({
status: 500,
@@ -43,7 +43,7 @@ class KiryuuController {
}
async chapters(req, res) {
- const chapters = await new Kiryuu(Browser.browser).getChapters(req.query.link)
+ const chapters = await Kiryuu.getChapters(req.query.link)
if (chapters.error) {
res.status(500).json({
status: 500,
@@ -59,7 +59,7 @@ class KiryuuController {
}
async images(req, res) {
- const images = await new Kiryuu(Browser.browser).getImages(req.query.link)
+ const images = await Kiryuu.getImages(req.query.link)
if (images.error) {
res.status(500).json({
status: 500,
@@ -75,7 +75,7 @@ class KiryuuController {
}
async newReleases(req, res) {
- const releases = await new Kiryuu(Browser.browser).getNewReleases(req.query.link)
+ const releases = await Kiryuu.getNewReleases(req.query.link)
if (releases.error) {
res.status(500).json({
status: 500,
diff --git a/controllers/MeownimeController.js b/controllers/MeownimeController.js
index ad1bd96..021811f 100644
--- a/controllers/MeownimeController.js
+++ b/controllers/MeownimeController.js
@@ -1,123 +1,130 @@
-const Meownime = require('../services/Meownime')
+const Browser = require('../services/Browser')
+const Meownime = new(require('../services/Meownime'))(Browser)
-const anime = async (req, res) => {
- const episodes = await Meownime.getEpisodes(req.query.link)
- if (!episodes) {
- res.status(500).json({
- status: 500,
- message: 'Something went wrong'
- })
- } else {
- res.json({
- status: 200,
- message: 'Success',
- data: episodes
- })
+class MeownimeController {
+ constructor() {
+ this.anime = this.anime.bind(this)
+ this.movie = this.movie.bind(this)
+ this.davinsurance = this.davinsurance.bind(this)
+ this.meowbox = this.meowbox.bind(this)
+ this.meowdrive = this.meowdrive.bind(this)
+ this.checkOnGoingPage = this.checkOnGoingPage.bind(this)
+ this.onGoingAnime = this.onGoingAnime.bind(this)
}
-}
-const movie = async (req, res) => {
- const episodes = await Meownime.getMovieEpisodes(req.query.link)
- if (!episodes) {
- res.status(500).json({
- status: 500,
- message: 'Something went wrong'
- })
- } else {
- res.json({
- status: 200,
- message: 'Success',
- data: episodes
- })
+ async anime(req, res) {
+ const episodes = await Meownime.getEpisodes(req.query.link)
+ if (!episodes) {
+ res.status(500).json({
+ status: 500,
+ message: episodes.message
+ })
+ } else {
+ res.json({
+ status: 200,
+ message: 'Success',
+ data: episodes
+ })
+ }
}
-}
-const davinsurance = async (req, res) => {
- const link = await Meownime.davinsurance(req.query.link)
- if (!link) {
- res.status(500).json({
- status: 500,
- message: 'Something went wrong'
- })
- } else {
- res.json({
- status: 200,
- message: 'Success',
- data: link
- })
+ async movie(req, res) {
+ const episodes = await Meownime.getMovieEpisodes(req.query.link)
+ if (!episodes) {
+ res.status(500).json({
+ status: 500,
+ message: episodes.message
+ })
+ } else {
+ res.json({
+ status: 200,
+ message: 'Success',
+ data: episodes
+ })
+ }
}
-}
-const meowbox = async (req, res) => {
- const link = await Meownime.meowbox(req.query.link)
- if (!link) {
- res.status(500).json({
- status: 500,
- message: 'Something went wrong'
- })
- } else {
- res.json({
- status: 200,
- message: 'Success',
- data: link
- })
+ async davinsurance(req, res) {
+ const link = await Meownime.davinsurance(req.query.link)
+ if (!link) {
+ res.status(500).json({
+ status: 500,
+ message: link.message
+ })
+ } else {
+ res.json({
+ status: 200,
+ message: 'Success',
+ data: link
+ })
+ }
}
-}
-const meowdrive = async (req, res) => {
- const link = await Meownime.meowdrive(req.query.link)
- if (!link) {
- res.status(500).json({
- status: 500,
- message: 'Something went wrong'
- })
- } else {
- res.json({
- status: 200,
- message: 'Success',
- data: link
- })
+ async meowbox(req, res) {
+ const link = await Meownime.meowbox(req.query.link)
+ if (!link) {
+ res.status(500).json({
+ status: 500,
+ message: link.message
+ })
+ } else {
+ res.json({
+ status: 200,
+ message: 'Success',
+ data: link
+ })
+ }
}
-}
-const checkOnGoingPage = async (req, res) => {
- const anime = await Meownime.checkOnGoingPage()
- if (!anime) {
- res.status(500).json({
- status: 500,
- message: 'Something went wrong'
- })
- } else {
- res.json({
- status: 200,
- message: 'Success',
- data: anime
- })
+ async meowdrive(req, res) {
+ const link = await Meownime.meowdrive(req.query.link)
+ if (!link) {
+ res.status(500).json({
+ status: 500,
+ message: link.message
+ })
+ } else {
+ res.json({
+ status: 200,
+ message: 'Success',
+ data: link
+ })
+ }
+ }
+
+ async checkOnGoingPage(req, res) {
+ const anime = await Meownime.checkOnGoingPage()
+ if (!anime) {
+ res.status(500).json({
+ status: 500,
+ message: anime.message
+ })
+ } else {
+ res.json({
+ status: 200,
+ message: 'Success',
+ data: anime
+ })
+ }
}
-}
-const onGoingAnime = async (req, res) => {
- const anime = await Meownime.onGoingAnime(req.query.link)
- if (!anime) {
- res.status(500).json({
- status: 500,
- message: 'Something went wrong'
- })
- } else {
- res.json({
- status: 200,
- message: 'Success',
- data: anime
- })
+ async onGoingAnime(req, res) {
+ const anime = await Meownime.onGoingAnime(req.query.link)
+ if (!anime) {
+ res.status(500).json({
+ status: 500,
+ message: anime.message
+ })
+ } else {
+ res.json({
+ status: 200,
+ message: 'Success',
+ data: anime
+ })
+ }
}
}
-module.exports = {
- anime,
- movie,
- davinsurance,
- meowbox,
- meowdrive,
- checkOnGoingPage,
- onGoingAnime
-}
\ No newline at end of file
+
+
+module.exports = new MeownimeController
\ No newline at end of file
diff --git a/controllers/NeonimeController.js b/controllers/NeonimeController.js
index 55f3166..a9c4cd4 100644
--- a/controllers/NeonimeController.js
+++ b/controllers/NeonimeController.js
@@ -1,5 +1,5 @@
const Browser = require('../services/Browser')
-const Neonime = require('../services/Neonime')
+const Neonime = new (require('../services/Neonime'))(Browser)
class NeonimeController {
constructor() {
@@ -12,7 +12,7 @@ class NeonimeController {
}
async checkOnGoingPage(req, res) {
- const anime = await new Neonime(Browser).checkOnGoingPage()
+ const anime = await Neonime.checkOnGoingPage()
if (!anime) {
res.status(500).json({
status: 500,
@@ -28,7 +28,7 @@ class NeonimeController {
}
async animeList(req, res) {
- const anime = await new Neonime(Browser).animeList(req.query.link)
+ const anime = await Neonime.animeList(req.query.link)
if (!anime) {
res.status(500).json({
status: 500,
@@ -44,7 +44,7 @@ class NeonimeController {
}
async tvShow(req, res) {
- const episodes = await new Neonime(Browser).tvShow(req.query.link)
+ const episodes = await Neonime.tvShow(req.query.link)
if (!episodes) {
res.status(500).json({
status: 500,
@@ -60,7 +60,7 @@ class NeonimeController {
}
async getBatchEpisodes(req, res) {
- const episodes = await new Neonime(Browser).getBatchEpisodes(req.query.link)
+ const episodes = await Neonime.getBatchEpisodes(req.query.link)
if (!episodes) {
res.status(500).json({
status: 500,
@@ -76,7 +76,7 @@ class NeonimeController {
}
async getEpisodes(req, res) {
- const episodes = await new Neonime(Browser).getEpisodes(req.query.link)
+ const episodes = await Neonime.getEpisodes(req.query.link)
if (!episodes) {
res.status(500).json({
status: 500,
@@ -92,7 +92,7 @@ class NeonimeController {
}
async hightech(req, res) {
- const url = await new Neonime(Browser).hightech(req.query.link)
+ const url = await Neonime.hightech(req.query.link)
if (!url) {
res.status(500).json({
status: 500,
diff --git a/controllers/OploverzController.js b/controllers/OploverzController.js
index c19061f..0b8c185 100644
--- a/controllers/OploverzController.js
+++ b/controllers/OploverzController.js
@@ -1,73 +1,77 @@
-const Oploverz = require('../services/Oploverz')
+const Browser = require('../services/Browser')
+const Oploverz = new (require('../services/Oploverz'))(Browser)
-// eslint-disable-next-line no-unused-vars
-const checkOnGoingPage = async (req, res) => {
- const anime = await Oploverz.checkOnGoingPage()
- if (!anime) {
- res.status(500).json({
- status: 500,
- message: 'Something went wrong'
- })
- } else {
- res.json({
- status: 200,
- message: 'Success',
- data: anime
- })
+class OploverzController {
+ constructor() {
+ this.checkOnGoingPage = this.checkOnGoingPage.bind(this)
+ this.series = this.series.bind(this)
+ this.getDownloadLinks = this.getDownloadLinks.bind(this)
+ this.hexa = this.hexa.bind(this)
}
-}
-const series = async (req, res) => {
- const episodes = await Oploverz.series(req.query.link)
- if (!episodes) {
- res.status(500).json({
- status: 500,
- message: 'Something went wrong'
- })
- } else {
- res.json({
- status: 200,
- message: 'Success',
- data: episodes
- })
+ async checkOnGoingPage(req, res) {
+ const anime = await Oploverz.checkOnGoingPage()
+ if (!anime) {
+ res.status(500).json({
+ status: 500,
+ message: anime.message
+ })
+ } else {
+ res.json({
+ status: 200,
+ message: 'Success',
+ data: anime
+ })
+ }
}
-}
-const getDownloadLinks = async (req, res) => {
- const links = await Oploverz.getDownloadLinks(req.query.link)
- if (!links) {
- res.status(500).json({
- status: 500,
- message: 'Something went wrong'
- })
- } else {
- res.json({
- status: 200,
- message: 'Success',
- data: links
- })
+ async series(req, res) {
+ const episodes = await Oploverz.series(req.query.link)
+ if (!episodes) {
+ res.status(500).json({
+ status: 500,
+ message: episodes.message
+ })
+ } else {
+ res.json({
+ status: 200,
+ message: 'Success',
+ data: episodes
+ })
+ }
+ }
+
+ async getDownloadLinks(req, res) {
+ const links = await Oploverz.getDownloadLinks(req.query.link)
+ if (!links) {
+ res.status(500).json({
+ status: 500,
+ message: links.message
+ })
+ } else {
+ res.json({
+ status: 200,
+ message: 'Success',
+ data: links
+ })
+ }
}
-}
-const hexa = async (req, res) => {
- const hexa = await Oploverz.hexa(req.query.link)
- if (!hexa) {
- res.status(500).json({
- status: 500,
- message: 'Something went wrong'
- })
- } else {
- res.json({
- status: 200,
- message: 'Success',
- data: hexa
- })
+ async hexa(req, res) {
+ const hexa = await Oploverz.hexa(req.query.link)
+ if (!hexa) {
+ res.status(500).json({
+ status: 500,
+ message: hexa.message
+ })
+ } else {
+ res.json({
+ status: 200,
+ message: 'Success',
+ data: hexa
+ })
+ }
}
}
-module.exports = {
- checkOnGoingPage,
- series,
- getDownloadLinks,
- hexa
-}
\ No newline at end of file
+module.exports = new OploverzController
\ No newline at end of file
diff --git a/controllers/SamehadakuController.js b/controllers/SamehadakuController.js
index 9b78692..e49bbbe 100644
--- a/controllers/SamehadakuController.js
+++ b/controllers/SamehadakuController.js
@@ -1,146 +1,150 @@
-const Samehadaku = require('../services/Samehadaku')
-const SamehadakuEas = require('../services/SamehadakuEas')
+const Browser = require('../services/Browser')
+const Samehadaku = new (require('../services/Samehadaku'))(Browser)
+const SamehadakuEas = new (require('../services/SamehadakuEas'))(Browser)
const Util = require('../utils/utils')
-// eslint-disable-next-line no-unused-vars
-const anime = async (req, res) => {
- const episodes = await SamehadakuEas.getEpisodes(req.query.link)
- if (!episodes) {
- res.status(500).json({
- status: 500,
- message: 'Something went wrong'
- })
- } else {
- res.json({
- status: 200,
- message: 'Success',
- data: episodes
- })
+class SamehadakuController {
+ constructor() {
+ this.anime = this.anime.bind(this)
+ this.checkOnGoingPage = this.checkOnGoingPage.bind(this)
+ this.getDownloadLinks = this.getDownloadLinks.bind(this)
+ this.tetew = this.tetew.bind(this)
+ this.njiir = this.njiir.bind(this)
}
-}
-const checkOnGoingPage = async (req, res) => {
- let anime = await SamehadakuEas.checkOnGoingPage()
- let anime2, anime3, anime4, anime5, anime6, anime7
-
- await Promise.all([
- SamehadakuEas.checkOnGoingPage(2),
- SamehadakuEas.checkOnGoingPage(3),
- SamehadakuEas.checkOnGoingPage(4),
- SamehadakuEas.checkOnGoingPage(5),
- SamehadakuEas.checkOnGoingPage(6),
- SamehadakuEas.checkOnGoingPage(7)
- ]).then(values => {
- anime2 = values[0]
- anime3 = values[1]
- anime4 = values[2]
- anime5 = values[3]
- anime6 = values[4]
- anime7 = values[5]
- })
-
- if (!anime) {
- res.status(500).json({
- status: 500,
- message: 'Something went wrong'
- })
- } else {
- if (anime2) {
- await Util.asyncForEach(anime2, item => {
- anime.push(item)
+ async anime(req, res) {
+ const episodes = await SamehadakuEas.getEpisodes(req.query.link)
+ if (!episodes) {
+ res.status(500).json({
+ status: 500,
+ message: episodes.message
})
- }
-
- if (anime3) {
- await Util.asyncForEach(anime3, item => {
- anime.push(item)
- })
- }
-
- if (anime4) {
- await Util.asyncForEach(anime4, item => {
- anime.push(item)
+ } else {
+ res.json({
+ status: 200,
+ message: 'Success',
+ data: episodes
})
}
+ }
- if (anime5) {
- await Util.asyncForEach(anime5, item => {
- anime.push(item)
- })
- }
+ async checkOnGoingPage(req, res) {
+ let anime = await SamehadakuEas.checkOnGoingPage()
+ let anime2, anime3, anime4, anime5, anime6, anime7
+
+ await Promise.all([
+ SamehadakuEas.checkOnGoingPage(2),
+ SamehadakuEas.checkOnGoingPage(3),
+ SamehadakuEas.checkOnGoingPage(4),
+ SamehadakuEas.checkOnGoingPage(5),
+ SamehadakuEas.checkOnGoingPage(6),
+ SamehadakuEas.checkOnGoingPage(7)
+ ]).then(values => {
+ anime2 = values[0]
+ anime3 = values[1]
+ anime4 = values[2]
+ anime5 = values[3]
+ anime6 = values[4]
+ anime7 = values[5]
+ })
- if (anime6) {
- await Util.asyncForEach(anime6, item => {
- anime.push(item)
+ if (!anime) {
+ res.status(500).json({
+ status: 500,
+ message: anime.message
})
- }
+ } else {
+ if (anime2) {
+ await Util.asyncForEach(anime2, item => {
+ anime.push(item)
+ })
+ }
+
+ if (anime3) {
+ await Util.asyncForEach(anime3, item => {
+ anime.push(item)
+ })
+ }
- if (anime7) {
- await Util.asyncForEach(anime7, item => {
- anime.push(item)
+ if (anime4) {
+ await Util.asyncForEach(anime4, item => {
+ anime.push(item)
+ })
+ }
+
+ if (anime5) {
+ await Util.asyncForEach(anime5, item => {
+ anime.push(item)
+ })
+ }
+
+ if (anime6) {
+ await Util.asyncForEach(anime6, item => {
+ anime.push(item)
+ })
+ }
+
+ if (anime7) {
+ await Util.asyncForEach(anime7, item => {
+ anime.push(item)
+ })
+ }
+
+ res.json({
+ status: 200,
+ message: 'Success',
+ data: anime
})
}
-
- res.json({
- status: 200,
- message: 'Success',
- data: anime
- })
}
-}
-const getDownloadLinks = async (req, res) => {
- const links = await Samehadaku.getDownloadLinks(req.query.link)
- if (!links) {
- res.status(500).json({
- status: 500,
- message: 'Something went wrong'
- })
- } else {
- res.json({
- status: 200,
- message: 'Success',
- data: links
- })
+ async getDownloadLinks(req, res) {
+ const links = await Samehadaku.getDownloadLinks(req.query.link)
+ if (!links) {
+ res.status(500).json({
+ status: 500,
+ message: links.message
+ })
+ } else {
+ res.json({
+ status: 200,
+ message: 'Success',
+ data: links
+ })
+ }
}
-}
-const tetew = async (req, res) => {
- const tetew = await Samehadaku.anjay(req.query.link)
- if (!tetew) {
- res.status(500).json({
- status: 500,
- message: 'Something went wrong'
- })
- } else {
- res.json({
- status: 200,
- message: 'Success',
- data: tetew
- })
+ async tetew(req, res) {
+ const tetew = await Samehadaku.anjay(req.query.link)
+ if (!tetew) {
+ res.status(500).json({
+ status: 500,
+ message: tetew.message
+ })
+ } else {
+ res.json({
+ status: 200,
+ message: 'Success',
+ data: tetew
+ })
+ }
}
-}
-const njiir = async (req, res) => {
- const njiir = await Samehadaku.njiir(req.query.link)
- if (!njiir) {
- res.status(500).json({
- status: 500,
- message: 'Something went wrong'
- })
- } else {
- res.json({
- status: 200,
- message: 'Success',
- data: njiir
- })
+ async njiir(req, res) {
+ const njiir = await Samehadaku.njiir(req.query.link)
+ if (!njiir) {
+ res.status(500).json({
+ status: 500,
+ message: njiir.message
+ })
+ } else {
+ res.json({
+ status: 200,
+ message: 'Success',
+ data: njiir
+ })
+ }
}
}
-module.exports = {
- anime,
- checkOnGoingPage,
- getDownloadLinks,
- tetew,
- njiir
-}
\ No newline at end of file
+module.exports = new SamehadakuController
\ No newline at end of file
diff --git a/exceptions/Handler.js b/exceptions/Handler.js
index 9e280cd..9ad39ce 100644
--- a/exceptions/Handler.js
+++ b/exceptions/Handler.js
@@ -4,7 +4,7 @@ const { app_env } = require('../config.json')
const transport = new(transports.DailyRotateFile)({
filename: 'shallty-%DATE%.log',
- datePattern: 'YYYY-MM-DD-HH',
+ datePattern: 'YYYY-MM-DD',
zippedArchive: true,
maxSize: '20m',
maxFiles: '14d',
diff --git a/index.js b/index.js
index 1036dd1..f5df1ee 100644
--- a/index.js
+++ b/index.js
@@ -5,11 +5,22 @@ const Browser = require('./services/Browser')
const { app_port } = require('./config.json')
const runningPort = process.env.PORT || app_port
+const isBrowserReady = (req, res, next) => {
+ if (Browser.browser !== null) {
+ next()
+ } else {
+ res.status(500).json({
+ status: 500,
+ message: 'Browser is not ready, please try again later.'
+ })
+ }
+}
+
app.get(express.json())
-app.get('/', async function (req, res) {
+app.get('/', async (req, res) => {
res.send(`
- You can start crawling via "/api" endpoint. + Welcome! You can start crawling via "/api" endpoint. See https://github.com/gegehprast98/shallty/blob/master/README.md for more information.
`) }) @@ -21,6 +32,8 @@ app.use((req, res, next) => { next() }) +app.use(isBrowserReady) + app.use('/api', routes) app.listen(runningPort, async () => { diff --git a/services/Kiryuu.js b/services/Kiryuu.js index 4694de3..c1b2528 100644 --- a/services/Kiryuu.js +++ b/services/Kiryuu.js @@ -50,6 +50,7 @@ class Kiryuu { */ async getMangaInfo(link) { const page = await this.browser.browser.newPage() + let cover = null try { link = decodeURIComponent(kiryuu_url + link) @@ -63,7 +64,13 @@ class Kiryuu { const title = await infox.$eval('h1', h1 => { return h1.innerText.replace(/ Bahasa Indonesia| Bahasa| Indonesia|/gi, '') }) - const cover = await page.$eval('div.thumb > img', img => img.src) + + if (await page.$('div.thumb > img') !== null) { + cover = await page.$eval('div.thumb > img', img => img.src) + } else { + cover = await page.$eval('div.ime > img', img => img.src) + } + if (await infox.$('span.alter') !== null) { alternate_title = await infox.$eval('span.alter', span => { return span.innerText diff --git a/services/Meownime.js b/services/Meownime.js index 3c83789..6c41f9e 100644 --- a/services/Meownime.js +++ b/services/Meownime.js @@ -1,14 +1,18 @@ -const Browser = require('./Browser') const Util = require('../utils/utils') +const Handler = require('../exceptions/Handler') const { meownime_url } = require('../config.json') class Meownime { + constructor(browser) { + this.browser = browser + } + /** * Parse episodes from completed anime. * @param link anime page. */ async getEpisodes(link) { - const page = await Browser.browser.newPage() + const page = await this.browser.browser.newPage() const episodes = new Map try { @@ -59,11 +63,10 @@ class Meownime { await page.close() return Array.from(episodes) - } catch (e) { - console.log(e) + } catch (error) { await page.close() - return false + return Handler.error(error) } } @@ -72,7 +75,7 @@ class Meownime { * @param link davinsurance page. */ async davinsurance(link) { - const page = await Browser.browser.newPage() + const page = await this.browser.browser.newPage() try { link = decodeURIComponent(link) @@ -97,11 +100,10 @@ class Meownime { splitted = splitted[0].replace(/(['"])+/g, '') return {url: splitted} - } catch (e) { - console.log(e) + } catch (error) { await page.close() - return false + return Handler.error(error) } } @@ -111,7 +113,7 @@ class Meownime { * @param link meowbox page. */ async meowbox(link) { - const page = await Browser.browser.newPage() + const page = await this.browser.browser.newPage() try { link = decodeURIComponent(link) @@ -169,11 +171,10 @@ class Meownime { await page.close() return {url: finalUrl} - } catch (e) { - console.log(e) + } catch (error) { await page.close() - return false + return Handler.error(error) } } @@ -184,7 +185,7 @@ class Meownime { */ async meowdrive(link) { let finalUrl - const page = await Browser.browser.newPage() + const page = await this.browser.browser.newPage() try { link = decodeURIComponent(link) @@ -213,11 +214,10 @@ class Meownime { await page.close() return {url: finalUrl} - } catch (e) { - console.log(e) + } catch (error) { await page.close() - return false + return Handler.error(error) } } @@ -226,7 +226,7 @@ class Meownime { */ async checkOnGoingPage() { const anime = [] - const page = await Browser.browser.newPage() + const page = await this.browser.browser.newPage() try { await page.goto(meownime_url + '/tag/ongoing/', { @@ -252,11 +252,10 @@ class Meownime { await page.close() return anime - } catch (e) { - console.log(e) + } catch (error) { await page.close() - return false + return Handler.error(error) } } @@ -266,7 +265,7 @@ class Meownime { */ async onGoingAnime(link) { const episodes = [] - const page = await Browser.browser.newPage() + const page = await this.browser.browser.newPage() try { link = decodeURIComponent(link) @@ -321,11 +320,10 @@ class Meownime { await page.close() return episodes - } catch (e) { - console.log(e) + } catch (error) { await page.close() - return false + return Handler.error(error) } } @@ -334,7 +332,7 @@ class Meownime { * @param link anime page. */ async getMovieEpisodes(link) { - const page = await Browser.browser.newPage() + const page = await this.browser.browser.newPage() const episodes = [] try { @@ -365,13 +363,12 @@ class Meownime { await page.close() return episodes - } catch (e) { - console.log(e) + } catch (error) { await page.close() - return false + return Handler.error(error) } } } -module.exports = new Meownime \ No newline at end of file +module.exports = Meownime \ No newline at end of file diff --git a/services/Neonime.js b/services/Neonime.js index 887fbd3..2f26c10 100644 --- a/services/Neonime.js +++ b/services/Neonime.js @@ -190,7 +190,7 @@ class Neonime { await page.waitForSelector('.smokeurl').catch(e => { - console.log(e) + Handler.error(e) info1 = true }) @@ -212,10 +212,9 @@ class Neonime { }) } else { await page.waitForSelector('p[data-id="info1"]').catch(async e => { - console.log(e) await page.close() - return false + return Handler.error(e) }) const smokeurls = await page.$$('p[data-id="info1"]') await Util.asyncForEach(smokeurls, async smokeurl => { @@ -276,7 +275,7 @@ class Neonime { await Util.sleep(3000) await page.click('a#link-download') - const newPage = await this.newPagePromise(page, this.browser) + const newPage = await this.newPagePromise(page, this.browser.browser) const url = newPage.url() await page.close() diff --git a/services/Oploverz.js b/services/Oploverz.js index 904035a..5ffefe9 100644 --- a/services/Oploverz.js +++ b/services/Oploverz.js @@ -1,14 +1,18 @@ -const Browser = require('./Browser') const Util = require('../utils/utils') +const Handler = require('../exceptions/Handler') const { oploverz_url } = require('../config.json') class Oploverz { + constructor(browser) { + this.browser = browser + } + /** * Check on going page and get latest released episodes. */ async checkOnGoingPage() { const anime = [] - const page = await Browser.browser.newPage() + const page = await this.browser.browser.newPage() try { await page.setUserAgent('Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/21.0.1180.83 Safari/537.1') @@ -41,11 +45,10 @@ class Oploverz { await page.close() return anime - } catch (e) { - console.log(e) + } catch (error) { await page.close() - return false + return Handler.error(error) } } @@ -55,7 +58,7 @@ class Oploverz { */ async series(link) { const episodes = [] - const page = await Browser.browser.newPage() + const page = await this.browser.browser.newPage() try { link = decodeURIComponent(link) @@ -85,11 +88,10 @@ class Oploverz { await page.close() return episodes - } catch (e) { - console.log(e) + } catch (error) { await page.close() - return false + return Handler.error(error) } } @@ -98,7 +100,7 @@ class Oploverz { * @param link episode page. */ async getDownloadLinks(link) { - const page = await Browser.browser.newPage() + const page = await this.browser.browser.newPage() const downloadLinks = [] try { @@ -133,11 +135,10 @@ class Oploverz { await page.close() return downloadLinks - } catch (e) { - console.log(e) + } catch (error) { await page.close() - return false + return Handler.error(error) } } @@ -148,7 +149,7 @@ class Oploverz { } async hexa(link) { - const page = await Browser.browser.newPage() + const page = await this.browser.browser.newPage() try { link = decodeURIComponent(link) @@ -170,13 +171,12 @@ class Oploverz { await page.close() return {url: url} - } catch (e) { - console.log(e) + } catch (error) { await page.close() - return false + return Handler.error(error) } } } -module.exports = new Oploverz \ No newline at end of file +module.exports = Oploverz \ No newline at end of file diff --git a/services/Samehadaku.js b/services/Samehadaku.js index 1257448..bc9e4f0 100644 --- a/services/Samehadaku.js +++ b/services/Samehadaku.js @@ -1,12 +1,15 @@ -// eslint-disable-next-line no-unused-vars -const Browser = require('./Browser') const Util = require('../utils/utils') +const Handler = require('../exceptions/Handler') const { samehadaku_url, samehadaku_magBoxContainer } = require('../config.json') class Samehadaku { + constructor(browser) { + this.browser = browser + } + /** * Parse and get episode information from a post element handler. * @param post post element handler. @@ -41,7 +44,7 @@ class Samehadaku { let totalPage const pageLimit = 3 const episodes = [] - const page = await Browser.browser.newPage() + const page = await this.browser.browser.newPage() try { link = decodeURIComponent(link) @@ -62,7 +65,7 @@ class Samehadaku { totalPage = parseInt(totalPage[totalPage.length - 1]) totalPage = totalPage > pageLimit ? pageLimit : totalPage } catch (error) { - console.log(error) + Handler.error(error) totalPage = 1 } @@ -92,11 +95,10 @@ class Samehadaku { await page.close() return episodes - } catch (e) { - console.log(e) + } catch (error) { await page.close() - return false + return Handler.error(error) } } @@ -105,7 +107,7 @@ class Samehadaku { */ async checkOnGoingPage() { const anime = [] - const page = await Browser.browser.newPage() + const page = await this.browser.browser.newPage() try { await page.goto(samehadaku_url, { @@ -140,11 +142,10 @@ class Samehadaku { await page.close() return anime - } catch (e) { - console.log(e) + } catch (error) { await page.close() - return false + return Handler.error(error) } } @@ -153,7 +154,7 @@ class Samehadaku { * @param link episode page. */ async getDownloadLinks(link) { - const page = await Browser.browser.newPage() + const page = await this.browser.browser.newPage() const downloadLinks = [] try { @@ -208,11 +209,10 @@ class Samehadaku { await page.close() return downloadLinks - } catch (e) { - console.log(e) + } catch (error) { await page.close() - return false + return Handler.error(error) } } @@ -234,7 +234,7 @@ class Samehadaku { */ async tetew(link, skip = false) { let final - const page = await Browser.browser.newPage() + const page = await this.browser.browser.newPage() try { link = decodeURIComponent(link) @@ -290,11 +290,10 @@ class Samehadaku { } return {url: final} - } catch (e) { - console.log(e) + } catch (error) { await page.close() - return false + return Handler.error(error) } } @@ -304,7 +303,7 @@ class Samehadaku { */ async njiir(link) { let downloadLink, anchor - const page = await Browser.browser.newPage() + const page = await this.browser.browser.newPage() try { link = decodeURIComponent(link) @@ -325,16 +324,15 @@ class Samehadaku { await page.close() return {url: downloadLink} - } catch (e) { - console.log(e) + } catch (error) { await page.close() - return false + return Handler.error(error) } } async eueSiherp(link) { - const page = await Browser.browser.newPage() + const page = await this.browser.browser.newPage() try { link = decodeURIComponent(link) @@ -357,11 +355,10 @@ class Samehadaku { await page.close() return {url: final} - } catch (e) { - console.log(e) + } catch (error) { await page.close() - return false + return Handler.error(error) } } @@ -380,7 +377,7 @@ class Samehadaku { //anjay.info async anjay(link) { - const page = await Browser.browser.newPage() + const page = await this.browser.browser.newPage() try { link = decodeURIComponent(link) @@ -398,7 +395,7 @@ class Samehadaku { await page.waitForSelector('#showlink') await page.click('#showlink') - const newPage = await this.newPagePromise(page, Browser.browser) + const newPage = await this.newPagePromise(page, this.browser.browser) const url = newPage.url() await page.close() @@ -407,13 +404,12 @@ class Samehadaku { const final = this.tetew(url, true) return final - } catch (e) { - console.log(e) + } catch (error) { await page.close() - return false + return Handler.error(error) } } } -module.exports = new Samehadaku \ No newline at end of file +module.exports = Samehadaku \ No newline at end of file diff --git a/services/SamehadakuEas.js b/services/SamehadakuEas.js index 3345ab8..777b492 100644 --- a/services/SamehadakuEas.js +++ b/services/SamehadakuEas.js @@ -1,12 +1,15 @@ -// eslint-disable-next-line no-unused-vars -const Browser = require('./Browser') const Util = require('../utils/utils') +const Handler = require('../exceptions/Handler') const { samehadaku_url } = require('../config.json') class Samehadaku { + constructor(browser) { + this.browser = browser + } + async checkOnGoingPage(navPage = 1) { const anime = [] - const page = await Browser.browser.newPage() + const page = await this.browser.browser.newPage() try { await page.goto(`${samehadaku_url}/page/${navPage}/`, { @@ -40,16 +43,15 @@ class Samehadaku { return anime } catch (error) { - console.log(error) await page.close() - return false + return Handler.error(error) } } async getEpisodes(link) { const episodes = [] - const page = await Browser.browser.newPage() + const page = await this.browser.browser.newPage() try { link = decodeURIComponent(link) @@ -89,13 +91,12 @@ class Samehadaku { await page.close() return episodes - } catch (e) { - console.log(e) + } catch (error) { await page.close() - return false + return Handler.error(error) } } } -module.exports = new Samehadaku \ No newline at end of file +module.exports = Samehadaku \ No newline at end of file