Finale
This commit is contained in:
1 parent
d3d221f9e3
commit
e59845661f
19 files changed
+4803
-4
No files matched your search
+153
@@ -0,0 +1,153 @@
|
||||
const fetch = require('node-fetch'); // Либа для запросов
|
||||
|
||||
exports.getProfileById = async (id) => { // Запрос на получение профиля по айди
|
||||
try {
|
||||
const response = await fetch('https://api.anixart.tv/profile/' + id + '?token=TOKEN')
|
||||
if (response.status !== 200) throw new Error()
|
||||
let body = JSON.parse(await response.text())
|
||||
return body
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
exports.getProfileByName = async (name) => { // Запрос на получение профиля по имени
|
||||
let todo = {
|
||||
query: name,
|
||||
searchBy: 0
|
||||
}
|
||||
|
||||
try {
|
||||
const response = await fetch('https://api.anixart.tv/search/profiles/0?token=TOKEN', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(todo),
|
||||
headers: { 'Content-Type': 'application/json' }
|
||||
})
|
||||
if (response.status !== 200) throw new Error()
|
||||
let body = JSON.parse(await response.text())
|
||||
let profile = null
|
||||
if (body.total_count < 26) {
|
||||
for(let i = 0; i < body.content.length; i++) {
|
||||
let profileLogin = body.content[i].login
|
||||
if(name.toLowerCase() == profileLogin.toLowerCase()) {
|
||||
profile = exports.getProfileById(body.content[i].id)
|
||||
break;
|
||||
}
|
||||
}
|
||||
return profile
|
||||
} else {
|
||||
for(let i = 0; i < Math.ceil(body.total_count/25); i++) { //Поиск аккаунта на других страницах
|
||||
let responseMore = await fetch('https://api.anixart.tv/search/profiles/' + i + '?token=TOKEN', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(todo),
|
||||
headers: { 'Content-Type': 'application/json' }
|
||||
})
|
||||
if (responseMore.status !== 200) throw new Error()
|
||||
let bodyMore = JSON.parse(await responseMore.text())
|
||||
|
||||
for(let a = 0; a < bodyMore.content.length; a++) { //поиск на этой странице
|
||||
let profileLogin = bodyMore.content[a].login
|
||||
if(profileLogin && name.toLowerCase() == profileLogin.toLowerCase()) {
|
||||
profile = exports.getProfileById(bodyMore.content[a].id)
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return profile
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
exports.getUserAnimeList = async (id, listType, page) => { // Запрос на получение списка (просмотренные, в планах и т.д.)
|
||||
try {
|
||||
const response = await fetch('https://api.anixart.tv/profile/list/all/' + id + "/" + listType + "/" + page + '?token=TOKEN')
|
||||
if (response.status !== 200) throw new Error()
|
||||
let body = JSON.parse(await response.text())
|
||||
return body
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
exports.getAnimeInfo = async (id) => { // Запрос на получение инфы об аниме
|
||||
try {
|
||||
const response = await fetch('https://api.anixart.tv/release/' + id + '?token=TOKEN')
|
||||
if (response.status !== 200) throw new Error()
|
||||
let body = JSON.parse(await response.text())
|
||||
return body
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
exports.getAnimeList = async (page, type) => { // Запрос на получение листа аниме по жанрам (тут новое, интересное)
|
||||
let todo = {
|
||||
sort: parseInt(type),
|
||||
extended_mode: true
|
||||
}
|
||||
|
||||
try {
|
||||
const response = await fetch('https://api.anixart.tv/filter/'+ page +'?token=TOKEN', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(todo),
|
||||
headers: { 'Content-Type': 'application/json' }
|
||||
})
|
||||
if (response.status !== 200) throw new Error()
|
||||
let body = JSON.parse(await response.text())
|
||||
return body
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
exports.getRandomAnime = async () => { // Случайное аниме
|
||||
try {
|
||||
const response = await fetch('https://api.anixart.tv/release/random?token=TOKEN')
|
||||
if (response.status !== 200) throw new Error()
|
||||
let body = JSON.parse(await response.text())
|
||||
return body
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
exports.getInterestingAnime = async () => { // Интересное
|
||||
try {
|
||||
const response = await fetch('https://api.anixart.tv/discover/interesting?token=TOKEN')
|
||||
if (response.status !== 200) throw new Error()
|
||||
let body = JSON.parse(await response.text())
|
||||
return body
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
exports.getAnimeByName = async (text) => { // Аниме по названию
|
||||
let todo = {
|
||||
query: text,
|
||||
searchBy: 0
|
||||
}
|
||||
|
||||
try {
|
||||
const response = await fetch('https://api.anixart.tv/search/releases/0?token=TOKEN', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(todo),
|
||||
headers: { 'Content-Type': 'application/json' }
|
||||
})
|
||||
if (response.status !== 200) throw new Error()
|
||||
let body = JSON.parse(await response.text())
|
||||
return body
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user