#!/opt/bin/perl BEGIN { require "common.pl" } our ($TXN, %stat, $db_env, $TPB, $db_info, $TODAY); use common::sense; use BDB; use JSON::XS; use Bencode; use CBOR::XS; ############################################################################# our $db_http = table "http"; our $db_torrent = table "torrent"; ############################################################################# #db_compact $db_http, undef, undef, undef, undef, 0, undef; my @del_http; my @del_torrent; if(1) { my $c = $db_torrent->cursor; while () { db_c_get $c, my $key, my $data, BDB::NEXT; last if $!; syswrite STDOUT, "\rT $key "; unless (ref eval { Bencode::bdecode $data, 1, 32 }) { print "bdecode error $@"; iput $key, [0, 1]; push @del_torrent, $key; } } } if(0) { my $c = $db_http->cursor; while () { db_c_get $c, my $key, my $data, BDB::NEXT; last if $!; syswrite STDOUT, "\rH $key "; unless ((dic_decompress 0, $data) =~ m% href="magnet:\?xt=urn:btih:([0-9a-f]*)&dn%) { print +(dic_decompress 0, $data), "\nno magnet"; iput $key, [0, 1]; push @del_http, $key; push @del_torrent, $key; }; } } db_del $db_http , undef, $_ for @del_http; db_del $db_torrent, undef, $_ for @del_torrent;