{"id":13595,"date":"2024-02-07T14:36:49","date_gmt":"2024-02-07T06:36:49","guid":{"rendered":"https:\/\/92it.top\/?p=13595"},"modified":"2024-02-07T14:36:49","modified_gmt":"2024-02-07T06:36:49","slug":"python-qbittorrent-%e4%bd%bf%e7%94%a8%e7%a3%81%e5%8a%9b%e9%93%be%e4%b8%8b%e8%bd%bd","status":"publish","type":"post","link":"https:\/\/92it.top\/?p=13595","title":{"rendered":"python qbittorrent \u4f7f\u7528\u78c1\u529b\u94fe\u4e0b\u8f7d"},"content":{"rendered":"\n<p><strong>\u6982\u8ff0<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p>qbittorrent \u662f\u4e00\u4e2a\u5f00\u6e90\u7684 BitTorrent \u5ba2\u6237\u7aef\uff0c\u5b83\u5141\u8bb8\u7528\u6237\u4e0b\u8f7d\u79cd\u5b50\u6587\u4ef6\u5e76\u4f7f\u7528\u78c1\u529b\u94fe\u8fdb\u884c\u4e0b\u8f7d\u3002\u901a\u8fc7\u4f7f\u7528 Python \u7f16\u7a0b\u8bed\u8a00\u7ed3\u5408 qbittorrent \u7684 API\uff0c\u6211\u4eec\u53ef\u4ee5\u7f16\u5199\u4e00\u4e2a\u811a\u672c\u6765\u81ea\u52a8\u5316\u4e0b\u8f7d\u4efb\u52a1\u3002<\/p>\n\n\n\n<p>\u672c\u6587\u5c06\u4ecb\u7ecd\u5982\u4f55\u4f7f\u7528 Python \u548c qbittorrent \u7684 API \u6765\u4e0b\u8f7d\u78c1\u529b\u94fe\u3002\u6211\u4eec\u5c06\u4ece\u5b89\u88c5 qbittorrent \u5f00\u59cb\uff0c\u7136\u540e\u4ecb\u7ecd\u5982\u4f55\u8bbe\u7f6e API \u8bbf\u95ee\uff0c\u5e76\u63d0\u4f9b\u4e00\u4e2a\u7b80\u5355\u7684\u793a\u4f8b\u6765\u8bf4\u660e\u5982\u4f55\u4f7f\u7528 Python \u811a\u672c\u8fdb\u884c\u4e0b\u8f7d\u3002<\/p>\n\n\n\n<p><strong>\u5b89\u88c5 qbittorrent<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p>\u9996\u5148\uff0c\u6211\u4eec\u9700\u8981\u5b89\u88c5 qbittorrent \u5ba2\u6237\u7aef\u3002qbittorrent \u63d0\u4f9b\u4e86\u9002\u7528\u4e8e Windows\u3001MacOS \u548c Linux \u7cfb\u7edf\u7684\u5b89\u88c5\u5305\u3002<\/p>\n\n\n\n<p>\u8fd9\u91cc\u6211\u662f\u901a\u8fc7docker\u5b89\u88c5\u3002<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><a href=\"https:\/\/92it.top\/?p=11563\">https:\/\/92it.top\/?p=11563<\/a><\/pre>\n\n\n\n<p><strong>\u8bbe\u7f6e API \u8bbf\u95ee<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p>qbittorrent \u5ba2\u6237\u7aef\u63d0\u4f9b\u4e86\u4e00\u4e2a API\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528\u8fd9\u4e2a API \u6765\u4e0e\u5ba2\u6237\u7aef\u8fdb\u884c\u901a\u4fe1\u5e76\u6267\u884c\u4e0b\u8f7d\u4efb\u52a1\u3002\u5728\u4f7f\u7528 API \u4e4b\u524d\uff0c\u6211\u4eec\u9700\u8981\u5148\u8bbe\u7f6e API \u8bbf\u95ee\u3002<\/p>\n\n\n\n<ul><li>\u6253\u5f00 qbittorrent \u5ba2\u6237\u7aef\u7684\u8bbe\u7f6e\u754c\u9762\u3002<\/li><li>\u9009\u62e9 \u201cWeb UI\u201d \u9009\u9879\u5361\u3002<\/li><li>\u5728 \u201cWeb UI\u201d \u9009\u9879\u5361\u4e2d\u542f\u7528 \u201cWeb User Interface (Remote control)\u201d\u3002<\/li><li>\u8bbe\u7f6e\u4e00\u4e2a\u7528\u6237\u540d\u548c\u5bc6\u7801\uff0c\u7528\u4e8e\u8eab\u4efd\u9a8c\u8bc1\u3002<\/li><li>\u786e\u4fdd \u201cBypass authentication for clients on localhost\u201d \u590d\u9009\u6846\u88ab\u9009\u4e2d\u3002<\/li><\/ul>\n\n\n\n<p>\u5b8c\u6210\u4e0a\u8ff0\u8bbe\u7f6e\u540e\uff0c\u6211\u4eec\u5c31\u53ef\u4ee5\u4f7f\u7528 Python \u811a\u672c\u901a\u8fc7 API \u8fdb\u884c\u4e0b\u8f7d\u4e86\u3002<\/p>\n\n\n\n<p><strong>\u4f7f\u7528 Python \u811a\u672c\u4e0b\u8f7d\u78c1\u529b\u94fe<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p>\u8981\u4f7f\u7528 Python \u811a\u672c\u4e0b\u8f7d\u78c1\u529b\u94fe\uff0c\u6211\u4eec\u9700\u8981\u5b89\u88c5 qbittorrent-api \u5305\u3002\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5728\u7ec8\u7aef\u4e2d\u5b89\u88c5\u5b83\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">pip install qbittorrent-api<\/pre>\n\n\n\n<p>\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u6211\u4eec\u53ef\u4ee5\u5f00\u59cb\u7f16\u5199 Python \u811a\u672c\u3002<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">from qbittorrent import Client\n\n# \u521b\u5efa qbittorrent \u5ba2\u6237\u7aef\u5b9e\u4f8b\nqb = Client(\"http:\/\/localhost:8080\/\")\n\n# \u8eab\u4efd\u9a8c\u8bc1\nqb.login(\"username\", \"password\")\n\n# \u6dfb\u52a0\u78c1\u529b\u94fe\nmagnet_link = \"magnet:?xt=urn:btih:8E199F9970A78B5FA0CFD4593D7DC620D5F6B7C0\"\nqb.download_from_link(magnet_link)\n\n# \u83b7\u53d6\u4e0b\u8f7d\u72b6\u6001\ntorrents = qb.torrents()\nfor torrent in torrents:\n    print(f\"\u540d\u79f0: {torrent['name']}, \u8fdb\u5ea6: {torrent['progress']}\")\n\n# \u5173\u95ed qbittorrent \u5ba2\u6237\u7aef\u8fde\u63a5\nqb.logout()\n\n<\/pre>\n\n\n\n<p>\u4e0a\u8ff0\u4ee3\u7801\u793a\u4f8b\u6f14\u793a\u4e86\u5982\u4f55\u4f7f\u7528 qbittorrent-api \u5305\u6765\u4e0b\u8f7d\u78c1\u529b\u94fe\u3002\u9996\u5148\uff0c\u6211\u4eec\u521b\u5efa\u4e86\u4e00\u4e2a qbittorrent \u5ba2\u6237\u7aef\u5b9e\u4f8b\uff0c\u5e76\u4f7f\u7528 login \u65b9\u6cd5\u8fdb\u884c\u8eab\u4efd\u9a8c\u8bc1\u3002\u7136\u540e\uff0c\u6211\u4eec\u4f7f\u7528 download_from_link \u65b9\u6cd5\u6dfb\u52a0\u4e86\u4e00\u4e2a\u78c1\u529b\u94fe\uff0c\u5e76\u4f7f\u7528 torrents \u65b9\u6cd5\u83b7\u53d6\u4e0b\u8f7d\u72b6\u6001\u3002\u6700\u540e\uff0c\u6211\u4eec\u4f7f\u7528 logout \u65b9\u6cd5\u5173\u95ed\u4e0e qbittorrent \u5ba2\u6237\u7aef\u7684\u8fde\u63a5\u3002<\/p>\n\n\n\n<p>\u4ee5\u4e0a\u793a\u4f8b\u53ea\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u6f14\u793a\uff0c\u4f60\u53ef\u4ee5\u6839\u636e\u81ea\u5df1\u7684\u9700\u6c42\u8fdb\u884c\u6269\u5c55\u548c\u4fee\u6539\u3002qbittorrent \u7684 API \u63d0\u4f9b\u4e86\u66f4\u591a\u7684\u65b9\u6cd5\u548c\u9009\u9879\uff0c\u4f7f\u4f60\u80fd\u591f\u66f4\u597d\u5730\u63a7\u5236\u4e0b\u8f7d\u4efb\u52a1\u3002<\/p>\n\n\n\n<p><strong>\u603b\u7ed3<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p>\u672c\u6587\u4ecb\u7ecd\u4e86\u5982\u4f55\u4f7f\u7528 Python qbittorrent API \u6765\u4e0b\u8f7d\u78c1\u529b\u94fe\u3002\u6211\u4eec\u9996\u5148\u5b89\u88c5\u4e86 qbittorrent \u5ba2\u6237\u7aef\uff0c\u5e76\u8bbe\u7f6e\u4e86 API \u8bbf\u95ee\u3002\u7136\u540e\uff0c\u6211\u4eec\u4f7f\u7528 qbittorrent-api \u5305\u7f16\u5199\u4e86\u4e00\u4e2a\u7b80\u5355\u7684 Python \u811a\u672c\u6765\u6267\u884c\u4e0b\u8f7d\u4efb\u52a1\u3002<\/p>\n\n\n\n<p>\u5e0c\u671b\u672c\u6587\u80fd\u5e2e\u52a9\u4f60\u4e86\u89e3\u5982\u4f55\u4f7f\u7528 Python \u548c qbittorrent \u6765\u81ea\u52a8\u5316\u4e0b\u8f7d\u4efb\u52a1\u3002\u5982\u679c\u4f60\u5bf9\u6b64\u611f\u5174\u8da3\uff0c\u53ef\u4ee5\u8fdb\u4e00\u6b65\u6df1\u5165\u7814\u7a76 qbittorrent \u7684 API\uff0c\u4ee5\u53ca qbittorrent \u7684\u5176\u4ed6\u529f\u80fd\u548c\u9009\u9879\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6982\u8ff0 qbittorrent \u662f\u4e00\u4e2a\u5f00\u6e90\u7684 BitTorrent \u5ba2\u6237\u7aef\uff0c\u5b83\u5141\u8bb8\u7528\u6237\u4e0b\u8f7d\u79cd\u5b50\u6587\u4ef6\u5e76\u4f7f\u7528\u78c1\u529b\u94fe\u8fdb [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10],"tags":[],"_links":{"self":[{"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts\/13595"}],"collection":[{"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=13595"}],"version-history":[{"count":1,"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts\/13595\/revisions"}],"predecessor-version":[{"id":13596,"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts\/13595\/revisions\/13596"}],"wp:attachment":[{"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=13595"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=13595"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=13595"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}