-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest_prog2.pl
46 lines (40 loc) · 995 Bytes
/
test_prog2.pl
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
#!/usr/bin/env perl
# use progs::podcasts;
use lib ".";
use progs::hbo;
use common::sense;
my $net = out::have_net();
my $p = progs::hbo->new($net) || die "cration prog\n";
my $channel = "HBO (East) US";
my $sub = $p->get($channel) || die "die rcupration prog $@\n";
say "got sub $sub";
my $n = 1;
my $show = 0;
$n = 1;
print "Les 10 programmes d'après :\n";
while ($n < 10 && $sub) {
core($sub);
$sub = $p->next($channel);
$n++;
}
sub dateheure {
# Affiche une date partir d'un champ time()
$_ = shift;
my ($sec,$min,$hour,$mday,$mon,$year) = localtime($_);
sprintf("%d/%d/%d %d:%02d",$mday,$mon+1,$year+1900,$hour,$min);
}
sub core {
my $sub = shift;
print dateheure($$sub[3])," ",dateheure($$sub[4])," $$sub[2] desc:$$sub[6] dtails:$$sub[7]\n";
if ($$sub[9] && !$show) {
$show = 1;
my $c = chaines::request($$sub[9]);
open(F,">image.jpg");
print F $c;
close(F);
system("feh image.jpg");
unlink("image.jpg");
} elsif ($$sub[9]) {
say "image $$sub[9]";
}
}