通过命令行查看magnet URL的内容?

通过命令行查看magnet URL的内容?

有没有办法使用命令行查看磁铁 URL 的内容?

我尝试过aria2c可以查看 torrent 文件的内容,但似乎不显示磁铁 URL 的内容。

答案1

磁力链接不包含有关文件的任何信息。首先您应该下载 torrent,然后您可以提取信息。例如你可以使用咏叹调2公用事业。这是 bash 包装函数:

magnet-info() {
  hash=$(echo "$1" | grep -oP "(?<=btih:).*?(?=&)")
  echo "Magnet hash: $hash"
  aria2c --bt-metadata-only=true --bt-save-metadata=true -q "$1"
  aria2c "$hash.torrent" -S
}

该函数会将 torrent 下载到$hash.torrent文件,然后显示其内容。

使用示例:

$ magnet-info "magnet:?xt=urn:btih:64b7700828fd44b37c0c045091939a2c0258ddc2&dn=archlinux-2014.06.01-dual.iso&tr=udp://tracker.archlinux.org:6969&tr=http://tracker.archlinux.org:6969/announce"
Magnet hash: 64b7700828fd44b37c0c045091939a2c0258ddc2
>>> Printing the contents of file '64b7700828fd44b37c0c045091939a2c0258ddc2.torrent'...
*** BitTorrent File Information ***
Mode: single
Announce:
 udp://tracker.archlinux.org:6969
 http://tracker.archlinux.org:6969/announce
Info Hash: 64b7700828fd44b37c0c045091939a2c0258ddc2
Piece Length: 512KiB
The Number of Pieces: 1094
Total Length: 547MiB (573,571,072)
Name: archlinux-2014.06.01-dual.iso
Magnet URI: magnet:?xt=urn:btih:64B7700828FD44B37C0C045091939A2C0258DDC2&dn=archlinux-2014.06.01-dual.iso&tr=udp%3A%2F%2Ftracker.archlinux.org%3A6969&tr=http%3A%2F%2Ftracker.archlinux.org%3A6969%2Fannounce
Files:
idx|path/length
===+===========================================================================
  1|./archlinux-2014.06.01-dual.iso
   |547MiB (573,571,072)
---+---------------------------------------------------------------------------

相关内容