From 54536a410fa3963774ea81f75663b815eb8bc802 Mon Sep 17 00:00:00 2001 From: mitty Date: Tue, 10 Apr 2012 15:47:14 +0000 Subject: [PATCH] * parse .torrent file and print list of files * this script couldn't many .torrent file because of Convert::Bencode bugs like below {{{ Use of uninitialized value $item in string eq at Perl/site/lib/Convert/Bencode.pm line 127. Use of uninitialized value $item in string eq at Perl/site/lib/Convert/Bencode.pm line 138. Use of uninitialized value $item in string eq at Perl/site/lib/Convert/Bencode.pm line 148. }}} git-svn-id: https://lab.mitty.jp/svn/lab/trunk@135 7d2118f6-f56c-43e7-95a2-4bb3031d96e7 --- misc/torrent2filelist.pl | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 misc/torrent2filelist.pl diff --git a/misc/torrent2filelist.pl b/misc/torrent2filelist.pl new file mode 100644 index 0000000..09eb51d --- /dev/null +++ b/misc/torrent2filelist.pl @@ -0,0 +1,27 @@ +#! /usr/bin/perl -w + +use strict; +use warnings; + +use Net::BitTorrent::File; +use Data::Dumper; + +my $torretfile = shift @ARGV; +my $torrent = Net::BitTorrent::File->new($torretfile) or + die "$0: cannot load torrent file: $torretfile"; + +my $files = $torrent->files; +if ($files) { + foreach my $file (@$files) { + if (exists $file->{'path.utf-8'}) { + print $torrent->name, "/", join ("/", @{ $file->{'path.utf-8'} }), "\n"; + } + else { + print $torrent->name, "/", join ("/", @{ $file->{'path'} }), "\n"; + + } + } +} +else { + print $torrent->name, "\n"; +} -- 1.7.9.5