【问题标题】:Move downloaded torrent after finished downloading libtorrent下载完 libtorrent 后移动下载的 torrent
【发布时间】:2021-09-04 15:23:25
【问题描述】:

我正在使用 libtorrent 下载种子。种子有不同的下载位置(save_path)。我希望在下载完成后将下载的 torrent 移动到新位置。 新位置取决于预先存在的 save_path。

ses = lt.session()
downloads=[]
.
.
params = {"save_path": "some/path"}
downloads.append(lt.add_magnet_uri(ses,  magnet_link, params))
.
.
.

    for index, download in enumerate(downloads[:]):
        if not download.is_seed():
            s = download.status()

            /....DO SOMETHING..../

        else:
            ses.remove_torrent(download)
            downloads.remove(download)
            
            #path of downloaded file
            #download.status().save_path 

            /...MOVE FILES TO NEW LOCATION.../

            print(download.name(), "complete")
  1. 如何获取下载的 torrent 的 save_pathDONE
  2. 如何移动下载的文件

【问题讨论】:

    标签: python libtorrent


    【解决方案1】:

    您好,根据 github 上的以下提交 libtorrent 或更确切地说是 test.py。我猜你会得到这样的save_path

    s = download.status()
    s.save_path
    

    我无法测试它。希望它有效。

    移动一个文件,是here

    import shutil
    shutil.move(s.save_path, "path/to/new/destination/")
    

    【讨论】:

    • 我想使用 libtorrent 的方法进行移动,但这可以解决问题。谢谢:)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-09-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-03-04
    • 1970-01-01
    相关资源
    最近更新 更多