← Back to team overview

puredyne-team team mailing list archive

torrent download statistics

 

Hey all,

Statistics are useful for lots of important things.

As of a few minutes ago, 20 downloads via bittorrent have completed (10 each of CD and DVD).

Attached is a quickly hacked together script that gets the download stats from the two (DVD, CD) 9.10 torrents. Info hash was copy/pasted from rtorrent. Expect a recipe in a blog post on my website in the coming days, the key point is you need the 20-byte binary hash, then url-encode it - it's either not obvious to find that out or my googlefu is weak... Note that the output isn't extracted from the returned response (will add that to the recipe, maybe).

Compile with: gcc -o hash2bin hash2bin.c


Claude
--
http://claudiusmaximus.goto10.org

Attachment: check-torrent-stats.sh
Description: Bourne shell script

#include <stdio.h>
#include <string.h>

int hexdigit(char c) {
  if ('0' <= c && c <= '9') { return c - '0'; }
  if ('a' <= c && c <= 'f') { return c - 'a' + 10; }
  if ('A' <= c && c <= 'F') { return c - 'A' + 10; }
  return -1;
}

int main(int argc, char **argv) {
  int i;
  char hi;
  char lo;
  char buffer[20];
  char *inptr;
  char *outptr;
  if (argc != 2) return 1;
  if (strlen(argv[1]) != 40) return 1;
  inptr = argv[1];
  outptr = buffer;
  for (i = 0; i < 20; ++i) {
    hi = *inptr++;
    lo = *inptr++;
    if (hi < 0 || lo < 0) return 1;
    *outptr++ = (hexdigit(hi) << 4) | hexdigit(lo);
  }
  fwrite(buffer, 20, 1, stdout);
  return 0;
}