VA appt, aria2c for torrent file selection
VA appointment: labs
Had a 0715 slot for labs so there were no delays. The lab results will be interpreted by the Dr at my medical appt in a few days.
After I left the facility and found a park to walk the doggo the VA sent this helpful text. Received it an hour after the appointment was over, which makes it of dubious value as a reminder:
aria2c
aria2 is a fantastic tool for downloading stuff. It does http/s, ftp, bittorrent (torrents and magnets) and many things I have never seen in the wild. I use it as the backend downloader for youtube-dl since the resume functions and config options are robust.
Problem: sometimes torrents contain multiple files but you only want one (see example below). I use YAAW to monitor progress but it does not appear to honor file selection. Let’s do it on the command line with aria2c
In the examples below we will use a torrent for a linux distribution, which is free to d/l. For convenience and display I will trim the full magnet link down to the bare minimum:
magnet:?xt=urn:btih:febd9a2cb755ec82e6e7a015a8dc497fde9dd507
if online listing is available
According to magnetdl.com1 the file list is:
/ubuntu-ultimate-1.4-dvd.iso (1.94 GB)
/ubuntu-ultimate-1.4-dvd.iso.md5 (62 B) <-- we only want this
/ubuntu-ultimate-1.4-dvd.iso.sha1 (70 B)
It’s ~2gig of data but let’s say I only want the md5 hash (62 bytes). We can issue this command:
aria2c --select-file=2 magnet:?xt=urn:btih:febd9a2cb755ec82e6e7a015a8dc497fde9dd507
This will download only the selected file[s]. It is possible that other file pieces might be downloaded if they share chunks with the target file. They will be fragmentary and deleteable.
if an accurate listing is unavailable
In this scenario we have to pull down a copy of the torrent file to parse locally so we can see the file list in order:
aria2c --bt-save-metadata=true --follow-torrent=false {link to torrent}
The .torrent file will be downloaded but the files will not.
If we only have a magnet link we use:
aria2c --bt-metadata-only --bt-save-metadata magnet:?xt=urn:btih:febd9a2cb755ec82e6e7a015a8dc497fde9dd507
Saved metadata as /home/mouse/torrent/complete/febd9a2cb755ec82e6e7a015a8dc497fde9dd507.torrent.
Note the .torrent is named after the magnet/hash.
extracting the list from the local .torrent
Once we have a local .torrent file from either method we can
aria2c --show-file febd9a2cb755ec82e6e7a015a8dc497fde9dd507.torrent
…but it outputs more than we need. Let’s use this:
-----------------------------------------------
aria2c --show-file febd9a2cb755ec82e6e7a015a8dc497fde9dd507.torrent | grep \|
idx|path/length
1|./ubuntu-ultimate-1.4-dvd/ubuntu-ultimate-1.4-dvd.iso
|1.9GiB (2,083,522,560)
2|./ubuntu-ultimate-1.4-dvd/ubuntu-ultimate-1.4-dvd.iso.md5
|62B (62)
3|./ubuntu-ultimate-1.4-dvd/ubuntu-ultimate-1.4-dvd.iso.sha1
|70B (70)
Yep, there’s our md5 at #2.
So now we can now select-file against
- a remote .torrent
- the local torrent
- magnet link
aria2c --select-file=2 febd9a2cb755ec82e6e7a015a8dc497fde9dd507.torrent
12/16 14:23:16 [NOTICE] Downloading 1 item(s)
12/16 14:23:16 [NOTICE] IPv4 DHT: listening on UDP port 6971
12/16 14:23:16 [NOTICE] IPv4 BitTorrent: listening on TCP port 6890
12/16 14:23:16 [NOTICE] IPv6 BitTorrent: listening on TCP port 6890
[#951c0b 0B/2.1KiB(0%) CN:5 SD:0 DL:0B]
12/16 14:23:17 [NOTICE] Download of selected files was complete.
[#951c0b SEED(0.0) CN:2 SD:0]
12/16 14:23:40 [NOTICE] Shutdown sequence commencing... Press Ctrl-C again for emergency shutdown.
12/16 14:23:40 [NOTICE] Download complete: ubuntu-ultimate-1.4-dvd
12/16 14:23:40 [NOTICE] Your share ratio was 0.0, uploaded/downloaded=0B/2.1KiB
Download Results:
gid |stat|avg speed |path/URI
======+====+===========+=======================================================
951c0b|OK | 1.3KiB/s|ubuntu-ultimate-1.4-dvd.iso.md5
NOte: I redacted path names for privacy and display. I also bailed out of the seeding session because this was just for demonstration using a tiny file.
comments
mastodon comment thread for this post
twitter comment thread for this post
-
ad- and javascript-blocking recommended; sites like this tend to have NSFW ads ↩