* parse .torrent file and print tag separated list of
authormitty <mitty@7d2118f6-f56c-43e7-95a2-4bb3031d96e7>
Thu, 12 Apr 2012 08:05:25 +0000 (08:05 +0000)
committermitty <mitty@7d2118f6-f56c-43e7-95a2-4bb3031d96e7>
Thu, 12 Apr 2012 08:05:25 +0000 (08:05 +0000)
{{{
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 [new file with mode: 0644]

diff --git a/misc/torrent2tsv.pl b/misc/torrent2tsv.pl
new file mode 100644 (file)
index 0000000..bee73a6
--- /dev/null
@@ -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";
+}