diff --git a/patches/bad.js b/patches/bad.js new file mode 100644 index 0000000..fb4e383 --- /dev/null +++ b/patches/bad.js @@ -0,0 +1,46 @@ +const mysql = require('mysql'); +const torrentTypeDetect = require('../lib/content'); + +const mysqlSettings = { + host : 'localhost', + user : 'btsearch', + password : 'pirateal100x', + database : 'btsearch' +}; + +socketMysql = mysql.createConnection(mysqlSettings); + +socketMysql.connect(function(mysqlError) { + if (mysqlError) { + console.error('error connecting: ' + mysqlError.stack); + return; + } + + let current = 0; + function func(index) { + socketMysql.query("SELECT * FROM `torrents` WHERE (`contentType` = 'video' or contentType = 'pictures') and contentCategory IS NULL LIMIT ?, 30000", [index], function (error, torrents, fields) { + let records = torrents.length; + let next = index + records; + if(records == 0) + return; + + torrents.forEach((torrent) => { + socketMysql.query('SELECT * FROM `files` WHERE hash = ?', torrent.hash, function (error, files, fields) { + torrentTypeDetect(torrent, files); + if(torrent.contentType && torrent.contentCategory == 'xxx') { + socketMysql.query('UPDATE `torrents` SET `contentType` = ?, contentCategory = ? WHERE `hash` = ?', [torrent.contentType, torrent.contentCategory, torrent.hash], function (error, files, fields) { + console.log('xxx ' + torrent.name + ': ' + (++current) + '/' + torrents.length); + if(--records == 0) + func(next) + }); + } else { + console.log((++current) + '/' + torrents.length); + if(--records == 0) + func(next) + } + }); + }); + }); + } + func(0); +}); \ No newline at end of file