【问题标题】:How to add set_sequential_download() to this code using libtorrent?如何使用 libtorrent 将 set_sequential_download() 添加到此代码中?
【发布时间】:2021-02-01 13:04:27
【问题描述】:

如何将set_sequential_download(True) 添加到下面的python 代码中?

我尝试了几种添加句柄的方法;但它不起作用。 sequential_download 也被称为 torrent 标志和 torrent 句柄。 我浏览了 Libtorrent 网站上的文档,但不清楚,而且我对 python 的经验非常有限。

import libtorrent as lt
import time
import datetime

ses = lt.session()
ses.listen_on(6881, 6891)
params = {
    'save_path': '/content/drive/Shared drives/Dakar files/Torrent',
    'storage_mode': lt.storage_mode_t(2),
    'paused': False,
    'auto_managed': True,
    'duplicate_is_error': True)

link = "??" # PASTE TORRENT/MAGNET LINK HERE
print(link)


h = ses.add_torrent({'ti': info, 'save_path': './'})
handle = lt.add_magnet_uri(ses, link, params)
ses.start_dht()

begin = time.time()
print(datetime.datetime.now())

print ('Downloading Metadata...')
while (not handle.has_metadata()):
    time.sleep(1)
print ('Got Metadata, Starting Torrent Download...')

print("Starting", handle.name())

while (handle.status().state != lt.torrent_status.seeding):
    s = handle.status()
            state_str = ['queued', 'checking', 'downloading metadata', \
            'downloading', 'finished', 'seeding', 'allocating']
    print ('%.2f%% complete (down: %.1f kb/s up: %.1f kB/s peers: %d) %s ' % \
            (s.progress * 100, s.download_rate / 1000, s.upload_rate / 1000, \
            s.num_peers, state_str[s.state]))
    time.sleep(5)

end = time.time()
print(handle.name(), "COMPLETE")

print("Elapsed Time: ",int((end-begin)//60),"min :", int((end-begin)%60), "sec")

print(datetime.datetime.now())

【问题讨论】:

    标签: python libtorrent libtorrent-rasterbar


    【解决方案1】:

    要启用和禁用 torrent 的某些功能,请使用 set_flags()unset_flags() (docs)。

    您可以设置和清除的标志记录在 here

    请为文档中任何不清楚的部分提交一份 github 票证。文档本身提供了执行此操作的链接。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-09-20
      • 1970-01-01
      • 2021-10-18
      • 1970-01-01
      • 2011-02-28
      • 1970-01-01
      相关资源
      最近更新 更多