diff --git a/main.js b/main.js index 8e7be64..23d639a 100644 --- a/main.js +++ b/main.js @@ -20,6 +20,18 @@ const template = menuFile.template(() => { }) const menu = Menu.buildFromTemplate(template) +// Checking if that config file already exists +fs.access(path.join(os.userInfo().homedir, '.KawAnime', 'config.js'), fs.constants.R_OK | fs.constants.W_OK, (err) => { + if (err) // This means the file does not exist + { + console.log('Creating initial config file.') + + // Taking the template config + fs.createReadStream(path.join(__dirname, 'resources', 'initConfig.js')) + .pipe(fs.createWriteStream(path.join(os.userInfo().homedir, '.KawAnime', 'config.js'))) + } +}) + // Keep a global reference of the window object, if you don't, the window will // be closed automatically when the JavaScript object is garbage collected. let mainWindow diff --git a/package.json b/package.json index 65fcd2d..c480645 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,7 @@ "dependencies": { "find-remove": "^1.0.0", "is-online": "^5.2.0", - "mal-scraper": "latest", + "mal-scraper": "^1.2.0", "malapi": "0.0.3", "mdi": "^1.8.36", "node-nyaa-api": "latest", diff --git a/resources/initConfig.js b/resources/initConfig.js new file mode 100644 index 0000000..9ed73fb --- /dev/null +++ b/resources/initConfig.js @@ -0,0 +1,9 @@ +const os = require('os') + +module.exports = { + fansub: 'HorribleSubs', + quality: '720p', + sound: 'Nyanpasu', + localPath: path.join(os.userInfo().homedir, 'Downloads'), + inside: true +} \ No newline at end of file diff --git a/src/downloader/functions.js b/src/downloader/functions.js index b97417b..fd89338 100644 --- a/src/downloader/functions.js +++ b/src/downloader/functions.js @@ -94,7 +94,10 @@ exports.downloadMagnets = (object) => { // Here we convert the torrent files to magnets const dirFiles = fs.readdirSync(DIR) + const date = new Date() + // Grabbing all the torrents + fs.appendFileSync(path.join(DIR, 'magnets.txt'), `${date}: ${animeName} ${fromEp} - ${untilEp}\n`) for (let i = 0; i < dirFiles.length; ++i) { let torrent = dirFiles[i] @@ -106,12 +109,10 @@ exports.downloadMagnets = (object) => { const name = torrent.name const torrentHash = torrent.infoHash - const date = new Date() const uri = parseTorrent.toMagnetURI({infoHash: torrentHash}) - fs.appendFileSync(path.join(DIR, 'magnets.txt'), `${date}: ${name}\n\t`) - fs.appendFileSync(path.join(DIR, 'magnets.txt'), `${uri}\n\n`) + fs.appendFileSync(path.join(DIR, 'magnets.txt'), `${uri}\n`) } }