qb tracker 的更新脚本
1.安装 qbittorrent-api 库
bash
pip install qbittorrent-api
2.获取 tracker 列表
python
def get_tarkers()->str:
tracker_url = "https://cf.trackerslist.com/all.txt"
res = requests.get(url=tracker_url)
tracker_str = res.text
return tracker_str
3.使用 api 库更新 trakers
python
def add_tarkers(trackers:str):
# instantiate a Client using the appropriate WebUI configuration
conn_info = dict(
host="192.168.31.169",
port=8080,
username="xxxxxxx",
password="xxxxxxx",
)
qbt_client = qbittorrentapi.Client(**conn_info)
try:
qbt_client.auth_log_in()
except qbittorrentapi.LoginFailed as e:
print(e)
qbt_client.auth_log_out()
qbt_client.app.set_preferences(prefs={"add_trackers":trackers})
4.完整代码
python
import qbittorrentapi
import requests
def get_tarkers()->str:
tracker_url = "https://cf.trackerslist.com/all.txt"
res = requests.get(url=tracker_url)
tracker_str = res.text
return tracker_str
def add_tarkers(trackers:str):
conn_info = dict(
host="192.168.31.169",
port=8080,
username="xxxxxx",
password="xxxxxxxx",
)
qbt_client = qbittorrentapi.Client(**conn_info)
try:
qbt_client.auth_log_in()
except qbittorrentapi.LoginFailed as e:
print(e)
qbt_client.auth_log_out()
qbt_client.app.set_preferences(prefs={"add_trackers": trackers})
def main():
trackers_str = get_tarkers()
add_tarkers(trackers_str)
if __name__ == "__main__":
main()
链接: