Releases now use malScraper => Faster and "better".

Fixed a bug related to JSON import that was making KawAnime crash on start.
This commit is contained in:
Kylart 2017-03-30 01:02:01 +02:00
parent 6a6d45608a
commit ffcfc6ec09
3 changed files with 17 additions and 16 deletions

View File

@ -26,7 +26,7 @@ fs.access(path.join(os.userInfo().homedir, '.KawAnime', 'config.json'), fs.const
{
console.log('Creating initial config file.')
const initPath = path.join(os.userInfo().homedir, '.Downloads')
const initPath = path.join(os.userInfo().homedir, 'Downloads')
const initConf = {
config: {

View File

@ -13,7 +13,7 @@ const path = require('path')
const os = require('os')
// Config file
const configFile = JSON.parse(require(path.join(os.userInfo().homedir, '.KawAnime', 'config.json')).config)
const configFile = require(path.join(os.userInfo().homedir, '.KawAnime', 'config.json')).config
const downloadRep = configFile.localPath
const ascending = true

View File

@ -16,7 +16,7 @@ const quality = '720p'
const path = require('path')
const Nyaa = require('node-nyaa-api')
const mal = require('malapi').Anime
const malScraper = require('mal-scraper')
const {loader} = require(path.join(__dirname, '..', 'renderer.js'))
exports.reduceString = (string, wanted) => {
@ -62,8 +62,18 @@ exports.getLatest = () => {
published: release.published
}
// Research MAL for info
mal.fromName(name).then((anime) => {
malScraper.getResultsFromSearch(name).then((items) => {
return malScraper.getInfoFromURI(malScraper.getBestMatch(name, items))
}).then((item) => {
result.synopsis = item.synopsis
result.reducedSynopsis = item.synopsis.length > 100
? item.synopsis.slice(0, 100) + '...'
: item.synopsis
result.picture = item.image_url
latestReleases.push(result)
latestReleases.sort(self.byProperty('published')).reverse()
++counter
if (counter === nyaaReleases.length)
{
@ -73,18 +83,9 @@ exports.getLatest = () => {
index.releases.show = true
console.log('Releases updated.')
}
index.releases.releases = latestReleases
}
result.synopsis = anime.synopsis
result.reducedSynopsis = anime.synopsis.length > 100
? anime.synopsis.slice(0, 100) + '...'
: anime.synopsis
result.picture = anime.image
latestReleases.push(result)
latestReleases.sort(self.byProperty('published')).reverse()
index.releases.releases = latestReleases
})
})
})