简体   繁体   English

从torrent集合中的单个文件生成torrent / magnet链接

[英]Generate a torrent/magnet link from a single file in a torrent collection

I was wondering if it is possible, having a torrent collection (IE a torrent containing multiple files) to extract a single one, generating an almost new torrent/magnet link to download only that single file but using the same source (announce, etc), instead of dowloading the whole torrent and then select what to download or not. 我想知道是否有可能,拥有一个torrent集合(IE包含多个文件的torrent)来提取单个文件,生成一个几乎全新的torrent /磁力链接,只下载该单个文件但使用相同的来源(宣布等)而不是下载整个洪流,然后选择下载或不下载。

Thanks for any hint about. 谢谢你的任何提示。

2019 Update: Yes, you now can! 2019年更新:是的,你现在可以! In 2017 a draft BEP was released that covers the question's behaviour for magnet URIs! 2017年发布了一份BEP草案,涵盖了磁体URI的问题行为! This is great, as it creates a standard that keeps a consistent info_hash between a magnet URI pointing to the multi-file torrent, and a magnet URI pointing to a single file within that multi-file torrent. 这很棒,因为它创建了一个标准,在指向多文件torrent的磁体URI和指向该多文件torrent中的单个文件的磁体URI之间保持一致的info_hash。 They will share a swarm, which means you can, as the question asks "[generate] an almost new torrent/magnet link to download only that single file but using the same source". 他们将共享一个群,这意味着你可以,因为问题是“[生成]一个几乎全新的洪流/磁铁链接,只下载该单个文件,但使用相同的来源”。

The draft BEP: http://www.bittorrent.org/beps/bep_0053.html BEP 53: "Magnet URI extension - Select specific file indices for download" BEP草案: http//www.bittorrent.org/beps/bep_0053.html BEP 53:“磁铁URI扩展 - 选择要下载的特定文件索引”

Example URI to request files 0, 2, 4 and the inclusive range 6 through to 8: 请求文件0,2,4和包含范围6到8的示例URI:

magnet:?xt=urn:btih:HASH&dn=NAME&tr=TRACKER&so=0,2,4,6-8

And the draft BEP is making it's way into bittorrent libraries: BEP草案正在进入bittorrent图书馆:


2013-MAY-03 Original Answer: Sometimes yes, but not often, and the resulting swarm has no peers. 2013年5月3日原始答案:有时是,但不经常,并且由此产生的群体没有同伴。

Firstly, you need the original .torrent file, so if you only have a magnet URI you need to resolve that to a .torrent using DHT. 首先,您需要原始的.torrent文件,因此如果您只有磁体URI,则需要使用DHT将其解析为.torrent。 Any bittorrent library that supports magnet URIs has the code for that task. 任何支持磁体URI的bittorrent库都有该任务的代码。

Once you have the .torrent, you then need to get the hashes relating to the file you're interested in. The .torrent file contains a very long string, each 20 bytes representing the hash of each piece in the torrent. 一旦你拥有.torrent,你就需要得到与你感兴趣的文件相关的哈希值.torrent文件包含一个很长的字符串,每个字节代表一个字符串中每个部分的哈希值。 Piece length is fixed for a torrent, typically between 256KB and 1MB. 片段长度固定为torrent,通常在256KB到1MB之间。 If the file starts at exactly a piece offset, and is sized equal to a multiple of the piece size or is the last file in the torrent then you can reuse these hashes. 如果文件以一个片段偏移量开始,并且大小等于片段大小的倍数或者是torrent中的最后一个文件,那么您可以重用这些哈希值。 You can then create a new .torrent file with that information, and generate a new magnet URI from the torrent file, re-using the announce or using a new one. 然后,您可以使用该信息创建新的.torrent文件,并从torrent文件生成新的磁体URI,重新使用通知或使用新的。

Torrent info structure: https://wiki.theory.org/BitTorrentSpecification#Metainfo_File_Structure Torrent信息结构: https//wiki.theory.org/BitTorrentSpecification#Metainfo_File_Structure

Being lucky enough to get that offset is unlikely, with a piece length generally varying between 256KB & 1MB, you have a 1/262144 to 1/268435456 chance of getting that offset (given that a file could start anywhere in a piece), so the circumstance is unlikely. 幸运地获得该偏移是不太可能的,片段长度通常在256KB和1MB之间变化,你有1/262144到1/268435456获得该偏移的机会(假设文件可以从一块中的任何地方开始),所以情况不太可能。 If you can't re-use the hashes, you need to generate new hashes which means you can't re-use the .torrent and would need to download the files to generate the new piece hashes. 如果你不能重新使用哈希,你需要生成新的哈希值,这意味着你不能重新使用.torrent,并且需要下载文件来生成新的哈希值。

The killer is that in the end, the torrent created has a different info_hash. 杀手最后,创建的torrent有一个不同的info_hash。 The info_hash is the hash of the info describing the torrent, which was a description of many files and now in your new hash is the description of a single file, thus is a new torrent so there's no-one available to leech from. info_hash是描述torrent的信息的哈希值,这是对许多文件的描述,现在在你的新哈希中是单个文件的描述,因此是一个新的torrent,所以没有人可以从中获取。 Peers collect into swarms based on the info_hash, and if you create a new torrent based on one file from a multifile torrent, the peers from the multifile torrent don't know about it and won't be available to leech from. 对等体基于info_hash收集到群组中,如果您基于多文件torrent中的一个文件创建新的torrent,则多文件torrent中的对等体不知道它并且无法从中获取。

Even if you're lucky enough to get the right piece offsets, you create a torrent that doesn't have anyone sharing the file. 即使你很幸运能获得正确的偏移量,你也可以创建一个没有任何人共享文件的torrent。

So, could you instead re-use the magnet URI and just specify a file name within the torrent? 那么,您是否可以重新使用磁体URI并在torrent中指定文件名? No, the BEP that describes how Bittorrent uses magnet URIs doesn't cover this behaviour. 不,描述Bittorrent如何使用磁体URI的BEP并未涵盖此行为。 http://www.bittorrent.org/beps/bep_0009.html http://www.bittorrent.org/beps/bep_0009.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM