Comparing version 1.3.4 to 1.3.5
23
index.js
@@ -1,2 +0,2 @@ | ||
const axios = require('axios').default; | ||
const axios = require('axios').default, c = require('cheerio'); | ||
const opt = { | ||
@@ -31,2 +31,20 @@ headers: { | ||
} | ||
async function get_character_amount(){ | ||
const res = await axios({url: 'https://www.animecharactersdatabase.com/charactershub.php?load=c_latest', method: 'get'}), $ = c.load(res.data); | ||
let number = 0; | ||
$('h3').each((idx, el) => { | ||
if(el.children[0].data){ | ||
if(el.children[0].data.toLowerCase().includes('characters')){ | ||
const new_number = parseInt(el.children[0].data.split(/ +/)[0]); | ||
number = new_number; | ||
} | ||
} | ||
}); | ||
return number; | ||
} | ||
async function get_random_character(){ | ||
const allIDs = await get_character_amount(), url = `http://www.animecharactersdatabase.com/api_series_characters.php?character_id=${Math.floor(Math.random() * allIDs)}`; | ||
const res = await axios({url: url, method: 'get', opt}); | ||
return res.data; | ||
} | ||
module.exports = { | ||
@@ -36,3 +54,4 @@ get_character_by_id, | ||
get_character_by_search, | ||
get_anime_by_search | ||
get_anime_by_search, | ||
get_random_character | ||
} |
{ | ||
"name": "acb-api", | ||
"version": "1.3.4", | ||
"version": "1.3.5", | ||
"description": "a api that uses the animecharacterdatabase and access information from there", | ||
@@ -21,4 +21,5 @@ "main": "index.js", | ||
"dependencies": { | ||
"axios": "^0.21.1" | ||
"axios": "^0.21.1", | ||
"cheerio": "^1.0.0-rc.5" | ||
} | ||
} |
@@ -127,2 +127,14 @@ # ACB Information Api | ||
} | ||
get_random_character returns: | ||
{ | ||
"id": 666, | ||
"anime_id": 90, | ||
"anime_image": "http://ami.animecharactersdatabase.com/productimages/90.jpg", | ||
"character_image": "http://ami.animecharactersdatabase.com/./images/maihime/Reito_thumb.jpg", | ||
"origin": "Mai-HiME - The Genealogical Tree of Fate", | ||
"gender": "Male", | ||
"name": "Reito Kanzaki", | ||
"desc": "Reito Kanzaki is a character from the visual novel Mai-HiME - The Genealogical Tree of Fate." | ||
} | ||
``` |
@@ -13,2 +13,5 @@ const a = require('./index'); | ||
console.log(res); | ||
}); | ||
a.get_random_character().then(res => { | ||
console.log(res); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
8088
69
139
2
+ Addedcheerio@^1.0.0-rc.5
+ Addedboolbase@1.0.0(transitive)
+ Addedcheerio@1.0.0(transitive)
+ Addedcheerio-select@2.1.0(transitive)
+ Addedcss-select@5.1.0(transitive)
+ Addedcss-what@6.1.0(transitive)
+ Addeddom-serializer@2.0.0(transitive)
+ Addeddomelementtype@2.3.0(transitive)
+ Addeddomhandler@5.0.3(transitive)
+ Addeddomutils@3.1.0(transitive)
+ Addedencoding-sniffer@0.2.0(transitive)
+ Addedentities@4.5.0(transitive)
+ Addedhtmlparser2@9.1.0(transitive)
+ Addediconv-lite@0.6.3(transitive)
+ Addednth-check@2.1.1(transitive)
+ Addedparse5@7.2.1(transitive)
+ Addedparse5-htmlparser2-tree-adapter@7.1.0(transitive)
+ Addedparse5-parser-stream@7.1.2(transitive)
+ Addedsafer-buffer@2.1.2(transitive)
+ Addedundici@6.21.0(transitive)
+ Addedwhatwg-encoding@3.1.1(transitive)
+ Addedwhatwg-mimetype@4.0.0(transitive)