use strict;
use warnings FATAL => q(all);
use JSON;
use URI;
use URI::QueryParam;
use UUID 'uuid';
binmode STDOUT;
my %h = (
db => { version => 1 },
header => {
params => undef,
slots => undef
},
version => 1,
);
while (<>) {
next unless /otpauth:.*/;
my $u = URI->new($&);
push @{ $h{db}->{entries} }, {
icon => undef,
info => {
algo => "SHA1", period => 30, digits => 6, },
name => ( $u->path_segments )[-1],
issuer => ( $u->path_segments )[-1],
type => $u->authority,
uuid => uuid(),
};
}
for ( @{ $h{db}->{entries} } ) {
$_->{info}->{digits} += 0;
$_->{info}->{period} += 0;
}
my $json = JSON->new;
$json = $json->canonical(1);
print $json->pretty->encode( \%h );