From b804ca6f58de1bbefdf2ee1768dba58c0dcbc868 Mon Sep 17 00:00:00 2001 From: mitty Date: Thu, 12 Apr 2012 08:05:25 +0000 Subject: [PATCH] * parse .torrent file and print tag separated list of {{{ torrent filename \t torrent name \t files }}} git-svn-id: https://lab.mitty.jp/svn/lab/trunk@136 7d2118f6-f56c-43e7-95a2-4bb3031d96e7 --- misc/torrent2tsv.pl | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 misc/torrent2tsv.pl diff --git a/misc/torrent2tsv.pl b/misc/torrent2tsv.pl new file mode 100644 index 0000000..bee73a6 --- /dev/null +++ b/misc/torrent2tsv.pl @@ -0,0 +1,34 @@ +#! /usr/bin/perl -w + +use strict; +use warnings; + +my $exec = 'dumptorrent-1.2.exe'; + +my $torrent = shift @ARGV; + +if (! -f $torrent) { + die "$0: file doesn't exit: $torrent"; +} + +my @output = `$exec "$torrent" 2>&1`; + +my ($name, @files); + +while (my $line = shift @output) { + + if (!$name and $line =~ /^Name:\s+(.*)$/) { + $name = $1; + } + if ($line =~ /^Files:/) { + while ($line = shift @output) { + if ($line =~ /^\s+(.+\w)\s+\d+( \([0-9\.]+[KM]\))?$/) { + push (@files, $1); + } + } + } +} + +foreach my $file (@files) { + print "$torrent\t$name\t$file\n"; +} -- 1.7.9.5