базовое определение типов контента

This commit is contained in:
Alexey Kasyanchuk
2017-01-03 11:04:24 +03:00
parent cb86f67e57
commit ec1191771c
3 changed files with 256 additions and 0 deletions

33
patches/patch1.js Normal file
View File

@ -0,0 +1,33 @@
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;
}
socketMysql.query('SELECT * FROM `torrents` WHERE `contentType` IS NULL', function (error, rows, fields) {
rows.forEach((torrent) => {
socketMysql.query('SELECT * FROM `files` WHERE hash = ?', torrent.hash, function (error, files, fields) {
torrentTypeDetect(torrent, files);
if(torrent.contentType) {
socketMysql.query('UPDATE `torrents` SET `contentType` = ? WHERE `hash` = ?', [torrent.contentType, torrent.hash], function (error, files, fields) {
console.log(error + ':' + torrent.contentType);
});
}
});
});
});
});
console.log('end');