qbittorrent>3.1.x的python包装器

python-qbittorrent的Python项目详细描述


Documentation Statushttps://badge.fury.io/py/python-qbittorrent.svg

qbittorrent web api的python包装器(用于v3.1.x以上的版本)。

对于具有早期版本的qbittorrent客户端,请使用mookfist的python-qbittorrent

此包装基于qBittorrent’s Official Web API Documentation

中描述的方法

一些方法仅在qbittorent的最新版本(编写时为v3.3.1)中受支持。

最好将客户端升级到最新版本。

安装

最好的方法是从pypi安装一个稳定的版本:

$ pip install python-qbittorrent

您还可以留在包裹的边缘:

$ git clone https://github.com/v1k45/python-qBittorrent.git
$ cd python-qBittorrent
$ python setup.py install

快速使用指南

fromqbittorrentimportClientqb=Client('http://127.0.0.1:8080/')qb.login('admin','your-secret-password')# not required when 'Bypass from localhost' setting is active.# defaults to admin:admin.# to use defaults, just do qb.login()torrents=qb.torrents()fortorrentintorrents:printtorrent['name']

API方法

获取torrents

  • 获取所有activetorrents:

    qb.torrents()
    
  • 过滤种子:

    qb.torrents(filter='downloading', category='my category')
    # This will return all torrents which are currently
    # downloading and are labeled as ``my category``.
    
    qb.torrents(filter='paused', sort='ratio')
    # This will return all paused torrents sorted by their Leech:Seed ratio.
    

有关所有可能的筛选器,请参阅qbittorents web api文档。

下载Torrents

  • 通过链接下载Torrents:

    magnet_link = "magnet:?xt=urn:btih:e334ab9ddd91c10938a7....."
    qb.download_from_link(magnet_link)
    
    # No matter the link is correct or not,
    # method will always return empty JSON object.
    
  • 按链接列表下载多个Torrent:

    link_list = [link1, link2, link3]
    qb.download_from_link(link_list)
    
  • 按文件下载种子:

    torrent_file = open('my-torrent-file.torrent', 'rb')
    qb.download_from_file(torrent_file)
    
  • 使用文件下载多个Torrent:

    torrent_file_list = [open('1.torrent', 'rb'), open('2.torrent', 'rb')]
    qb.download_from_file(torrent_file_list)
    
  • 指定下载的保存路径:

    dl_path = '/home/user/Downloads/special-dir/'
    qb.download_from_file(myfile, savepath=dl_path)
    
    # same for links.
    qb.download_from_link(my_magnet_uri, savepath=dl_path)
    
  • 将标签应用于下载:

    qb.download_from_file(myfile, label='secret-files ;) ')
    
    # same for links.
    qb.download_from_link(my_magnet_uri, category='anime')
    

暂停/恢复Torrents

  • 暂停/恢复所有种子:

    qb.pause_all()
    qb.resume_all()
    
  • 暂停/恢复特定的种子:

    info_hash = 'e334ab9ddd....infohash....5d7fff526cb4'
    qb.pause(info_hash)
    qb.resume(info_hash)
    
  • 暂停/恢复多个Torrent:

    info_hash_list = ['e334ab9ddd9......infohash......fff526cb4',
                      'c9dc36f46d9......infohash......90ebebc46',
                      '4c859243615......infohash......8b1f20108']
    
    qb.pause_multiple(info_hash_list)
    qb.resume_multipe(info_hash_list)
    

完整的API方法文档

qbittorrent的所有api方法都提到了@Read the docs

作者

贡献者

按时间顺序

待办事项

  • 编写测试

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java CopyOnWriteArrayList可以用于可变对象吗?   只有静态方法的java加载类   java试图在加载时在自己身上绘制一个窗口   java将json作为字符串传递   java未从SMS检索器API接收SMS内容,尽管设备正在接收消息   java如何将部分XML复制到新的XML文件?   java如何在2D平面上随机生成一组站点,这些站点之间的空间大致相同?   JavaSpringMVC控制器bean配置   在Java中调用构造函数中的数组   如何在语音事件后持续发送请求类型:单次语音结束谷歌语音云Java   比较Java中的两个csv文件   java如何从包含构造函数的类调用方法?   java Android试图创建“先保存文件”吗?“对话   java如何避免Spring托管bean和Pojo依赖于同一服务时出现单例