2016-11-21 14:33:22 +00:00
|
|
|
// This file is required by the index.html file and will
|
|
|
|
// be executed in the renderer process for that window.
|
|
|
|
// All of the Node.js APIs are available in this process.
|
|
|
|
|
|
|
|
const remote = require('electron').remote
|
|
|
|
const main = remote.require('./main.js')
|
2016-11-25 01:02:36 +00:00
|
|
|
const os = require('os')
|
2016-11-21 14:33:22 +00:00
|
|
|
|
2016-11-24 18:34:06 +00:00
|
|
|
// Mal API
|
|
|
|
const mal = require('malapi').Anime
|
|
|
|
// Nyaa API
|
|
|
|
const Nyaa = require('node-nyaa-api')
|
2016-11-21 14:33:22 +00:00
|
|
|
|
2016-11-21 19:08:13 +00:00
|
|
|
|
|
|
|
function reduceString(string) {
|
|
|
|
if (string.length > 100)
|
|
|
|
return string.substring(0, 100) + ('...')
|
|
|
|
return string
|
|
|
|
}
|
|
|
|
|
2016-11-24 18:34:06 +00:00
|
|
|
// I like HorribleSubs
|
2016-11-21 14:33:22 +00:00
|
|
|
function horribleSubsFilter(name) {
|
|
|
|
if ('[HorribleSubs]' === name.split(' ')[0])
|
|
|
|
{
|
|
|
|
if ('[720p].mkv' === name.split(' ').reverse()[0])
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2016-11-24 18:34:06 +00:00
|
|
|
function getNameOnly(name) {
|
|
|
|
let tmp = name.split(' ')
|
|
|
|
tmp.pop()
|
|
|
|
tmp.shift()
|
|
|
|
return tmp.join(' ')
|
2016-11-21 19:08:13 +00:00
|
|
|
}
|
|
|
|
|
2016-11-24 18:34:06 +00:00
|
|
|
// Make the research for the latest animes
|
|
|
|
Nyaa.get_latest( function (err, animes) {
|
|
|
|
if (err) throw err
|
2016-11-21 19:08:13 +00:00
|
|
|
|
2016-11-24 18:34:06 +00:00
|
|
|
for(let anime in animes)
|
2016-11-21 14:33:22 +00:00
|
|
|
{
|
2016-11-24 18:34:06 +00:00
|
|
|
if (horribleSubsFilter(animes[anime].title))
|
2016-11-21 14:33:22 +00:00
|
|
|
{
|
2016-11-24 18:34:06 +00:00
|
|
|
let tmp = animes[anime].title.split(' ')
|
|
|
|
tmp.pop() // Remove the episode number
|
|
|
|
tmp.pop() // Remove the annoying '-'
|
|
|
|
|
|
|
|
// Make the actual research
|
|
|
|
mal.fromName(tmp.join(' ')).then(result => {
|
|
|
|
releases.releases.push({
|
|
|
|
title: getNameOnly(animes[anime].title),
|
|
|
|
link: animes[anime].link,
|
|
|
|
synopsis: reduceString(result.synopsis),
|
|
|
|
picture: result.image
|
|
|
|
})
|
|
|
|
})
|
2016-11-21 14:33:22 +00:00
|
|
|
}
|
|
|
|
}
|
2016-11-21 19:56:00 +00:00
|
|
|
})
|
2016-11-21 19:08:13 +00:00
|
|
|
|
2016-11-24 18:34:06 +00:00
|
|
|
let releases = new Vue({
|
|
|
|
el: '#releases',
|
2016-11-21 19:56:00 +00:00
|
|
|
data: {
|
2016-11-24 18:34:06 +00:00
|
|
|
releases: []
|
2016-11-21 14:33:22 +00:00
|
|
|
},
|
2016-11-24 18:34:06 +00:00
|
|
|
watch: {
|
|
|
|
releases: function () { // Whenever releases changes, this function will run
|
2016-11-25 01:02:36 +00:00
|
|
|
// Code
|
2016-11-21 14:33:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
2016-11-21 14:48:04 +00:00
|
|
|
|
2016-11-24 18:34:06 +00:00
|
|
|
// Vue object to open the other pages
|
|
|
|
new Vue({
|
|
|
|
el: '.mdl-navigation',
|
2016-11-21 14:48:04 +00:00
|
|
|
methods: {
|
2016-11-24 18:34:06 +00:00
|
|
|
getDownloader: function () {
|
|
|
|
main.openDownloader()
|
|
|
|
},
|
|
|
|
getInfoPage: function () {
|
|
|
|
main.getInfoPage()
|
2016-11-21 14:48:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
2016-11-25 01:02:36 +00:00
|
|
|
|
|
|
|
// For the greeting's message
|
|
|
|
new Vue({
|
|
|
|
el: '.greetings',
|
|
|
|
data: {
|
|
|
|
username: os.userInfo().username
|
|
|
|
}
|
|
|
|
})
|