From a3463648d1c70337a5bc2919a88eeace36c6499f Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Fri, 19 Sep 2014 23:00:00 +0000 Subject: list dropboxes now parses new improved format diff --git a/lib/rddb.pm b/lib/rddb.pm index b8188e2..823629d 100755 --- a/lib/rddb.pm +++ b/lib/rddb.pm @@ -81,7 +81,7 @@ sub get_dropboxes { my ($dbh, $username) = @_; - my $sql = qq{select USER_PERMS.GROUP_NAME,DROPBOXES.PATH,DROPBOXES.TO_CART,GROUPS.DESCRIPTION from USER_PERMS, DROPBOXES, GROUPS where USER_PERMS.USER_NAME= ? and DROPBOXES.GROUP_NAME=USER_PERMS.GROUP_NAME and DROPBOXES.GROUP_NAME=GROUPS.NAME;}; + my $sql = qq{select USER_PERMS.GROUP_NAME,DROPBOXES.PATH,DROPBOXES.TO_CART,DROPBOXES.NORMALIZATION_LEVEL,DROPBOXES.AUTOTRIM_LEVEL,DROPBOXES.SET_USER_DEFINED,GROUPS.DESCRIPTION from USER_PERMS, DROPBOXES, GROUPS where USER_PERMS.USER_NAME= ? and DROPBOXES.GROUP_NAME=USER_PERMS.GROUP_NAME and DROPBOXES.GROUP_NAME=GROUPS.NAME;}; my $sth = $dbh->prepare($sql) or return (undef, 'ERROR', "Database Error: " . $dbh->errstr); @@ -90,37 +90,32 @@ sub get_dropboxes or return (undef, 'ERROR', "Database Error: " . $sth->errstr); my @allowed_dbs; - while(my ($group, $path, $to_cart, $desc) = $sth->fetchrow_array()) { - $path =~ s/\/\*$//; - my $name = $path; - if($name =~ /^([0-9]{2}-[A-Za-z]+)\/([0-9]{2})([0-9]{2})-([01]{4})-([0-9]{3})\/(.*)$/) { - $name = "$1 - $2:$3 - $6 ($4, $5)"; + while(my ($group, $type, $showid, $normlevel, $trimlevel, $params, $groupdesc) = $sth->fetchrow_array()) { + + my $entry = {}; + $entry->{'GROUP'} = $group; + $entry->{'GROUPDESC'} = $groupdesc; + $entry->{'TYPE'} = $type; + $entry->{'SHOWID'} = -1; + $entry->{'NORMLEVEL'} = $normlevel; + $entry->{'TRIMLEVEL'} = $trimlevel; + $entry->{'PARAM'} = $params; + if($type eq "show") { + $entry->{'SHOWID'} = $showid; + # $params has the format: 1111-01-1600-060 + if($params =~ /^([01]{4})-([0-9]{2})-([0-9]{2})([0-9]{2})-([0-9]{3})$/) { + $entry->{'RHYTHM'} = $1; + $entry->{'DOW'} = int $2; + $entry->{'STARTTIME'} = "$3:$4"; + $entry->{'LENGTH'} = int $5; + } } - elsif($name =~ /^([0-9]{2}-[A-Za-z]+)\/jingle$/ || $name =~ /^jingles\/(.*)$/) { - $name = "Jingles - $1"; - } - elsif($name =~ /^pool\/pool(.*)$/) { - $name = "Pool $1 - $desc"; - } - elsif($name =~ /^pool\/(.*)$/) { - $name = "Pool - $1"; - } - elsif($name =~ /^sondersendungen\/(.*)$/) { - $name = "Sondersendungen - $1"; - } - elsif($name =~ /^autoimport\/(.*)$/) { - $name = "autoimport - $1"; - } - my $perm = {}; - $perm->{'GROUP'} = $group; - $perm->{'PATH'} = $path; - $perm->{'TO_CART'} = $to_cart; - $perm->{'NAME'} = $name; - push @allowed_dbs, $perm; + + push @allowed_dbs, $entry; } $sth->finish(); - return sort { uc($a->{'NAME'}) cmp uc($b->{'NAME'}) } @allowed_dbs; + return @allowed_dbs; } diff --git a/listdrobpoxes.cgi b/listdrobpoxes.cgi index f2dec4f..c1efb06 100755 --- a/listdrobpoxes.cgi +++ b/listdrobpoxes.cgi @@ -46,10 +46,19 @@ if($responsecode != 200) { print "\n"; for my $href (@dropboxes) { print " \n"; - print " " . $href->{'NAME'} . "\n"; print " " . $href->{'GROUP'} . "\n"; - print " " . $href->{'PATH'} . "\n"; - print " " . $href->{'TO_CART'} . "\n"; + print " " . $href->{'GROUPDESC'} . "\n"; + print " " . $href->{'TYPE'} . "\n"; + print " " . $href->{'SHOWID'} . "\n"; + print " " . $href->{'NORMLEVEL'} . "\n"; + print " " . $href->{'TRIMLEVEL'} . "\n"; + print " " . $href->{'PARAM'} . "\n"; + if($href->{'TYPE'} eq "show") { + print " " . $href->{'RHYTHM'} . "\n"; + print " " . $href->{'DOW'} . "\n"; + print " " . $href->{'STARTTIME'} . "\n"; + print " " . $href->{'LENGTH'} . "\n"; + } print " \n"; } print "\n"; -- cgit v0.10.2