#!/usr/bin/perl # # Date: 2009-12-04 # Author: Ole Kristian Lien # License: GNU General Public License # # Creates a intro and outro video-file from a csv-file # # libtext-csv-perl # see test.csv use strict; use warnings; use Text::CSV; use File::Basename; if ($#ARGV != 0 ) { print "usage: intro-outro \n"; exit; } my $file=$ARGV[0]; my $csv = Text::CSV->new(); my @takk; my @url; my $counter = "000"; open (CSV, "<:encoding(utf8)", "$file") or die "$file: $!"; while () { if ($csv->parse($_)) { my @columns = $csv->fields(); if ($. == 1) { my $index; foreach (@columns) { if ($_ eq "Takk") { push(@takk, $index); } elsif ($_ eq "URL") { push(@url, $index); } $index++; } } next if ($. == 1); my $filename = $columns[0]; my $logo = $columns[1]; my $name = $columns[2]; my $title = $columns[3]; my $what = $columns[4]; my $date = $columns[5]; my $location = $columns[6]; my $license = $columns[7]; my $takk = $columns[8]; my $filenametmp = fileparse($filename, qr/\.\D.*/); unless (-e $filename) { print "File: $filename doesn't Exist!\n"; exit 1; } print "#$.. Filename: $filename\n"; print "\tIntro:\n"; print "\t\tLogo: $logo\n"; print "\t\tName: $name\n"; print "\t\tTitle: $title\n"; print "\t\tWhat: $what\n"; print "\t\tDate: $date\n"; print "\t\tLocation: $location\n"; print "\t\tLicense: $license\n"; system("bash ./image_logo $filename $counter white $logo"); $counter++; system("bash ./image_logo $filename $counter white $logo"); $counter++; system("bash ./image_logo $filename $counter white $logo"); $counter++; system("bash ./image_text $filename $counter white '$what' '$date - $location'"); $counter++; system("bash ./image_text $filename $counter white '$what' '$date - $location'"); $counter++; system("bash ./image_text $filename $counter white '$what' '$date - $location'"); $counter++; system("bash ./image_text $filename $counter white '$title' '$name'"); $counter++; system("bash ./image_text $filename $counter white '$title' '$name'"); $counter++; system("bash ./image_text $filename $counter white '$title' '$name'"); $counter++; system("cp $license.png $filenametmp-$counter.png"); $counter++; system("cp $license.png $filenametmp-$counter.png"); $counter++; system("cp $license.png $filenametmp-$counter.png"); $counter++; # .dv buh fix! system("./image2video $filename intro"); system("rm $filenametmp-*.png"); $counter="000"; print "\tOutro:\n"; system("bash ./image_text $filename $counter black 'TAKK TIL'"); $counter++; system("bash ./image_text $filename $counter black 'TAKK TIL'"); $counter++; system("bash ./image_text $filename $counter black 'TAKK TIL'"); $counter++; print "\t\tName: $name\n"; print "\t\tLocation: $location\n"; system("bash ./image_text $filename $counter black '$name' Foredragsholder"); $counter++; system("bash ./image_text $filename $counter black '$location' Lokaler"); $counter++; foreach (@takk) { my $test = $columns[$_]; if($test) { my @takk = split(/:/, $test); my $hva = $takk[0]; my $hvem = $takk[1]; # if takk1 "" print "\t\tTakk: $hvem - $hva\n"; system("bash ./image_text $filename $counter black '$hvem' '$hva'"); $counter++; } } foreach (@url) { my $lenke = $columns[$_]; print "\t\tURL: $lenke\n"; system("bash ./image_text $filename $counter black ' '"); $counter++; system("bash ./image_text $filename $counter black '$lenke'"); $counter++; system("bash ./image_text $filename $counter black '$lenke'"); $counter++; } system("./image2video $filename outro"); system("rm $filenametmp-*.png"); } else { my $err = $csv->error_input; print "Failed to parse line #$..: $err"; } } close CSV;