原始地址:https://dev.to/iw4p/how-to-download-torrent-files-python-25ll
'''
I searched a lot and I didn’t find anything EASY and FAST for downloading torrent files with python on Google colab. So I decided to start writing my own wrapped library for downloading torrent files.
TorrentP is a great and easy way to download torrent files, on your local machine or even google Colab!
Make sure you have Python installed, Then you can download it with this command on your terminal:
pip install torrentp After that you just have 3 steps:
Create a .py file
Copy and paste 3 lines
Run the script file and wait until it downloads completely!
If you have a torrent file use it like this:
from torrentp import TorrentDownloader
torrent_file = TorrentDownloader("test.torrent", '.')
torrent_file.start_download()
You don’t have the torrent file? just a magnet link? no problem
from torrentp import TorrentDownloader
torrent_file = TorrentDownloader("magnet:...", '.')
torrent_file.start_download()
It’s free and open source! you can fork and star it on Github if you enjoy it or if you like to add a new feature!
Project on GitHub: Github
PyPi Link: PyPi
Don’t forget to star it!
'''
我在谷歌colab上用python搜索了很多,但是没有找到一个简单和快速的用python下载种子文件的方法。所以我决定开始编写自己的封装库来下载种子文件。
TorrentP是一个在本地或者在google Colab上下载种子文件的好方案!
确保你已经安装了Python,然后你可以在终端上使用以下命令来下载:
pip install torrentp
之后,你只需要3个步骤:
- 创建一个.py文件
- 复制并粘贴3行代码
- 运行脚本文件并等待下载完成!
如果你有一个种子文件,可以像这样使用它:
from torrentp import TorrentDownloader
torrent_file = TorrentDownloader("test.torrent", '.')
torrent_file.start_download()
如果你没有种子文件,只有一个磁力链接,也没问题:
from torrentp import TorrentDownloader
torrent_file = TorrentDownloader("magnet:...", '.')
torrent_file.start_download()
这是一个免费且开源的项目!如果你喜欢它或想要添加新的功能,可以在Github上fork和star它!
GitHub项目链接: Github
PyPi链接: PyPi
别忘了给它一个star!