source: lab.git/misc/torrent2tsv.pl @ 7c991ad

trunk
Last change on this file since 7c991ad was b804ca6, checked in by mitty <mitty@…>, 13 years ago
  • 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

  • Property mode set to 100644
File size: 626 bytes
RevLine 
[b804ca6]1#! /usr/bin/perl -w
2
3use strict;
4use warnings;
5
6my $exec = 'dumptorrent-1.2.exe';
7
8my $torrent = shift @ARGV;
9
10if (! -f $torrent) {
11    die "$0: file doesn't exit: $torrent";
12}
13
14my @output = `$exec "$torrent" 2>&1`;
15
16my ($name, @files);
17
18while (my $line = shift @output) {
19   
20    if (!$name and $line =~ /^Name:\s+(.*)$/) {
21        $name = $1;
22    }
23    if ($line =~ /^Files:/) {
24        while ($line = shift @output) {
25            if ($line =~ /^\s+(.+\w)\s+\d+( \([0-9\.]+[KM]\))?$/) {
26                push (@files, $1);
27            }
28        }
29    }
30}
31
32foreach my $file (@files) {
33    print "$torrent\t$name\t$file\n";
34}
Note: See TracBrowser for help on using the repository browser.