develooper Front page | perl.beginners | Postings from July 2010

Extract data from BEncoded .torrent files

Thread Next
From:
NisargaYoga
Date:
July 25, 2010 12:48
Subject:
Extract data from BEncoded .torrent files
Message ID:
3cf18b1a-11f2-4b03-bb7b-2f9b8e3ba2c5@d17g2000yqb.googlegroups.com
Hi - Total newbie and my first post so please tell me if I'm doing
anything wrong.

My first real Perl project - looking for some conceptual guidance.

The project involves processing of BEncoded .torrent files downloaded
from an rtorrent seedbox.

Bottom line is I want to cycle through about 150 files in a directory
and extract two data pieces from each file: the name of the torrent
file and another statistic. The data could be saved in .csv files.

Specifically the object is to extract on a weekly basis the number of
bytes that the seedbox has uploaded for each torrent (about 150 active
torrents), in order to detect torrents that have minimal activity, so
they can be deleted later (manually).

All work will be done on either my PC or my Linux box (not on the
hosted seedbox server).

In rtorrent, active torrents are stored at /var/www2/
rtorrent2/.rtsession/

I downloaded all active .torrent files to my desktop PC via FTP.

I can see the contents of each torrent using "BEncode Editor". Besides
the "normal" .torrent information, a torrent taken from the
".rtsession" directory has an additional node for data specific to its
status in the seedbox.

I don't see a way to attaching a sample file, but I saved one in this
directory:

http://www.nisargayoga.org/hidden/    << the file name is "my-
downloaded-active.torrent"

When opened with BEncode Editor (before the nodes are expanded) the
bottom node is labeled

"rtorrent (d)[23]"    << has it [23] elements, I don't know what the
(d) means

When this node is expanded, the second node from the bottom is

"total_uploaded (i) =  212151318"

<< this is the statistic I need, plus the name, which is in an earlier
node.

The node with the name is "info (d)[6] --> name (b)[77]"

So to recap, the project is to cycle through all BEncoded .torrent
files in a directory, extract 2 pieces of data from each and write the
output to a .csv file, one row per torrent, 2 data items per row.

There must be a half-dozen ways to do this but you could help me by
pointing me in the right direction. All suggestions welcome.

Thanks very much.


Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About