set editor to 'vim'
[lab.git] / misc / torrent2filelist.pl
1 #! /usr/bin/perl -w
2
3 use strict;
4 use warnings;
5
6 use Net::BitTorrent::File;
7 use Data::Dumper;
8
9 my $torretfile = shift @ARGV;
10 my $torrent = Net::BitTorrent::File->new($torretfile) or
11     die "$0: cannot load torrent file: $torretfile";
12
13 my $files = $torrent->files;
14 if ($files) {
15     foreach my $file (@$files) {
16         if (exists $file->{'path.utf-8'}) {
17             print $torrent->name, "/", join ("/", @{ $file->{'path.utf-8'} }), "\n";
18         }
19         else {
20             print $torrent->name, "/", join ("/", @{ $file->{'path'} }), "\n";
21             
22         }
23     }
24 }
25 else {
26     print $torrent->name, "\n";
27 }