From f24a796939427b3b2e77e0e659f2488de5215cac Mon Sep 17 00:00:00 2001 From: Alexey Kasyanchuk Date: Mon, 30 Jan 2017 12:12:26 +0300 Subject: [PATCH] =?UTF-8?q?=D0=BF=D0=B0=D1=82=D1=87=20=D0=B4=D0=BB=D1=8F?= =?UTF-8?q?=20=D0=BF=D0=BB=D0=BE=D1=85=D0=BE=D0=B3=D0=BE=20=D0=BA=D0=BE?= =?UTF-8?q?=D0=BD=D1=82=D0=B5=D0=BD=D1=82=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- patches/bad.js | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 patches/bad.js 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