#!/usr/bin/perl # Dit scriptje laat de NOS teletext zien, GPL versie 2 # (c) 2001, 2002, 2003 by Bas Zoetekouw # All rights reserved. # (c) 2013 Miek Gieben # Complete rewrite. # http://utopia.knoware.nl/users/eprebel/Communication/Prestel/index.html use LWP::Simple; use Switch; use strict; my $color = 1; if ((scalar @ARGV > 0) && ($ARGV[0] eq "-m")) { $color = 0; shift; } my %graphs = ( "0" => "", "1" => "", "2" => "", "3" => "", "4" => "", "5" => "▌", "6" => "", "7" => "", "8" => "", "9" => "", " " => " ", "j" => "▐", "k" => "▜", "p" => "▂", "q" => "", "r" => "", "s" => "═", "t" => "⌙", "u" => "▙", "/" => "▖", "#" => " ", "`" => " ", "," => "━", "<" => "", "|" => "━", A => "A", B => "B", C => "C", D => "D", E => "E", F => "F", G => "G", H => "H", I => "I", J => "J", K => "K", L => "L", M => "M", N => "N", O => "O", P => "P", Q => "Q", R => "R", S => "S", T => "T", U => "U", V => "V", W => "W", X => "X", Y => "Y", Z => "Z", ); my %specials = ( "" => "\e[7m ", " " => "\e[0m \n ", "" => "■", ); my %gcolors = ( "" => "\e[31m", #red "" => "\e[32m", #green "" => "\e[33m", #yellow "" => "\e[34m", #blue "" => "\e[35m", #blue "" => "\e[36m", #blue "" => "\e[37m", #white "" => "" , #contiguous display ); my %colors = ( "" => "\e[31m", #red "" => "\e[32m", #green "" => "\e[33m", #yellow "" => "\e[34m", #blue "" => "\e[35m", #magenta "" => "\e[36m", #cyan "" => "\e[37m", #white "" => "\e[30m", #background to black ); sub display(@) { # last line contains tt my $line = $_[-1]; $line =~ s/
//; $line =~ s/<\/pre>//;
    my $i = 0;
    my $set = 0;    # 0: normal set, 1: graphics set
    foreach (split //, $line) {
        switch ($_) {
        case { exists $gcolors{$_} }   { print $gcolors{$_} if $color; print " "; $set = 1; }
        case { exists $specials{$_} }  { print $specials{$_}; }
        case { exists $colors{$_} }    { print $colors{$_} if $color; print " "; $set = 0; }
        else                           {
                                            if ($set == 0) { utf8::encode $_; print ; }
                                            if ($set == 1) { print $graphs{$_}; }
                                       }
        }
        $i++;
        if ($i > 39) { print "\e[0m\n"; $i = 0; $set = 0; }
    }
}

my ($pag, $sub) = @ARGV;
$pag = "100" if (scalar @ARGV == 0);
$sub = "0"   if (scalar @ARGV <= 1);
display split /\n/, get "http://teletekst.e-office.com/g/android?p=${pag}-${sub}&id=" . time;