Skip to content

Instantly share code, notes, and snippets.

@buzztiaan
Created October 21, 2020 11:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save buzztiaan/294302a0eeff89f55784b45cecb4dc5a to your computer and use it in GitHub Desktop.
Save buzztiaan/294302a0eeff89f55784b45cecb4dc5a to your computer and use it in GitHub Desktop.
parse big .torrent directories and only grab infohash and name
#!/usr/bin/perl
use warnings;
use Net::BitTorrent::File;
$directory = "./yts.am_26.01.2019/yts.am_torrents_26.01.2019";
#$directory = "./mac-torrents.com_23.01.2019/torrents";
$directory = "./eztv.io_27.01.2019/eztv.io_torrents_27.01.2019";
$directory = "./nostalgic.is_19.12.2019/nostalgic.is_public_torrents/";
opendir DIR, $directory;
my @files = readdir(DIR);
close DIR;
foreach(@files) {
if ((-f $directory . "/" . $_) && (-s $directory . "/" . $_)) {
my $torrent = new Net::BitTorrent::File ($directory. "/" .$_);
$info_hash = $torrent->info_hash();
$printvalue = "";
while ($info_hash =~ /(.)/g) {
$printvalue .= sprintf('%02x', unpack("C*",$1));
}
print $printvalue." | ";
print $torrent->name;
print "\n";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment