diff --git a/plugins/qbittorrent/index.py b/plugins/qbittorrent/index.py index 831e471c4..8b437e528 100755 --- a/plugins/qbittorrent/index.py +++ b/plugins/qbittorrent/index.py @@ -235,6 +235,12 @@ def pQbClient(): return qb +def getQbUrl(): + info = getQbConf() + url = 'http://' + info['QB_HOST'] + ':' + info['QB_PORT'] + '/' + return public.returnJson(True, 'ok', url) + + def qbList(): args = getArgs() # data = checkArgs(args, ['type']) @@ -269,6 +275,17 @@ def qbDel(): return public.returnJson(True, '操作成功!', data) +def qbAdd(): + args = getArgs() + data = checkArgs(args, ['hash']) + if not data[0]: + return data[1] + url = 'magnet:?xt=urn:btih:' + args['hash'] + qb = pQbClient() + data = qb.download_from_link(url) + return public.returnJson(True, '操作成功!', data) + + def test(): qb = pQbClient() # magnet_link = "magnet:?xt=urn:btih:57a0ec92a61c60585f1b7a206a75798aa69285a5" @@ -305,6 +322,10 @@ if __name__ == "__main__": print qbList() elif func == 'qb_del': print qbDel() + elif func == 'qb_add': + print qbAdd() + elif func == 'qb_url': + print getQbUrl() elif func == 'test': print test() else: diff --git a/plugins/qbittorrent/js/qbittorrent.js b/plugins/qbittorrent/js/qbittorrent.js index 74ea6d5e0..e00249172 100755 --- a/plugins/qbittorrent/js/qbittorrent.js +++ b/plugins/qbittorrent/js/qbittorrent.js @@ -62,8 +62,43 @@ function getLocalTime(nS) { } -function qbAdd(type){ - + +function qbAdd(){ + + var loadOpen = layer.open({ + type: 1, + title: '添加资源', + area: '400px', + content:"
\ +
\ +
\ +
\ +
\ + \ + \ +
\ +
" + }); + + $('#qb_close').click(function(){ + layer.close(loadOpen); + }); + + $('#qb_ok').click(function(){ + var hash = $('#qb_hash').val(); + qbPost('qb_add', {hash:hash}, function(data){ + + var rdata = $.parseJSON(data.data); + if (rdata['status']){ + showMsg(rdata.msg, function(){ + qbList(); + },{icon:1,time:2000,shade: [0.3, '#000']}); + layer.close(loadOpen); + } else { + layer.msg(rdata.msg,{icon:2,time:2000,shade: [0.3, '#000']}); + } + }); + }); } @@ -87,6 +122,13 @@ function qbListFind(){ } } +function openAdminUrl(){ + qbPost('qb_url', '', function(data){ + var rdata = $.parseJSON(data.data); + window.open(rdata.data); + }); +} + function qbList(search){ var _data = {}; _data['test'] ='yes'; @@ -113,7 +155,7 @@ function qbList(search){ content += ''; content += '种子(hash)'; content += '添加时间'; - content += '操作(添加 | 管理)'; + content += '操作(添加 | 管理)'; content += ''; content += '';