import warnings
from torrentp.session import Session
from torrentp import TorrentInfo
import libtorrent
# disable DeprecationWarning
warnings.filterwarnings("ignore", category=DeprecationWarning)
torrent_file = "file.torrent"
torrent_info = TorrentInfo(torrent_file, libtorrent)
session = Session(libtorrent).create_session()
_file = session.add_torrent({'ti': torrent_info(), 'save_path': torrent_file})
while(not _file.has_metadata()):
pass
torinfo = _file.get_torrent_info()
for x in range(torinfo.files().num_files()):
print(torinfo.files().file_path(x))
import warnings
import time
import libtorrent as lt
# Disable DeprecationWarning
warnings.filterwarnings("ignore", category=DeprecationWarning)
# Путь к торрент-файлу и папке для сохранения загруженных файлов
torrent_file = "file.torrent"
save_path = "/path/to/save"
# Создаем сессию и добавляем торрент
session = lt.session()
info = lt.torrent_info(torrent_file)
params = {
'save_path': save_path,
'storage_mode': lt.storage_mode_t.storage_mode_sparse,
'ti': info
}
handle = session.add_torrent(params)
print('Starting download...')
while not handle.is_seed():
s = handle.status()
print(f'\rDownload rate: {s.download_rate / 1000:.2f} kB/s, Progress: {s.progress * 100:.2f}%', end='')
time.sleep(1)
print('\nDownload complete!')
# Вывод информации о загруженных файлах
for file in info.files():
print(file.path)