On Sun, Jul 25, 2010 at 9:24 PM, NisargaYoga <steven.harn...@gmail.com>wrote:
> 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. > > > -- > To unsubscribe, e-mail: beginners-unsubscr...@perl.org > For additional commands, e-mail: beginners-h...@perl.org > http://learn.perl.org/ > > > Hi, I have never attempted to work with BEncoded files but a simple search on CPAN shows that other have (quite a few of them actually). I would advise you to have a look at their work and if at all possible reuse the modules they have made available for this type of work. After all it makes very little sense to reinvent the wheel doesn't it? So go to: http://search.cpan.org and look for BEncode. The first module I found looks very prommising: http://search.cpan.org/~aristotle/Bencode-1.4/lib/Bencode.pm it encodes and decodes files to and from Perl hashs by the look of it (just looked at the first example. I think that might just be what you are looking for. ;-) Rob