Cleaned up renderer.js from downloader things.

This commit is contained in:
Kylart 2017-03-03 06:12:27 +01:00
parent d39b6d9217
commit e8658c96b1
1 changed files with 7 additions and 32 deletions

View File

@ -1,18 +1,17 @@
/**
*
* This file is the main one in the rendering process. Here we navigate
* between the vue objects and set up most important functions.
*
*/
/* ------------------ IMPORTS ------------------ */
const remote = require('electron').remote
const main = remote.require('./main.js')
const shell = require('electron').shell
const fs = require('fs')
const os = require('os')
// Those are needed to download the torrents
const path = require('path')
const request = require('request')
const findRemoveSync = require('find-remove')
const parseTorrent = require('parse-torrent')
const player = require('play-sound')(opts = {})
// Mal API
const mal = require('malapi').Anime
@ -23,9 +22,6 @@ const malScraper = require('mal-scraper')
/* ----------------- END IMPORTS ----------------- */
const DIR = path.join(os.userInfo().homedir, '.KawAnime')
const magnetPath = path.join(DIR, 'magnets.txt')
/* ----------------- VUE IMPORTS ----------------- */
require(path.join(__dirname, 'downloader', 'index.js'))
@ -154,27 +150,6 @@ function getLatest() {
})
}
function downloadFile(file_url, name) {
let req = request({
method: 'GET',
uri: file_url
})
let out = fs.createWriteStream(path.join(DIR, `${name}.torrent`))
req.pipe(out)
}
function startTorrent(file_url, name) {
// Removing old torrents
findRemoveSync(DIR, {extensions: ['.torrent']})
// Downloading the new ones
downloadFile(file_url, name)
// Opening them
main.openTorrents()
}
function makeResearchOnMal(name) {
mal.fromName(name).then((anime) => {