summaryrefslogtreecommitdiffstats
path: root/tools/intro-outro
blob: 99682e45c976374e0062af7ed4f7e46411c9354c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
#!/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;

my $file = 'test.csv';
my $csv = Text::CSV->new();
my @takk;
my @url;
my $counter = "000";

open (CSV, "<:encoding(utf8)", "$file") or die "$file: $!";

while (<CSV>) {
	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];

		print "#$.. Filename: $filename\n";

		print "\tIntro:\n";
		print "\t\tSlide 1: Logo: $logo\n";
		print "\t\tSlide 2: Name: $name\n";
		print "\t\tSlide 2: Title: $title\n";
		print "\t\tSlide 2: What: $what\n";
		print "\t\tSlide 2: Date: $date\n";
		print "\t\tSlide 2: Location: $location\n";
		print "\t\tSlide 3: License: $license\n";

		system("bash ./image_logo $filename.dv $counter white $logo"); $counter++;
		system("bash ./image_logo $filename.dv $counter white $logo"); $counter++;
		system("bash ./image_logo $filename.dv $counter white $logo"); $counter++;

		system("bash ./image_text $filename.dv $counter white '$what' '$date - $location'"); $counter++;
		system("bash ./image_text $filename.dv $counter white '$what' '$date - $location'"); $counter++;
		system("bash ./image_text $filename.dv $counter white '$what' '$date - $location'"); $counter++;

		system("bash ./image_text $filename.dv $counter white '$title' '$name'"); $counter++;
		system("bash ./image_text $filename.dv $counter white '$title' '$name'"); $counter++;
		system("bash ./image_text $filename.dv $counter white '$title' '$name'"); $counter++;

		system("cp $license.png $filename-$counter.png"); $counter++;
		system("cp $license.png $filename-$counter.png"); $counter++;
		system("cp $license.png $filename-$counter.png"); $counter++;

		# .dv buh fix!
		system("./image2video $filename.dv intro");
		system("rm $filename-*.png");
		$counter="000";

		print "\tOutro:\n";

		system("bash ./image_text $filename.dv $counter black 'TAKK TIL'"); $counter++;
		system("bash ./image_text $filename.dv $counter black 'TAKK TIL'"); $counter++;
		system("bash ./image_text $filename.dv $counter black 'TAKK TIL'"); $counter++;

		print "\t\tName: $name\n";
		print "\t\tLocation: $location\n";

		system("bash ./image_text $filename.dv $counter black '$name' Foredragsholder"); $counter++;
		system("bash ./image_text $filename.dv $counter black '$location' Lokaler"); $counter++;

		foreach (@takk) {
			my $test = $columns[$_];
			my @takk = split(/:/, $test);
			my $hva = $takk[0];
			my $hvem = $takk[1];
		# if takk1 ""
			print "\t\t$hvem - $hva\n";
			system("bash ./image_text $filename.dv $counter black '$hvem' '$hva'"); $counter++;
		}

		foreach (@url) {
			my $lenke = $columns[$_];
			print "\t\tURL: $lenke\n";
			system("bash ./image_text $filename.dv $counter black ' '"); $counter++;
			system("bash ./image_text $filename.dv $counter black '$lenke'"); $counter++;
			system("bash ./image_text $filename.dv $counter black '$lenke'"); $counter++;
		}

		# .dv buh fix!
		system("./image2video $filename.dv outro");
		system("rm $filename-*.png");

	} else {
		my $err = $csv->error_input;
		print "Failed to parse line #$..: $err";
	}
}

close CSV;