Copyright 2022 - Custom text here

amc_xtract.pl

#!perl

#$amc_file = "C:\\TEMP\\clodomi_1\\amc2csv\\cinematheque.amc";
# amc_xtract.pl "C:\\local\\cinematheque\\cinémathèque.amc" "E:\\docs\\outgoing\\cinematheque.html"
# amc_xtract.pl "C:\\local\\cinematheque enfants\\cinémathèque enfant.amc" "E:\\docs\\outgoing\\cinematheque_enfants.html"

$amc_file = $ARGV[0];
$html_file = $ARGV[1];

$amc2csv_exe = "C:\\local\\bin\\amc2csv.exe";

$csv_file = $amc_file;
$csv_file =~ s/\.amc/\.csv/i;

($_sec,$_min,$_hour,$dd,$mm,$yy,$_wday,$_yday) = localtime(time);
$mm++;
$yy+=1900;
system "\"$amc2csv_exe\" \"$amc_file\" \"$csv_file\"";

open(F, $csv_file) || die "Cannot open $csv_file: $_\n";
open (H, ">$html_file" ) || die "Cannot open $html_file: $_\n";
print H "<HTML><HEAD><TITLE>CJ Cinémathèque</TITLE></HEAD>\n<BODY><I>Mise à jour du $dd/$mm/$yy</I><TABLE><TR><TD><B>Numéro</B></TD><TD><B>Titre</B></TD><TD><B>Année</B></TD><TD><B>Lien</B></TD></TR>";
$i=0;
while ($line = <F>){
    if( $i % 2){
         $bgcolor = '#FFFFFF';
    }else{
         $bgcolor = '#EEEEEE';
    }
    $i++;
    $line =~ s/\n//;
    ($Number,$Checked,$Media_Label,$Media_Type,$Source,$Date,$Borrower,$Rating,$Original_Title,$Translated_Title,$Formatted_Title,$Director,$Producer,$Country,$Category,$Year,$Length,$Actors,$URL,$Description,$Comments,$Video_Format,$Video_Bitrate,$Audio_Format,$Audio_Bitrate,$Resolution,$Framerate,$Languages,$Subtitles,$Size,$Disks) = split(/;/,$line);
    $Formatted_Title = $Original_Title;
    if( $Translated_Title && $Translated_Title ne $Original_Title){
        $Formatted_Title .= "($Translated_Title)";
    }
    if( length($Formatted_Title) > 32 ){
        $Formatted_Title = substr($Formatted_Title,0,32);
        $Formatted_Title .= "...";
    }
    $Formatted_Title = lc($Formatted_Title);
    $Formatted_Title = ucfirst($Formatted_Title);
    print H "<TR BGCOLOR=$bgcolor><TD>$Number</TD><TD>$Formatted_Title</TD><TD>$Year</TD><TD><A href=\"$URL\"><FONT size=\"-2\">lien</FONT></A></TD></TR>\n";
}
close(F);
print H "</TABLE></BODY></HTML>\n";
close(H);
f t g m