diff --git a/plugins/qbittorrent/conf/qb.conf b/plugins/qbittorrent/conf/qb.conf new file mode 100755 index 000000000..091cd0e97 --- /dev/null +++ b/plugins/qbittorrent/conf/qb.conf @@ -0,0 +1,6 @@ + + +QB_HOST = 127.0.0.1 +QB_PORT = 8080 +QB_USER = admin +QB_PWD = adminadmin diff --git a/plugins/qbittorrent/conf/qb.sql b/plugins/qbittorrent/conf/qb.sql new file mode 100644 index 000000000..d7940482c --- /dev/null +++ b/plugins/qbittorrent/conf/qb.sql @@ -0,0 +1,11 @@ +CREATE TABLE `download_list` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `info_hash` varchar(40) NOT NULL, + `data_hash` varchar(32) NOT NULL, + `name` varchar(255) NOT NULL, + `length` bigint(20) NOT NULL, + `create_time` datetime NOT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `info_hash` (`info_hash`), + KEY `create_time` (`create_time`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; \ No newline at end of file diff --git a/plugins/qbittorrent/index.html b/plugins/qbittorrent/index.html index 2851e4606..d2fc4ec85 100755 --- a/plugins/qbittorrent/index.html +++ b/plugins/qbittorrent/index.html @@ -3,6 +3,7 @@

服务

自启动

+

手动导入SQL

diff --git a/plugins/qbittorrent/index.py b/plugins/qbittorrent/index.py index 223db8035..400c01c66 100755 --- a/plugins/qbittorrent/index.py +++ b/plugins/qbittorrent/index.py @@ -64,7 +64,7 @@ def getInitDTpl(): def getSqlFile(): - file = getPluginDir() + "/conf/simdht.sql" + file = getPluginDir() + "/conf/qb.sql" return file @@ -129,7 +129,6 @@ def stop(): file = initDreplace() data = public.execShell(file + ' stop') if data[1] == '': - public.execShell('rm -rf /tmp/mysql.sock') return 'ok' return 'fail' @@ -183,6 +182,23 @@ def initdUinstall(): return 'ok' +def matchData(reg, content): + tmp = re.search(reg, content).groups() + return tmp[0] + + +def getDbConfInfo(): + cfg = getDbConf() + content = public.readFile(cfg) + data = {} + data['DB_HOST'] = matchData("DB_HOST\s*=\s(.*)", content) + data['DB_USER'] = matchData("DB_USER\s*=\s(.*)", content) + data['DB_PORT'] = matchData("DB_PORT\s*=\s(.*)", content) + data['DB_PASS'] = matchData("DB_PASS\s*=\s(.*)", content) + data['DB_NAME'] = matchData("DB_NAME\s*=\s(.*)", content) + return data + + def pMysqlDb(): data = getDbConfInfo() conn = mysql.mysql() @@ -194,11 +210,15 @@ def pMysqlDb(): return conn -def test(): +def pQbClient(): from qbittorrent import Client qb = Client('http://154.48.251.71:8080/') qb.login('admin', 'adminadmin') + return qb + +def test(): + qb = pQbClient() # magnet_link = "magnet:?xt=urn:btih:57a0ec92a61c60585f1b7a206a75798aa69285a5" # print qb.download_from_link(magnet_link) torrents = qb.torrents(filter='downloading') diff --git a/plugins/simdht/index.py b/plugins/simdht/index.py index 969e8e9ff..a7e5a97a7 100755 --- a/plugins/simdht/index.py +++ b/plugins/simdht/index.py @@ -132,7 +132,6 @@ def stop(): file = initDreplace() data = public.execShell(file + ' stop') if data[1] == '': - public.execShell('rm -rf /tmp/mysql.sock') return 'ok' return 'fail' @@ -263,9 +262,10 @@ def getTrendData(): print str(e) return public.getJson([0, 0, 0]) + def dhtCmd(): file = initDreplace() - return file+' restart' + return file + ' restart' if __name__ == "__main__": func = sys.argv[1] @@ -294,6 +294,6 @@ if __name__ == "__main__": elif func == 'get_trend_data': print getTrendData() elif func == 'dht_cmd': - print dhtCmd(); + print dhtCmd() else: print 'error'