Changeset 858


Ignore:
Timestamp:
Oct 10, 2009, 2:37:54 AM (10 years ago)
Author:
bruno
Message:
  • Proto version 6 for UTF-8 support
  • CDDB_get 2.27 now required for revision support
  • new ce_prepare_mail function
File:
1 edited

Legend:

Unmodified
Added
Removed
  • projects/CDDBeditor/bin/CDDBeditor

    r855 r858  
    2121use lib qw (lib);
    2222use locale;
     23# > 2.27
    2324use CDDB_get qw( get_cddb get_discids );
    24 use CDDB;
    2525use Encode;
    2626
     
    3131my @date = pb_get_date();
    3232my $pbdate = strftime("%Y-%m-%d", @date);
     33
     34pb_temp_init();
    3335
    3436=pod
     
    180182$ce_config{"HTTP_PROXY"}=$ENV{http_proxy} if $ENV{http_proxy};
    181183$ce_config{"input"}=0;
     184$ce_config{"HELLO_ID"} = "bruno musique-ancienne.org fastrip 0.77";
     185$ce_config{"PROTO_VERSION"} = 6;
    182186
    183187# First panel for configuration parameters
     
    256260$ce_config{"CD_DEVICE"}=$dev_entry->Get();
    257261$ce_config{"input"}=$user_group->Get();
    258 $ce_config{"HELLO_ID"} = "bruno musique-ancienne.org fastrip 0.77";
    259262
    260263# Components
     
    279282    my %ce_cd = get_cddb(\%ce_config);
    280283
    281     # Modify enconding of some fields
    282     $ce_cd{artist} = decode("iso8859-1",$ce_cd{artist});
    283     $ce_cd{title} = decode("iso8859-1",$ce_cd{title});
     284    # Modify enconding of some fields if proto < 5
     285    #$ce_cd{artist} = decode("iso8859-1",$ce_cd{artist});
     286    #$ce_cd{title} = decode("iso8859-1",$ce_cd{title});
    284287
    285288    # Third panel to display CD Infos
     
    344347        my $min=int($dur/75/60);
    345348        my $sec=int($dur/75)-$min*60;
    346         my $frm=($dur-$sec*75-$min*75*60)*100/75;
     349        #my $frm=($dur-$sec*75-$min*75*60)*100/75;
    347350        my $tr = sprintf "Track %2d:", $n;
    348351        my $track_label = Newt::Label($tr);
    349352        $tr = sprintf " %2d':%.2d", $min, $sec;
     353        # Adapt encoding of track if proto < 5
     354        #$ce_cd{track}[$n -1] = decode("iso8859-1",$ce_cd{track}[$n -1]);
     355
    350356        my $dur_label = Newt::Label($tr);
    351357        $flag = NEWT_FLAG_WRAP|NEWT_ENTRY_SCROLL;
    352         # Adapt encoding of track
    353         $ce_cd{track}[$n -1] = decode("iso8859-1",$ce_cd{track}[$n -1]);
    354358        my $track_entry = Newt::Entry($width, $flag, $ce_cd{track}[$n-1]);
    355359        $ce_panel->Add(0, 8+$n, $track_label);
     
    383387        $width = 40;
    384388        my $height = 25;
    385         my $info_tb = Newt::Textbox($width, $height, $flag, Dumper(keys %ce_cd));
    386389
    387390        Newt::DrawRootText(ce_center_string($ce_title), 1, $ce_title);
    388391        Newt::PushHelpLine($ce_help);
     392
     393        ce_prepare_mail(\%ce_cd);
     394        open(TEXT,"$ENV{'PBTMP'}/mail.txt") || die "Unable to open $ENV{'PBTMP'}/mail.txt";
     395        my $txt = "";
     396        #my $txt = pb_get_content("$ENV{'PBTMP'}/mail.txt");
     397        while (<TEXT>) {
     398            next if (/^#/);
     399            $txt .= $_;
     400        }
     401        my $info_tb = Newt::Textbox($width, $height, $flag, $txt);
    389402
    390403        Newt::Cls();
     
    413426}
    414427
     428sub ce_prepare_mail() {
     429
     430my $ce_cd = shift;
     431
     432open(MAIL, "> $ENV{'PBTMP'}/mail.txt") || die "Unable to create $ENV{'PBTMP'}/mail.txt";
     433print MAIL "# xmcd CD database file\n#\n# Track frame offsets:\n";
     434my $n=1;
     435while ( $n <= $ce_cd->{tno} ) {
     436    print MAIL "#       ".$ce_cd->{frames}[$n-1]."\n";
     437    $n++;
     438}
     439my $from=$ce_cd->{frames}[0];
     440my $to=$ce_cd->{frames}[$ce_cd->{tno}];
     441my $dur=$to-$from;
     442my $sec=int($dur/75);
     443my $rev = $ce_cd->{revision} + 1;
     444print MAIL "#\n# Disc length: $sec seconds\n#\n";
     445print MAIL "# Revision: $rev\n";
     446print MAIL "# Processed by: cddbd v1.5PL3 Copyright (c) Steve Scherf et al.\n";
     447print MAIL "# Submitted via: CDDBEditor $projver-$projrev\n";
     448print MAIL "DISCID=$ce_cd->{id}\n";
     449print MAIL "DTITLE=$ce_cd->{title}\n";
     450print MAIL "DYEAR=$ce_cd->{year}\n";
     451print MAIL "DGENRE=$ce_cd->{genre}\n";
     452$n=1;
     453while ( $n <= $ce_cd->{tno} ) {
     454    print MAIL "TTITLE$n=$ce_cd->{track}[$n-1]\n";
     455    $n++;
     456}
     457print MAIL "EXTD=\n";
     458$n=1;
     459while ( $n <= $ce_cd->{tno} ) {
     460    print MAIL "EXTT$n=\n";
     461    $n++;
     462}
     463print MAIL "PLAYORDER=\n";
     464close(MAIL);
     465}
     466
    4154671;
Note: See TracChangeset for help on using the changeset viewer.