Comments (6)
from torf.
from torf.
from torf.
You need to
torrent.generate()
before you cantorrent.write()
. Also, you can modifytorrent.files
like any regular list, so you can do stuff likedel torrent.files[3]
ortorrent.files.remove("file/path")
.
Thanks for your reply. It seems that i have a wrong understanding for torf
.
add torrent.generate
I tried torrent.generate()
. But there are some errors. The code and error information are below:
from torf import Torrent
torrent = Torrent.read('./temp/old.torrent')
#torrent.files = [torrent.files[0], torrent.files[2], torrent.files[-1]]
del torrent.files[3]
torrent.generate()
torrent.write('./temp/new.torrent')
Traceback (most recent call last):
File "test.py", line 6, in
torrent.generate()
File "D:\work\02work\work\009torrent\rw-torrent\venv\lib\site-packages\torf_torrent.py", line 1016, in generate
raise RuntimeError('generate() called with no path specified')
RuntimeError: generate() called with no path specified
add path
I add a path to torrent
:
from torf import Torrent
torrent = Torrent.read('./temp/old.torrent')
#torrent.files = [torrent.files[0], torrent.files[2], torrent.files[-1]]
del torrent.files[3]
torrent.path = 'temp'
torrent.generate()
print(torrent.files)
torrent.write('./temp/new.torrent')
But the new.torrent
contains the files which are in my computer, instead of the files in the old.torrent
. The information is below:
λ ls temp/
k old.torrent
(venv) admin@DESKTOP-ILNMBPV /d/work/02work/work/009torrent/rw-torrent
λ python test.py
[File('temp\k', size=95829), File('temp\old.torrent', size=95829)]
(venv) admin@DESKTOP-ILNMBPV /d/work/02work/work/009torrent/rw-torrent
what's more, if the path
does not exist, the code and error information are below:
from torf import Torrent
torrent = Torrent.read('./temp/old.torrent')
#torrent.files = [torrent.files[0], torrent.files[2], torrent.files[-1]]
del torrent.files[3]
torrent.path = 'temp_not_exist'
torrent.generate()
print(torrent.files)
torrent.write('./temp/new.torrent')
Traceback (most recent call last):
File "C:\ProgramData\Anaconda3\lib\os.py", line 350, in walk
scandir_it = scandir(top)
FileNotFoundError: [WinError 3] The system cannot find the specified path: 'temp_not_exist'During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "test.py", line 6, in
torrent.path = 'temp_not_exist'
File "D:\work\02work\work\009torrent\rw-torrent\venv\lib\site-packages\torf_torrent.py", line 178, in path
for fp in utils.list_files(basepath))
File "D:\work\02work\work\009torrent\rw-torrent\venv\lib\site-packages\torf_utils.py", line 138, in list_files
for dirpath, dirnames, filenames in os.walk(path, onerror=onerror):
File "C:\ProgramData\Anaconda3\lib\os.py", line 353, in walk
onerror(error)
File "D:\work\02work\work\009torrent\rw-torrent\venv\lib\site-packages\torf_utils.py", line 136, in onerror
getattr(exc, 'filename', None))
torf._errors.ReadError: temp_not_exist: No such file or directory
my goal
I want to download several files in a torrent which contains a lot of files. I want to remove some files in the torrent. So can a torrent file be modified by torf?
from torf.
Thanks @rndusr . So I can only download the specific files in the original torrent, instead of making a new torrent from the original torrent.
from torf.
from torf.
Related Issues (20)
- wrong infohash HOT 2
- File conflict with python-hypothesis HOT 4
- Question remove file HOT 6
- v2 Torrent - Invalid metainfo: Missing 'pieces' in ['info'] HOT 1
- A question about source flag. HOT 1
- Is it possible to use single file with multi-file type directory struture? HOT 4
- Missing __enter and __exit method HOT 8
- How can I make it not create a directory HOT 1
- Is it possible to add a file with a different filename inside the torrent? HOT 4
- Too many open files HOT 5
- Piece size not power of two HOT 5
- [Feature request]load torrent file from bytes object. HOT 1
- infohash got changed after load, without any modification HOT 1
- Add link to torf-gui in readme HOT 5
- Allow setting 32MB piece size HOT 9
- `collections.abc.ByteString` is deprecated in Python 3.12 and will be removed in Python 3.14 HOT 1
- License HOT 4
- Create single file torrent from a stream HOT 5
- Allow creating 64 MB piece size HOT 2
- Subfolders HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from torf.