diff --git a/app/Downloader/downloader.js b/app/Downloader/downloader.js index 11d15f7..4022850 100644 --- a/app/Downloader/downloader.js +++ b/app/Downloader/downloader.js @@ -83,7 +83,7 @@ function startTorrent () { openCmd = 'xdg-open ' break case 'win32': - openCmd = '' + openCmd = 'start ' } exec(openCmd + torrents, (error, stdout, stderr) => { diff --git a/app/InformationPage/informations.js b/app/InformationPage/informations.js index f5f7cc3..494e38c 100644 --- a/app/InformationPage/informations.js +++ b/app/InformationPage/informations.js @@ -174,7 +174,7 @@ let container = new Vue({ function makeResearch(name) { mal.fromName(name).then(anime => { - let t0 = performance.now(); + let t0 = performance.now() animeData.title = anime.title animeData.japaneseTitle = anime.japaneseTitle animeData.image = anime.image @@ -188,7 +188,7 @@ function makeResearch(name) { animeData.type = anime.type.split(' ').slice(0, 3).join(' ') animeData.characters = anime.characters animeData.staff = anime.staff - let t1 = performance.now(); + let t1 = performance.now() console.log("Information gathered in " + (t1 - t0) + " seconds.") }) } diff --git a/app/style.css b/app/style.css index 861dc91..5413493 100644 --- a/app/style.css +++ b/app/style.css @@ -130,7 +130,58 @@ body { position: absolute; bottom: 0; - /*content: url('../resources/totoro-hoola-hoop.gif');*/ margin-left: 20%; margin-right: 20%; + content: url('https://media.giphy.com/media/pt0EKLDJmVvlS/giphy.gif'); +} + +/* ----------------- INFOS ----------------- */ +#info-container +{ + width: 100%; + height: 100%; + display: none; +} + +#info-container .mdl-grid +{ + padding-top: 0; + padding-left: 0; +} + +#info-picture +{ + margin-left: 0; + margin-top: 0; +} + +#info-title +{ + text-align: center; +} + +#info-title h5 +{ + margin: 2% 0 0 0; +} + +#synopsis-container +{ + display: flex; + align-items: center; + height: 100%; +} + +#synopsis-container pre +{ + box-shadow: 0 2px 2px 0 rgba(0,0,0,.14),0 3px 1px -2px rgba(0,0,0,.2),0 1px 5px 0 rgba(0,0,0,.12); + margin-top: 0; + line-height: 130%; + text-align: justify; + text-indent: 20px; + white-space: pre-wrap; + word-wrap: break-word; + font-family: inherit; + padding: 3% 3% 3% 3%; + background-color: rgba(255, 255, 255, 0.7); } \ No newline at end of file diff --git a/index.html b/index.html index 9ac64ec..c0455e4 100644 --- a/index.html +++ b/index.html @@ -66,10 +66,11 @@ - download! + download! - + more @@ -81,7 +82,48 @@ 少々お待ち下さい。 - + + + + + + + + + + {{ infos.title }} + + + {{ infos.synopsis }} + + + + + + + + Studios + + {{ studio }} + + + + Characters + + + {{ character.name }} + {{ character.actor }} + + + + + + + {{ infos.stats.score.value}} + {{ infos.stats.ranking}} + + diff --git a/main.js b/main.js index eb935de..20ed51a 100644 --- a/main.js +++ b/main.js @@ -18,7 +18,7 @@ function createWindow () { height: 800, titleBarStyle: 'hidden', show: false, - title: 'KawAnime', + title: 'KawAnime' }) // and load the index.html of the app. diff --git a/renderer.js b/renderer.js index f371e44..9085487 100644 --- a/renderer.js +++ b/renderer.js @@ -2,6 +2,8 @@ // be executed in the renderer process for that window. // All of the Node.js APIs are available in this process. +/* ------------------ IMPORTS ------------------ */ + const remote = require('electron').remote const main = remote.require('./main.js') const fs = require('fs') @@ -18,6 +20,9 @@ const mal = require('malapi').Anime // Nyaa API const Nyaa = require('node-nyaa-api') +/* ----------------- END IMPORTS ----------------- */ + +/* ----------------- FUNCTIONS ----------------- */ function reduceString(string) { if (string.length > 100) @@ -42,89 +47,49 @@ function getNameOnly(name) { return tmp.join(' ') } +function getNameForResearch(name) { + let tmp = getNameOnly(name).split(' ') + tmp.pop() // Episode number + + return tmp.join(' ') +} + // Make the research for the latest animes -Nyaa.get_latest( function (err, animes) { - if (err) throw err +function getLatest () { + Nyaa.get_latest( function (err, animes) { + // Initialize + releases.releases = [] + releases.show = false + loader.show = true + if (err) throw err - for(let anime in animes) - { - if (horribleSubsFilter(animes[anime].title)) + for(let anime in animes) { - let tmp = animes[anime].title.split(' ') - tmp.pop() // Remove the episode number - tmp.pop() // Remove the annoying '-' + if (horribleSubsFilter(animes[anime].title)) + { + let tmp = animes[anime].title.split(' ') + tmp.pop() // Remove the extension + tmp.pop() // Remove the episode number + tmp.shift() - // Make the actual research - mal.fromName(tmp.join(' ')).then(result => { - releases.releases.push({ - realTitle: animes[anime].title, - title: getNameOnly(animes[anime].title), - link: animes[anime].link, - synopsis: reduceString(result.synopsis), - picture: result.image + // Make the actual research + mal.fromName(tmp.join(' ')).then(result => { + releases.releases.push({ + realTitle: animes[anime].title, + title: getNameOnly(animes[anime].title), + link: animes[anime].link, + synopsis: reduceString(result.synopsis), + picture: result.image + }) }) - }) + } } - } - setTimeout( () => { - loader.show = false - releases.show = true - }, 3000) - -}) - -let releases = new Vue({ - el: '#releases', - data: { - releases: [], - show: false - }, - watch: { - releases: function () { // Whenever releases changes, this function will run - // Code - } - }, - methods: { - download: function (url, name) { - startTorrent(url, name) - } - } -}) - -let loader = new Vue({ - el: '#loader-container', - data: { - show: true, - gif: path.join(__dirname, 'resources', 'totoro-hoola-hoop.gif') - }, - methods: { - test: function () { - this.show = false + setTimeout( () => { + loader.show = false releases.show = true - } - } -}) - -// Vue object to open the other pages -new Vue({ - el: '.mdl-navigation', - methods: { - getDownloader: function () { - main.openDownloader() - }, - getInfoPage: function () { - main.getInfoPage() - } - } -}) - -// For the greeting's message -new Vue({ - el: '.greetings', - data: { - username: os.userInfo().username - } -}) + }, 3000) + }) +} function downloadFile (file_url, name){ let req = request({ @@ -166,3 +131,129 @@ function startTorrent (file_url, name) { console.log(`stderr: ${stderr}`) }) } + +function makeResearchOnMal (name) { + + mal.fromName(name).then(anime => { + info.infos.title = anime.title + info.infos.japTitle = anime.japaneseTitle + info.infos.image = anime.image + info.infos.synopsis = anime.synopsis + info.infos.episodes = anime.episoes + info.infos.studios = anime.studios + info.infos.stats = anime.statistics + info.infos.genres = anime.genres + info.infos.type = anime.type.split(' ').slice(0, 3).join(' ') + info.infos.characters = anime.characters + info.infos.staff = anime.staff + + releases.show = false + loader.show = false + info.display = 'block' + info.show = true + }) +} + +/* -------------------- END FUNCTIONS ----------------- */ + +// First research at kawAnime's start +getLatest() + +/* ------------------- VUE.JS OBJECTS ----------------- */ + + +let releases = new Vue({ + el: '#releases', + data: { + releases: [], + show: false + }, + watch: { + releases: function () { // Whenever releases changes, this function will run + // Code + } + }, + methods: { + download: function (url, name) { + startTorrent(url, name) + }, + refresh: function () { + getLatest() + }, + searchThis: function (arg) { + info.infos = {} + this.show = false + loader.show = true + makeResearchOnMal(getNameForResearch(arg)) + } + } +}) + +let loader = new Vue({ + el: '#loader-container', + data: { + show: true + }, + methods: { + test: function () { + this.show = false + releases.show = true + } + } +}) + +let info = new Vue({ + el: '#info-container', + data: { + infos: { + stats: { + score: {value: ''}, + ranking: '' + } + }, + display: 'none', + show: false + }, + methods: { + downlaodThis: function () { + + }, + show: function () { + this.display = 'block' + this.show = true + }, + hide: function () { + this.show = false + }, + test: function () { + this.hide() + releases.show = true + } + }, + watch: { + infos: function () { + + } + } +}) + +// Vue object to open the other pages +new Vue({ + el: '.mdl-navigation', + methods: { + getDownloader: function () { + main.openDownloader() + }, + getInfoPage: function () { + main.getInfoPage() + } + } +}) + +// For the greeting's message +new Vue({ + el: '.greetings', + data: { + username: os.userInfo().username + } +})
{{ infos.synopsis }}
{{ character.name }}
{{ character.actor }}
{{ infos.stats.score.value}}
{{ infos.stats.ranking}}