Is there any way to view the contents of a magnet URL using command line?

I've tried aria2c which can view the contents of a torrent file but doesn't seem to show contents of magnet URLs.


Magnet link doesn't contains any information about files. At first you should download torrent and then you can extract information. E.g. you can use aria2 utility. Here is bash wrapper function:

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

That function will download torrent to $hash.torrent file and then display it's content.

Usage example:

$ 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
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
   |547MiB (573,571,072)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.