Closed jarkahome closed 1 year ago
Please advise on how I can modify the files in the torrent and create a new torrent file with the modified files.
From a perspective of a torrent what you're trying to do is not a modification by nature, but the creation of a new file. That's so because files
is the most essential part of a torrent file, and modification of this entry requires data reprocessing. For example, if you do not have all files of the torrent downloaded, you cannot comprise torrent file "equal" to the initial. Those would be two different files with different hashes and will be announced by a tracker as such.
The right and more obvious way to do what you want, is to create a new file from the directory, copying some metadata from the initial file properties.
Thank you for your response. However, what I want to do is modify a downloaded torrent file, specifically unchecking some of the files like in a BitTorrent client. I understand that modifying the files in a torrent file may not be feasible, but is there a way to achieve this using the torrentool library without creating a new file based on a directory
However, what I want to do is modify a downloaded torrent file, specifically unchecking some of the files like in a BitTorrent client.
In a client you do not modify a torrent, instead you just instruct it not to download some file stated in the torrent. I should emphasize that there's no notion of editing the file, since what you're really doing is creating a new file.
Considered closed. Feel free to reopen if required.
I have a question, if a.torrent has 2 files in my_torrent.files (afile,bfile),I downloaded afile, bfile I need download again. so i need edit my_torrent.files and to_file a new torrent ,how can I do? In fact , a.torrent has 2000file, I had downloaded a part like 100,I want 2 edit torrent , just redownload the rest of all
@chen88358323
so i need edit my_torrent.files and to_file a new torrent ,how can I do? In fact , a.torrent has 2000file, I had downloaded a part like 100,I want 2 edit torrent , just redownload the rest of all
I'm afraid there is some misundertanding on how you treat the torrent file.
To download files you do not need torrentool, but you do need a torrent client. Also you do not need to edit the torrent to download the rest of files (in fact making a new torrent file will prevent you to download those files, since nobody except you has such an exact torrent).
Instead you need to instruct your torrent client to download the rest of files.
I am using the torrentool library to read and modify a torrent file in Python. When I try to set the files property of a Torrent object, I get an AttributeError saying that the property has no setter.
Here is my code:
`from torrentool.api import Torrent
Read the original torrent file
original_torrent = Torrent.from_file('test.torrent')
Create a new torrent file with modified files
new_torrent = Torrent() new_torrent.comment = original_torrent.comment new_torrent.created_by = original_torrent.created_by new_torrent.creation_date = original_torrent.creation_date new_torrent.creation_date = original_torrent.creation_date new_torrent.files = []
Modify the files
for file in original_torrent.files: if not file.name.endswith('.srt'): new_torrent.files.append((file.name, file.size))
Write the new torrent file
new_torrent.to_file('new.torrent') `
I expect this code to create a new torrent file with the same properties as the original, but with some files removed. However, when I try to set the files property of the new Torrent object, I get an AttributeError saying that the property has no setter.
Please advise on how I can modify the files in the torrent and create a new torrent file with the modified files.
Thank you.