KawAnime/assets/api/seasons.js

31 lines
798 B
JavaScript
Raw Normal View History

2017-04-15 14:16:14 +00:00
/**
* Created by Kylart on 03/04/2017.
*/
const malScraper = require('mal-scraper')
const qs = require('querystring')
exports.getSeason = (url, res) => {
const query = qs.parse(url.query.replace('?', ''))
malScraper.getSeason(query.year, query.season).then((result) => {
console.log(`[Mal-Scraper] (Seasons): Now having ${query.season} ${query.year}.`)
2017-07-07 11:07:44 +00:00
const keys = Object.keys(result.info)
keys.forEach((key) => {
result.info[key].forEach((elem, index) => {
result.info[key][index].key = Math.random()
})
})
2017-05-08 13:18:10 +00:00
res.writeHead(200, {'Content-Type': 'application/json'})
2017-04-15 14:16:14 +00:00
res.write(JSON.stringify(result))
res.end()
}).catch((err) => {
console.log('[MalScraper] (Seasons): ' + err.message)
res.writeHead(204, {})
res.end()
2017-04-15 14:16:14 +00:00
})
}