【问题标题】:Python libtorrent, get file list namesPython libtorrent,获取文件列表名称
【发布时间】:2018-11-18 23:42:33
【问题描述】:

我正在为 python 3.6 使用 libtorrent。我只想获取随会话下载的任何文件名,例如文件夹名称,文件名等。 我在网上搜索并没有发现任何东西。我正在使用以下示例:

https://www.libtorrent.org/python_binding.html

所以当下载进度完成时,我想知道这个会话下载了哪些文件。怎样才能做到这一点?提前致谢!

【问题讨论】:

    标签: python file directory torrent libtorrent


    【解决方案1】:

    终于找到答案了,代码是:

    handle = libtorrent.add_magnet_uri(session, magnetLink,params)
    
        session.start_dht()                
    
        while not handle.has_metadata():
            time.sleep(1)          
    
        torinfo = handle.get_torrent_info()
    
        for x in range(torinfo.files().num_files()):
            print(torinfo.files().file_path(x))
    

    上面的代码打印了磁铁文件附带的文件名。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-07-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-01-27
      相关资源
      最近更新 更多