Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions lib/util/Request.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const cheerio = require("cheerio");
const Qs = require("qs");

const baseUrl = "https://nhentai.net";
const pipeUrl = (url) => `https://translate.google.com/translate?sl=vi&tl=en&hl=vi&u=${url}&client=webapp`;

/**
* @class Request
Expand All @@ -17,7 +18,7 @@ module.exports = class Request {
* @returns {object|null} nHentai book API
*/
async getBook(bookID) {
let json = `${baseUrl}/api/gallery/${bookID}`;
let json = pipeUrl(`${baseUrl}/api/gallery/${bookID}`);

return axios
.get(json)
Expand All @@ -36,7 +37,7 @@ module.exports = class Request {
* @return {object|null} nHentai book API
*/
async getRelated(bookID) {
let json = `${baseUrl}/api/gallery/${bookID}/related`;
let json = pipeUrl(`${baseUrl}/api/gallery/${bookID}/related`);

return axios
.get(json)
Expand All @@ -56,7 +57,7 @@ module.exports = class Request {
*/
async getList(url) {
return axios
.get(url)
.get(pipeUrl(url))
.then((res) => {
const $ = cheerio.load(res.data, {
decodeEntities: false,
Expand Down Expand Up @@ -131,7 +132,7 @@ module.exports = class Request {
* @returns {object} nHentai popular list
*/
async getPopularNow() {
return axios.get(baseUrl).then((res) => {
return axios.get(pipeUrl(baseUrl)).then((res) => {
const $ = cheerio.load(res.data, {
decodeEntities: false,
});
Expand Down