处理Torrent文件的工具。
torrentool的Python项目详细描述
https://github.com/idlesign/torrentool
说明
处理Torrent文件的工具。
适用于Python2.7+和3.5+。
包括:
- 命令行接口(需要安装click包)
- Torrent Utils(文件创建、读取和修改)
- bencoding utils(解码器、编码器)
使用cli
; Make .torrent out of `video.mkv` $ torrentool torrent create /home/my/files_here/video.mkv ; Make .torrent out of entire `/home/my/files_here` dir, ; and put some open trackers announce URLs into it, ; and publish file on torrent caching service, so it is ready to share. $ torrentool torrent create /home/my/files_here --open_trackers --cache ; Print out existing file info. $ torrentool torrent info /home/my/some.torrent
使用命令行--help开关了解更多信息。
注意
有些命令要求安装requests包。
从您的python代码
fromtorrentool.apiimportTorrent# Reading and modifying an existing file.my_torrent=Torrent.from_file('/home/idle/some.torrent')my_torrent.total_size# Total files size in bytes.my_torrent.magnet_link# Magnet link for you.my_torrent.comment='Your torrents are mine.'# Set a comment.my_torrent.to_file()# Save changes.# Or we can create a new torrent from a directory.new_torrent=Torrent.create_from('/home/idle/my_stuff/')# or it could have been a single filenew_torrent.announce_urls='udp://tracker.openbittorrent.com:80'new_torrent.to_file('/home/idle/another.torrent')