Linted all pirate, git, tmdb and searchHistory scripts.
This commit is contained in:
		| @@ -1,8 +1,7 @@ | ||||
| const assert = require('assert'); | ||||
|  | ||||
| class GitRepository { | ||||
|  | ||||
| 	dumpHook(body) { | ||||
|    static dumpHook(body) { | ||||
|       /* eslint-disable no-console */ | ||||
|       console.log(body); | ||||
|    } | ||||
| } | ||||
|   | ||||
| @@ -1,54 +1,53 @@ | ||||
| const assert = require('assert'); | ||||
| var PythonShell = require('python-shell'); | ||||
| var async = require('async'); | ||||
| const PythonShell = require('python-shell'); | ||||
|  | ||||
| async function find(searchterm, callback) { | ||||
|  | ||||
|   var options = { | ||||
|    const options = { | ||||
|       pythonPath: '/usr/bin/python3', | ||||
|       // pythonPath: '/Library/Frameworks/Python.framework/Versions/3.6/bin/python3', | ||||
| 		args: [searchterm, '-s', 'piratebay', '--print'] | ||||
| 	} | ||||
|       args: [searchterm, '-s', 'piratebay', '--print'], | ||||
|    }; | ||||
|  | ||||
|    PythonShell.run('../app/torrent_search/torrentSearch/search.py', options, callback); | ||||
|    // PythonShell does not support return | ||||
| }; | ||||
| } | ||||
|  | ||||
|  | ||||
| async function callPythonAddMagnet(magnet, callback) { | ||||
| 	var options = { | ||||
|    const options = { | ||||
|       pythonPath: '/usr/bin/python', | ||||
|       // pythonPath: '/Library/Frameworks/Python.framework/Versions/3.6/bin/python3', | ||||
| 		args: [magnet] | ||||
| 	} | ||||
|       args: [magnet], | ||||
|    }; | ||||
|  | ||||
|    PythonShell.run('../app/magnet.py', options, callback); | ||||
| } | ||||
|  | ||||
| async function SearchPiratebay(query) { | ||||
| 	return await new Promise((resolve, reject) => { | ||||
| 		return find(query, function(err, results) { | ||||
|    return await new Promise((resolve, reject) => find(query, (err, results) => { | ||||
|       if (err) { | ||||
| 				console.log('THERE WAS A FUCKING ERROR!') | ||||
| 				reject(Error('There was a error when searching for torrents')) | ||||
|          /* eslint-disable no-console */ | ||||
|          console.log('THERE WAS A FUCKING ERROR!'); | ||||
|          reject(Error('There was a error when searching for torrents')); | ||||
|       } | ||||
|       if (results) { | ||||
|          /* eslint-disable no-console */ | ||||
|          console.log('result', results); | ||||
|          resolve(JSON.parse(results, null, '\t')); | ||||
|       } | ||||
| 		}) | ||||
| 	}) | ||||
|    })); | ||||
| } | ||||
|  | ||||
| async function AddMagnet(magnet) { | ||||
| 	return await new Promise((resolve) => { | ||||
| 		return callPythonAddMagnet(magnet, function(err, results) { | ||||
|    return await new Promise(resolve => callPythonAddMagnet(magnet, (err, results) => { | ||||
|       if (err) { | ||||
| 				console.log(err) | ||||
|          /* eslint-disable no-console */ | ||||
|          console.log(err); | ||||
|       } | ||||
| 			resolve({ success: true }) | ||||
| 		}) | ||||
| 	}) | ||||
|       /* eslint-disable no-console */ | ||||
|       console.log(results); | ||||
|       resolve({ success: true }); | ||||
|    })); | ||||
| } | ||||
|  | ||||
| module.exports = { SearchPiratebay, AddMagnet } | ||||
| module.exports = { SearchPiratebay, AddMagnet }; | ||||
|   | ||||
| @@ -1,7 +1,6 @@ | ||||
| const establishedDatabase = require('src/database/database'); | ||||
|  | ||||
| class SearchHistory { | ||||
|  | ||||
|    constructor(database) { | ||||
|       this.database = database || establishedDatabase; | ||||
|       this.queries = { | ||||
| @@ -27,13 +26,13 @@ class SearchHistory { | ||||
|    * @returns {Promise} | ||||
|    */ | ||||
|    create(user, searchQuery) { | ||||
|     return this.database.run(this.queries.create, [searchQuery, user]).catch((error) => { | ||||
|       return this.database.run(this.queries.create, [searchQuery, user]) | ||||
|          .catch((error) => { | ||||
|             if (error.message.includes('FOREIGN')) { | ||||
|                throw new Error('Could not create search history.'); | ||||
|             } | ||||
|          }); | ||||
|    } | ||||
|  | ||||
| } | ||||
|  | ||||
| module.exports = SearchHistory; | ||||
|   | ||||
| @@ -3,12 +3,12 @@ const establishedDatabase = require('src/database/database'); | ||||
|  | ||||
| class Cache { | ||||
|    constructor(database) { | ||||
| 		this.database = database || establishedDatabase | ||||
|       this.database = database || establishedDatabase; | ||||
|       this.queries = { | ||||
| 		'read': 'SELECT value, time_to_live, created_at, DATETIME("now", "localtime") as now, ' + | ||||
|          read: 'SELECT value, time_to_live, created_at, DATETIME("now", "localtime") as now, ' + | ||||
|          'DATETIME(created_at, "+" || time_to_live || " seconds") as expires ' + | ||||
|          'FROM cache WHERE key = ? AND now < expires', | ||||
| 		'create': 'INSERT OR REPLACE INTO cache (key, value, time_to_live) VALUES (?, ?, ?)', | ||||
|          create: 'INSERT OR REPLACE INTO cache (key, value, time_to_live) VALUES (?, ?, ?)', | ||||
|       }; | ||||
|    } | ||||
|  | ||||
| @@ -23,7 +23,7 @@ class Cache { | ||||
|          .then((row) => { | ||||
|             assert(row, 'Could not find cache enrty with that key.'); | ||||
|             return JSON.parse(row.value); | ||||
| 	 	}) | ||||
|          }); | ||||
|    } | ||||
|  | ||||
|    /** | ||||
| @@ -31,7 +31,7 @@ class Cache { | ||||
|     * @param {String} key of the cache entry | ||||
|     * @param {String} value of the cache entry | ||||
|     * @param {Number} timeToLive the number of seconds before entry expires | ||||
| 	 * @returns {Object} | ||||
|     * @returns {Object} | ||||
|     */ | ||||
|    set(key, value, timeToLive = 172800) { | ||||
|       const json = JSON.stringify(value); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user