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