|
|
|
@ -537,15 +537,17 @@ class AnimeInfo
|
|
|
|
|
*
|
|
|
|
|
* @param {String} title
|
|
|
|
|
* @param {String} status
|
|
|
|
|
* @param {String} url
|
|
|
|
|
* @param {String} episodes
|
|
|
|
|
* @param {String} trailer
|
|
|
|
|
* @param {String} description
|
|
|
|
|
* @param {String} coverImage
|
|
|
|
|
*/
|
|
|
|
|
constructor(title, status, episodes, trailer, description, coverImage)
|
|
|
|
|
constructor(title, status, episodes, url , trailer, description, coverImage)
|
|
|
|
|
{
|
|
|
|
|
this.title = title;
|
|
|
|
|
this.status = status;
|
|
|
|
|
this.url = url
|
|
|
|
|
this.episodes=episodes;
|
|
|
|
|
this.trailer = trailer;
|
|
|
|
|
this.description = description;
|
|
|
|
@ -559,12 +561,14 @@ class CharInfo
|
|
|
|
|
* @param {String} name
|
|
|
|
|
* @param {String} gender
|
|
|
|
|
* @param {String} image
|
|
|
|
|
* @param {String} url
|
|
|
|
|
* @param {String} description
|
|
|
|
|
*/
|
|
|
|
|
constructor(name, gender, image, description)
|
|
|
|
|
{
|
|
|
|
|
this.name = name;
|
|
|
|
|
this.gender = gender;
|
|
|
|
|
this.url = url
|
|
|
|
|
this.image=image;
|
|
|
|
|
this.description = description;
|
|
|
|
|
}
|
|
|
|
@ -575,6 +579,7 @@ class MangaInfo
|
|
|
|
|
*
|
|
|
|
|
* @param {String} title
|
|
|
|
|
* @param {String} status
|
|
|
|
|
* @param {String} url
|
|
|
|
|
* @param {String} description
|
|
|
|
|
* @param {String} coverImage
|
|
|
|
|
*/
|
|
|
|
@ -582,12 +587,54 @@ class MangaInfo
|
|
|
|
|
{
|
|
|
|
|
this.title = title;
|
|
|
|
|
this.status = status;
|
|
|
|
|
this.url = url
|
|
|
|
|
this.description = description;
|
|
|
|
|
this.coverImage = coverImage;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
class Options
|
|
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
* @param {String} method
|
|
|
|
|
* @param {String} headers
|
|
|
|
|
* @param {String} body
|
|
|
|
|
*/
|
|
|
|
|
constructor(method, headers, body)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
this.method = method;
|
|
|
|
|
this.headers = headers;
|
|
|
|
|
this.body = body;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class aniListCli {
|
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
* @param {Options} options
|
|
|
|
|
* @returns {Info}
|
|
|
|
|
*/
|
|
|
|
|
async getInfo(options)
|
|
|
|
|
{
|
|
|
|
|
return await fetch('https://graphql.anilist.co', options).then(handleResponse)
|
|
|
|
|
.then(handleData)
|
|
|
|
|
.catch(handleError);
|
|
|
|
|
function handleResponse(response)
|
|
|
|
|
{
|
|
|
|
|
return response.json().then(function (json)
|
|
|
|
|
{
|
|
|
|
|
return response.ok ? json : Promise.reject(json);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
function handleData(data)
|
|
|
|
|
{
|
|
|
|
|
return data
|
|
|
|
|
}
|
|
|
|
|
function handleError(error) {
|
|
|
|
|
return error;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
* @param {String} ss - Search Query
|
|
|
|
@ -615,8 +662,7 @@ class aniListCli {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
`
|
|
|
|
|
var url = 'https://graphql.anilist.co',
|
|
|
|
|
options = {
|
|
|
|
|
var options = {
|
|
|
|
|
method: 'POST',
|
|
|
|
|
headers: {
|
|
|
|
|
'Content-Type': 'application/json',
|
|
|
|
@ -627,33 +673,20 @@ class aniListCli {
|
|
|
|
|
variables
|
|
|
|
|
})
|
|
|
|
|
};
|
|
|
|
|
return await fetch(url, options).then(handleResponse)
|
|
|
|
|
.then(handleData)
|
|
|
|
|
.catch(handleError);
|
|
|
|
|
function handleResponse(response)
|
|
|
|
|
{
|
|
|
|
|
return response.json().then(function (json)
|
|
|
|
|
{
|
|
|
|
|
return response.ok ? json : Promise.reject(json);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
function handleError(error) {
|
|
|
|
|
return error;
|
|
|
|
|
}
|
|
|
|
|
function handleData(data) {
|
|
|
|
|
data = data.data.Page.media
|
|
|
|
|
if(!data[0]) return 'Error'
|
|
|
|
|
var aux = [];
|
|
|
|
|
for(var anime of data)
|
|
|
|
|
{
|
|
|
|
|
aux.push({
|
|
|
|
|
title:anime.title,
|
|
|
|
|
id:anime.id,
|
|
|
|
|
coverImage:anime.coverImage.medium
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
return aux;
|
|
|
|
|
}
|
|
|
|
|
var data = await this.getInfo(options)
|
|
|
|
|
|
|
|
|
|
data = data.data.Page.media
|
|
|
|
|
if(!data[0]) return 'Error'
|
|
|
|
|
var aux = [];
|
|
|
|
|
for(var anime of data)
|
|
|
|
|
{
|
|
|
|
|
aux.push({
|
|
|
|
|
title:anime.title,
|
|
|
|
|
id:anime.id,
|
|
|
|
|
coverImage:anime.coverImage.medium
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
return aux;
|
|
|
|
|
}
|
|
|
|
|
async getAnimeInfo(id)
|
|
|
|
|
{
|
|
|
|
@ -682,8 +715,7 @@ class aniListCli {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}`;
|
|
|
|
|
var url = 'https://graphql.anilist.co',
|
|
|
|
|
options = {
|
|
|
|
|
var options = {
|
|
|
|
|
method: 'POST',
|
|
|
|
|
headers: {
|
|
|
|
|
'Content-Type': 'application/json',
|
|
|
|
@ -694,32 +726,17 @@ class aniListCli {
|
|
|
|
|
variables
|
|
|
|
|
})
|
|
|
|
|
};
|
|
|
|
|
return await fetch(url, options).then(handleResponse)
|
|
|
|
|
.then(handleData)
|
|
|
|
|
.catch(handleError);
|
|
|
|
|
function handleResponse(response)
|
|
|
|
|
{
|
|
|
|
|
return response.json().then(function (json)
|
|
|
|
|
{
|
|
|
|
|
return response.ok ? json : Promise.reject(json);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
function handleError(error) {
|
|
|
|
|
return error;
|
|
|
|
|
}
|
|
|
|
|
function handleData(data) {
|
|
|
|
|
return {
|
|
|
|
|
title:data.data.Media.title,
|
|
|
|
|
malLink:'https://myanimelist.net/anime/'+data.data.Media.idMal,
|
|
|
|
|
status:data.data.Media.status,
|
|
|
|
|
url:data.data.Media.siteUrl,
|
|
|
|
|
episodes:data.data.Media.episodes,
|
|
|
|
|
trailer:data.data.Media.trailer,
|
|
|
|
|
description:data.data.Media.description,
|
|
|
|
|
coverImage:data.data.Media.coverImage.large
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var data = await this.getInfo(options);
|
|
|
|
|
return {
|
|
|
|
|
title:data.data.Media.title,
|
|
|
|
|
malLink:'https://myanimelist.net/anime/'+data.data.Media.idMal,
|
|
|
|
|
status:data.data.Media.status,
|
|
|
|
|
url:data.data.Media.siteUrl,
|
|
|
|
|
episodes:data.data.Media.episodes,
|
|
|
|
|
trailer:data.data.Media.trailer,
|
|
|
|
|
description:data.data.Media.description,
|
|
|
|
|
coverImage:data.data.Media.coverImage.large
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
@ -750,8 +767,7 @@ class aniListCli {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
`;
|
|
|
|
|
var url = 'https://graphql.anilist.co',
|
|
|
|
|
options = {
|
|
|
|
|
var options = {
|
|
|
|
|
method: 'POST',
|
|
|
|
|
headers: {
|
|
|
|
|
'Content-Type': 'application/json',
|
|
|
|
@ -762,36 +778,21 @@ class aniListCli {
|
|
|
|
|
variables
|
|
|
|
|
})
|
|
|
|
|
};
|
|
|
|
|
return await fetch(url, options).then(handleResponse)
|
|
|
|
|
.then(handleData)
|
|
|
|
|
.catch(handleError);
|
|
|
|
|
function handleResponse(response)
|
|
|
|
|
var data = await this.getInfo(options)
|
|
|
|
|
var chars = data.data.Page.characters
|
|
|
|
|
var aux = [];
|
|
|
|
|
if(!chars[0]) return 'Error'
|
|
|
|
|
for(var char of chars)
|
|
|
|
|
{
|
|
|
|
|
return response.json().then(function (json)
|
|
|
|
|
{
|
|
|
|
|
return response.ok ? json : Promise.reject(json);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
function handleError(error) {
|
|
|
|
|
return error;
|
|
|
|
|
}
|
|
|
|
|
function handleData(data) {
|
|
|
|
|
var chars = data.data.Page.characters
|
|
|
|
|
var aux = [];
|
|
|
|
|
if(!chars[0]) return 'Error'
|
|
|
|
|
for(var char of chars)
|
|
|
|
|
{
|
|
|
|
|
aux.push({
|
|
|
|
|
id:char.id,
|
|
|
|
|
name:char.name,
|
|
|
|
|
gender:char.gender,
|
|
|
|
|
url:char.siteUrl,
|
|
|
|
|
image:char.image.medium
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
return aux;
|
|
|
|
|
aux.push({
|
|
|
|
|
id:char.id,
|
|
|
|
|
name:char.name,
|
|
|
|
|
gender:char.gender,
|
|
|
|
|
url:char.siteUrl,
|
|
|
|
|
image:char.image.medium
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return aux;
|
|
|
|
|
}
|
|
|
|
|
async getCharInfo(id)
|
|
|
|
|
{
|
|
|
|
@ -815,8 +816,7 @@ class aniListCli {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
`;
|
|
|
|
|
var url = 'https://graphql.anilist.co',
|
|
|
|
|
options = {
|
|
|
|
|
var options = {
|
|
|
|
|
method: 'POST',
|
|
|
|
|
headers: {
|
|
|
|
|
'Content-Type': 'application/json',
|
|
|
|
@ -827,28 +827,15 @@ class aniListCli {
|
|
|
|
|
variables
|
|
|
|
|
})
|
|
|
|
|
};
|
|
|
|
|
return await fetch(url, options).then(handleResponse)
|
|
|
|
|
.then(handleData)
|
|
|
|
|
.catch(handleError);
|
|
|
|
|
function handleResponse(response)
|
|
|
|
|
{
|
|
|
|
|
return response.json().then(function (json)
|
|
|
|
|
{
|
|
|
|
|
return response.ok ? json : Promise.reject(json);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
function handleError(error) {
|
|
|
|
|
return error;
|
|
|
|
|
}
|
|
|
|
|
function handleData(data) {
|
|
|
|
|
return {
|
|
|
|
|
name:data.data.Character.name,
|
|
|
|
|
gender:data.data.Character.gender,
|
|
|
|
|
url:data.data.Character.siteUrl,
|
|
|
|
|
image:data.data.Character.image.medium,
|
|
|
|
|
description:data.data.Character.description,
|
|
|
|
|
}
|
|
|
|
|
var data = await this.getInfo(options)
|
|
|
|
|
return {
|
|
|
|
|
name:data.data.Character.name,
|
|
|
|
|
gender:data.data.Character.gender,
|
|
|
|
|
url:data.data.Character.siteUrl,
|
|
|
|
|
image:data.data.Character.image.medium,
|
|
|
|
|
description:data.data.Character.description,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
@ -878,8 +865,7 @@ class aniListCli {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}`
|
|
|
|
|
var url = 'https://graphql.anilist.co',
|
|
|
|
|
options = {
|
|
|
|
|
var options = {
|
|
|
|
|
method: 'POST',
|
|
|
|
|
headers: {
|
|
|
|
|
'Content-Type': 'application/json',
|
|
|
|
@ -890,33 +876,20 @@ class aniListCli {
|
|
|
|
|
variables
|
|
|
|
|
})
|
|
|
|
|
};
|
|
|
|
|
return await fetch(url, options).then(handleResponse)
|
|
|
|
|
.then(handleData)
|
|
|
|
|
.catch(handleError);
|
|
|
|
|
function handleResponse(response)
|
|
|
|
|
var data = await this.getInfo(options)
|
|
|
|
|
var mangas = data.data.Page.media;
|
|
|
|
|
var aux = [];
|
|
|
|
|
if(!mangas[0]) return 'Error'
|
|
|
|
|
for(var manga of mangas)
|
|
|
|
|
{
|
|
|
|
|
return response.json().then(function (json)
|
|
|
|
|
{
|
|
|
|
|
return response.ok ? json : Promise.reject(json);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
function handleError(error) {
|
|
|
|
|
return error;
|
|
|
|
|
}
|
|
|
|
|
function handleData(data) {
|
|
|
|
|
var mangas = data.data.Page.media;
|
|
|
|
|
var aux = [];
|
|
|
|
|
if(!mangas[0]) return 'Error'
|
|
|
|
|
for(var manga of mangas)
|
|
|
|
|
{
|
|
|
|
|
aux.push({
|
|
|
|
|
id:manga.id,
|
|
|
|
|
title:manga.title,
|
|
|
|
|
image:manga.coverImage.medium
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
return aux;
|
|
|
|
|
aux.push({
|
|
|
|
|
id:manga.id,
|
|
|
|
|
title:manga.title,
|
|
|
|
|
image:manga.coverImage.medium
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
return aux;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
async getMangaInfo(id)
|
|
|
|
|
{
|
|
|
|
@ -939,8 +912,7 @@ class aniListCli {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
`;
|
|
|
|
|
var url = 'https://graphql.anilist.co',
|
|
|
|
|
options = {
|
|
|
|
|
var options = {
|
|
|
|
|
method: 'POST',
|
|
|
|
|
headers: {
|
|
|
|
|
'Content-Type': 'application/json',
|
|
|
|
@ -951,29 +923,14 @@ class aniListCli {
|
|
|
|
|
variables
|
|
|
|
|
})
|
|
|
|
|
};
|
|
|
|
|
return await fetch(url, options).then(handleResponse)
|
|
|
|
|
.then(handleData)
|
|
|
|
|
.catch(handleError);
|
|
|
|
|
function handleResponse(response)
|
|
|
|
|
{
|
|
|
|
|
return response.json().then(function (json)
|
|
|
|
|
{
|
|
|
|
|
return response.ok ? json : Promise.reject(json);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
function handleError(error) {
|
|
|
|
|
return error;
|
|
|
|
|
}
|
|
|
|
|
function handleData(data) {
|
|
|
|
|
return {
|
|
|
|
|
title:data.data.Media.title,
|
|
|
|
|
status:data.data.Media.status,
|
|
|
|
|
url:data.data.Media.siteUrl,
|
|
|
|
|
description:data.data.Media.description,
|
|
|
|
|
coverImage:data.data.Media.coverImage.large
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var data = await this.getInfo(options)
|
|
|
|
|
return {
|
|
|
|
|
title:data.data.Media.title,
|
|
|
|
|
status:data.data.Media.status,
|
|
|
|
|
url:data.data.Media.siteUrl,
|
|
|
|
|
description:data.data.Media.description,
|
|
|
|
|
coverImage:data.data.Media.coverImage.large
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}module.exports.aniList = aniListCli;
|
|
|
|
|