tvkaista-0.962/Makefile tvkaista-0.964/Makefile
3 tvkaista.desktop logo.pov tvkaista.png Makefile3 tvkaista.desktop logo.pov tvkaista.png Makefile
44
55
6all: tvkaista_gtkui6all: tvkaista_gtkui tvkaista_gtkpw
77
8tvkaista_gtkui: tvkaista_gtkui.c tvkaista.desktop8tvkaista_gtkui: tvkaista_gtkui.c tvkaista.desktop
9 sh tvkaista_gtkui.c9 sh $<
10
11tvkaista_gtkpw: tvkaista_gtkpw.c
12 sh $<
1013
11logo.png: logo.pov14logo.png: logo.pov
12 povray -D0 +Q9 +ua -H400 -W500 $<15 povray -D0 +Q9 +ua -H400 -W500 $<
13 @echo tvkaista.png is clipped and scaled from this with GIMP16 @echo tvkaista.png is clipped and scaled from this with GIMP
1417
15install: tvkaista_gtkui18install: tvkaista_gtkui tvkaista_gtkpw
16 sh -n tvkaista.sh && perl -c tvkaista-helper.pl19 sh -n tvkaista.sh && perl -c tvkaista-helper.pl
17 test -d "$$HOME"/.tvkaista || mkdir "$$HOME/".tvkaista20 test -d "$$HOME"/.tvkaista || mkdir "$$HOME/".tvkaista
18 test -d "$$HOME"/.tvkaista/2 || mkdir "$$HOME/".tvkaista/221 test -d "$$HOME"/.tvkaista/2 || mkdir "$$HOME/".tvkaista/2
19 cp tvkaista.sh "$$HOME"/.tvkaista22 cp tvkaista.sh "$$HOME"/.tvkaista
20 cp tvkaista_gtkui "$$HOME"/.tvkaista23 cp tvkaista_gtkui "$$HOME"/.tvkaista
24 cp tvkaista_gtkpw "$$HOME"/.tvkaista
21 cp tvkaista-helper.pl "$$HOME"/.tvkaista25 cp tvkaista-helper.pl "$$HOME"/.tvkaista
22 cp tvkaista.png "$$HOME"/.tvkaista26 cp tvkaista.png "$$HOME"/.tvkaista
23 cp tvkaista.menu "$$HOME"/.tvkaista27 cp tvkaista.menu "$$HOME"/.tvkaista

tvkaista-0.962/gitlog tvkaista-0.964/gitlog
1commit 935a04199c509d2a27e52db1ae78b1e44edabff9
2Author: Tomi Ollila <too@iki.fi>
3Date: Mon May 4 23:08:17 2009 +0300
4
5 tekstien muokkausta. introteksti. version 0.964
6
7M tvkaista.desktop
8M tvkaista_gtkui.c
9
10commit 4a0fccde8f3b8637e50b7e7ce7bafcba16e6e0e7
11Author: Tomi Ollila <too@iki.fi>
12Date: Mon May 4 21:55:05 2009 +0300
13
14 "chomp()" graafisen salasanakyselun tulostuksesta
15 väärä salasana cookieta haettaessa ei vielä toimi (katso/tallenna)
16
17M tvkaista-helper.pl
18
19commit 1d8aa3b6e2c9710fa7a563a335eae435cc39dcce
20Author: Tomi Ollila <too@koti.localdomain>
21Date: Mon May 4 21:21:33 2009 +0300
22
23 tekstitystallennuskorjaus -- samalla tallenteen nimi
24
25M tvkaista-helper.pl
26
27commit 70997995d3892108ee970bf1612238fcba604367
28Author: Tomi Ollila <too@iki.fi>
29Date: Wed Apr 29 22:31:56 2009 +0300
30
31 gui password requester, xterm launchers dropped. version 0.963
32
33M Makefile
34M tvkaista-helper.pl
35M tvkaista.desktop
36M tvkaista.sh
37A tvkaista_gtkpw.c
38M tvkaista_gtkui.c
39
1commit d25ab2b5cd40b78c71111fce700ad6e22f45e9f940commit d25ab2b5cd40b78c71111fce700ad6e22f45e9f9
2Author: Tomi Ollila <too@iki.fi>41Author: Tomi Ollila <too@iki.fi>
3Date: Tue Apr 28 22:18:04 2009 +030042Date: Tue Apr 28 22:18:04 2009 +0300

tvkaista-0.962/tvkaista-helper.pl tvkaista-0.964/tvkaista-helper.pl
4# Author: Tomi Ollila -- too ät iki piste fi4# Author: Tomi Ollila -- too ät iki piste fi
5#5#
6# Created: Sat Feb 07 21:29:53 EET 2009 too6# Created: Sat Feb 07 21:29:53 EET 2009 too
7# Last modified: Tue 28 Apr 2009 21:55:13 EEST too7# Last modified: Mon 04 May 2009 21:40:38 EEST too
88
9#PERL_UNICODE=SD perl tvkaista-helper.pl 1 update9#PERL_UNICODE=SD perl tvkaista-helper.pl 1 update
10#or perl -CSD perl tvkaista-helper.pl 1 list10#or perl -CSD perl tvkaista-helper.pl 1 list
2626
27sub usage()27sub usage()
28{28{
29 die "Usage: $0 <output-fd> (list|play|update)\n";29 die "Usage: $0 [gui] (list|play|update)\n";
30}30}
3131
32if (defined $ARGV[1])32my $gui = 0;
33{33$gui = 1, shift @ARGV if (defined $ARGV[0] && $ARGV[0] eq 'gui');
34 my $dfd = int($ARGV[0]);
35 open STDOUT, ">>&$dfd" if ($dfd > 1);
36}
37else { usage; }
3834
39my $recdir = 'tallenteet';35my $recdir = 'tallenteet';
40if (-e $recdir)36if (-e $recdir)
6359
64sub mkpw($)60sub mkpw($)
65{61{
66 if ($_[0]) {62 if ($gui) {
67 print "\nKäyttäjätunnus ja/tai salasana saattaa olla väärä\n";63 open I, '-|', "./tvkaista_gtkpw $_[0]";
68 print "tai kyseessä on verkko-ongelma.\n";64 chomp ($username = <I>);
69 print "Haluatko antaa uudet (k/e) ? ";65 chomp ($password = <I>);
70 do {66 close I;
71 chomp ($_ = <STDIN>);67 return if $username =~ /^\s*$/;
72 } while (! /^k/ && ! /^e/);
73 return unless /^k/;
74 }68 }
75 else {69 else {
70 if ($_[0]) {
71 print "\nKäyttäjätunnus ja/tai salasana saattaa olla väärä\n";
72 print "tai kyseessä on verkko-ongelma.\n";
73 print "Haluatko antaa uudet (k/e) ? ";
74 do {
75 chomp ($_ = <STDIN>);
76 } while (! /^k/ && ! /^e/);
77 return unless /^k/;
78 }
79 else {
76 print "\nKäyttäjätunnusta ja/tai salasanaa ei tiedossa...\n";80 print "\nKäyttäjätunnusta ja/tai salasanaa ei tiedossa...\n";
77 }81 }
78 print "\nKäyttäjätunnus: ";82 print "\nKäyttäjätunnus: ";
79 chomp ($username = <STDIN>);83 chomp ($username = <STDIN>);
80 print "Salasana: ";84 print "Salasana: ";
81 system 'stty', '-echo';85 system 'stty', '-echo';
82 chomp ($password = <STDIN>);86 chomp ($password = <STDIN>);
83 print "\n";87 print "\n";
84 system 'stty', 'echo';88 system 'stty', 'echo';
85 89 }
86 open O, '>', '2/tunnus' or die $!;90 open O, '>', '2/tunnus' or die $!;
87 print O "tunnus = $username\nsalasana = $password\n";91 print O "tunnus = $username\nsalasana = $password\n";
88 close O;92 close O;
263 mkpw 1 if ($username eq '' or $password eq '');267 mkpw 1 if ($username eq '' or $password eq '');
264 getdatetime;268 getdatetime;
265 recwget "2/today/login-$time.html", 'http://www.tvkaista.fi/netpvr/Login',269 recwget "2/today/login-$time.html", 'http://www.tvkaista.fi/netpvr/Login',
266 '--save-cookies', "cookies-$date-$time.txt", '--keep-session-cookies',270 '--save-cookies', "2/cookies-$date-$time.txt", '--keep-session-cookies',
267 '--max-redirect=0',271 '--max-redirect=0',
268 '--post-data',272 '--post-data',
269 "action=login&username=$username&password=$password&rememberme=on";273 "action=login&username=$username&password=$password&rememberme=on";
270 unlink 'cookies.txt';274 unlink '2/cookies.txt';
271 symlink "cookies-$date-$time.txt", 'cookies.txt';275 symlink "cookies-$date-$time.txt", '2/cookies.txt';
272276
273 return -z "2/today/login-$time.html";277 return -z "2/today/login-$time.html";
274}278}
294{298{
295 #http://www.tvkaista.fi/netpvr/Download/774338.srt299 #http://www.tvkaista.fi/netpvr/Download/774338.srt
296300
297 my $tof = "$_[0].srt";301 my $tof = "$recdir/$_[0].srt";
298302
299 recwget $tof, "http://www.tvkaista.fi/netpvr/Download/$_[0].srt",303 recwget $tof, "http://www.tvkaista.fi/netpvr/Download/$_[0].srt",
300 '--load-cookies', '2/cookies.txt';304 '--load-cookies', '2/cookies.txt';
310 close I;314 close I;
311 if ($conlen > 0) {315 if ($conlen > 0) {
312 $namepfx = 'tekstitys' if $_[1] ne 'wget';316 $namepfx = 'tekstitys' if $_[1] ne 'wget';
313 rename $tof, "$namepfx.srt"; }317 rename $tof, "$recdir/$namepfx.srt"; }
314 else {318 else {
315 unlink $tof; }319 unlink $tof; }
316320
321325
322sub play ($)326sub play ($)
323{327{
324 die "Play needs player, media id and format\n" unless defined $ARGV[4];328 die "Play needs player, media id and format\n" unless defined $ARGV[3];
325329
326 getpw;330 getpw;
327331
328 my $pagename = "2/today/play-$time.html";332 my $pagename = "2/today/play-$time.html";
329333
330 my $format = $speeds{$ARGV[4]};334 my $format = $speeds{$ARGV[3]};
331 recwget $pagename,335 recwget $pagename,
332 "http://www.tvkaista.fi/netpvr/VLC?id=$ARGV[3]&format=$format",336 "http://www.tvkaista.fi/netpvr/VLC?id=$ARGV[2]&format=$format",
333 '--load-cookies', '2/cookies.txt';337 '--load-cookies', '2/cookies.txt';
334338
335 open I, '<', $pagename or die "Can not open '$pagename': $!\n";339 open I, '<', $pagename or die "Can not open '$pagename': $!\n";
343 die "No content found!\n";347 die "No content found!\n";
344 }348 }
345349
350 my ($namepfx, $srtflen) = getsrt($ARGV[2], $ARGV[1]);
346 chdir $recdir;351 chdir $recdir;
347 my ($namepfx, $srtflen) = getsrt($ARGV[3], $ARGV[2]);
348352
349 my @list = ( $ARGV[2] );353 my @list = ( $ARGV[1] );
350 if ($ARGV[2] eq 'wget') {354 if ($ARGV[1] eq 'wget') {
351 push @list, '-O' , "$namepfx.$format";355 push @list, '-O' , "$namepfx.$format";
352 }356 }
353 elsif ($ARGV[2] eq 'vlc') {357 elsif ($ARGV[1] eq 'vlc') {
354 push @list, '--sub-file', "$namepfx.srt" if $srtflen > 0;358 push @list, '--sub-file', "$namepfx.srt" if $srtflen > 0;
355 }359 }
356 elsif ($ARGV[2] eq 'mplayer') {360 elsif ($ARGV[1] eq 'mplayer') {
357 push @list, '-ao', 'oss', '-utf8';361 push @list, '-ao', 'oss', '-utf8';
358 push @list, '-sub', "$namepfx.srt" if $srtflen > 0;362 push @list, '-sub', "$namepfx.srt" if $srtflen > 0;
359 }363 }
360 elsif ($ARGV[2] eq 'xine') {364 elsif ($ARGV[1] eq 'xine') {
361 # how to give subtitle file as separate command line parameter ?365 # how to give subtitle file as separate command line parameter ?
362 }366 }
363367
366 system @list or warn "system(): $!\n";370 system @list or warn "system(): $!\n";
367 print "Executed @list\n";371 print "Executed @list\n";
368372
369 unlink "$namepfx.srt" if $srtflen > 0 && $ARGV[2] ne 'wget';373 unlink "$namepfx.srt" if $srtflen > 0 && $ARGV[1] ne 'wget';
370374
371 # add more checks & cleanups375 # add more checks & cleanups
372 exit 0;376 exit 0;
373}377}
374378
375if ($ARGV[1] eq 'play')379if ($ARGV[0] eq 'play')
376{380{
377 login, play 1 unless play 0;381 login, play 1 unless play 0;
378 exit 1;382 exit 1;
379}383}
380384
381if ($ARGV[1] eq 'update')385if ($ARGV[0] eq 'update')
382{386{
383 my $minfile;387 my $minfile;
384 getpw;388 getpw;
396 pop @logdirs foreach (1..2);400 pop @logdirs foreach (1..2);
397 system '/bin/rm', '-rf', @logdirs if defined (pop @logdirs);401 system '/bin/rm', '-rf', @logdirs if defined (pop @logdirs);
398}402}
399elsif ($ARGV[1] ne 'list')403elsif ($ARGV[0] ne 'list')
400{404{
401 usage;405 usage;
402}406}

tvkaista-0.962/tvkaista.desktop tvkaista-0.964/tvkaista.desktop
1[Desktop Entry]1[Desktop Entry]
2Encoding=UTF-82Encoding=UTF-8
3Version=0.9623Version=0.964
4Name=tv kaista4Name=tv kaista
5Comment=gui-kilentti tvkaistalle5Comment=gui-kilentti tvkaistalle
6GenericName=tvkaista-kilentti6GenericName=tvkaista-kilentti
7Exec=$dest/tvkaista.sh gui7Exec=$dest/tvkaista.sh gui
8Icon=$dest/tvkaista.png8Icon=$dest/tvkaista.png
9Terminal=false9Terminal=true
10Type=Application10Type=Application
11Categories=AudioVideo;Video11Categories=AudioVideo;Video
12StartupNotify=false12StartupNotify=false

tvkaista-0.962/tvkaista.sh tvkaista-0.964/tvkaista.sh
9# All rights reserved9# All rights reserved
10#10#
11# Created: Sat Jan 30 18:41:21 EET 2009 too11# Created: Sat Jan 30 18:41:21 EET 2009 too
12# Last modified: Tue 28 Apr 2009 20:58:20 EEST too12# Last modified: Wed 29 Apr 2009 20:14:37 EEST too
1313
14LANG=fi_FI.utf8 LC_ALL=fi_FI.utf8; export LANG LC_ALL14LANG=fi_FI.utf8 LC_ALL=fi_FI.utf8; export LANG LC_ALL
15LESS= LESSCHARSET=utf-8; export LESS LESSCHARSET15LESS= LESSCHARSET=utf-8; export LESS LESSCHARSET
112112
113 exec ./tvkaista_gtkui113 exec ./tvkaista_gtkui
114}114}
115
116case $1 in gui) cmd_gui ;; esac
117die "currently only 'gui' accepted"
115118
116# ad hoc hack #1119# ad hoc hack #1
117getprograminfo ()120getprograminfo ()

tvkaista-0.962/tvkaista_gtkui.c tvkaista-0.964/tvkaista_gtkui.c
40#include <sys/stat.h>40#include <sys/stat.h>
41#include <fcntl.h>41#include <fcntl.h>
4242
43#include <signal.h>
44#include <errno.h>43#include <errno.h>
4544
46#define null ((void*)0)45#define null ((void*)0)
137 G.prgfd[i] = -1;136 G.prgfd[i] = -1;
138}137}
139138
140FILE * runhelper(bool xterm, const char * format, ...)139FILE * runhelper(const char * format, ...)
141{140{
142 char cmdline[512];141 char cmdline[512];
143 va_list ap;142 va_list ap;
144 int l;143 int l;
145144
146 sprintf(cmdline, xterm ?145 sprintf(cmdline, "exec \"%s\" gui ", G_helper);
147 /* */ "exec 8>&1; exec xterm -hold -fa '' -fs 10 -e \"%s\" 8 " :
148 /* */ "exec \"%s\" 1 ", G_helper);
149 l = strlen(cmdline);146 l = strlen(cmdline);
150 if (l > 500)147 if (l > 500)
151 return null;148 return null;
446443
447 model = create_model();444 model = create_model();
448445
449 FILE * fh = runhelper(0, "list");446 FILE * fh = runhelper("list");
450 if (fh == null)447 if (fh == null)
451 die("Can not run helper to get program list: $!\n");448 die("Can not run helper to get program list: $!\n");
452 fill_store(fh);449 fill_store(fh);
685682
686bool reset_signal(void * inprogress_p)683bool reset_signal(void * inprogress_p)
687{684{
688 signal(SIGTERM, SIG_DFL);
689 *(int*)inprogress_p = false;685 *(int*)inprogress_p = false;
690 return false;686 return false;
691}687}
698 if (inprogress)694 if (inprogress)
699 return;695 return;
700696
701 FILE * fh = runhelper(1, "update");697 FILE * fh = runhelper("update");
702 clean_data();698 clean_data();
703 if (fill_store(fh)) {699 if (fill_store(fh)) {
704 sleep(1);
705 signal(SIGTERM, SIG_IGN);
706 kill(0, SIGTERM);
707 inprogress = true;700 inprogress = true;
708 g_idle_add(reset_signal, &inprogress);701 g_idle_add(reset_signal, &inprogress);
709 }702 }
729 int i = G.previndx / 1000;722 int i = G.previndx / 1000;
730 int j = G.previndx % 1000;723 int j = G.previndx % 1000;
731724
732 runhelper(1, "play %s %d %s", tool, G.prgbuffers[i][j].id, speeds[speed]);725 runhelper("play %s %d %s", tool, G.prgbuffers[i][j].id, speeds[speed]);
733}726}
734727
735void play_pressed(void * uu)728void play_pressed(void * uu)
787 2, true, true,780 2, true, true,
788 aVBox(/* <- homogeneous spacing */ false, 2,781 aVBox(/* <- homogeneous spacing */ false, 2,
789 aHBox(/* <- homogeneous spacing */ false, 2,782 aHBox(/* <- homogeneous spacing */ false, 2,
790 aButton("Päivitä", update_pressed, null),783 aButton("päivitä", update_pressed, null),
791 /* ^^ expand fill padding */ false, true, 2,784 /* ^^ expand fill padding */ false, true, 2,
792 aButton("Katso", play_pressed, null),785 aButton("katso", play_pressed, null),
793 /* ^^ expand fill padding */ false, true, 2,786 /* ^^ expand fill padding */ false, true, 2,
794 aButton("Tallenna", save_pressed, null),787 aButton("tallenna", save_pressed, null),
795 /* ^^ expand fill padding */ false, true, 2,788 /* ^^ expand fill padding */ false, true, 2,
796 W.scb = aTextComboBox(speeds, nspeeds, 2),789 W.scb = aTextComboBox(speeds, nspeeds, 2),
797 /* ^^ expand fill padding */ false, true, 2,790 /* ^^ expand fill padding */ false, true, 2,
834// gtk_widget_show_all(W.w);827// gtk_widget_show_all(W.w);
835}828}
836829
830const char intro[] = "\n"
831 "KORJAA: tarkenna tätä tekstiä...\n"
832 "\n"
833 "Tähän ilmestyy logia tvkaista-ohjelman ajamista komennoista ja\n"
834 "niiden tulostuksesta. Tästä voi seurata kun ongemia ilmenee.\n"
835 "\n"
836 "Ctrl-C tässä lopettaa tvkaista-ohjelman ja mahdollisesti suoritettavan\n"
837 "tallennuksen/tv-ohjelman seurannan. Myöhemmin toimii ehkä paremmin.\n"
838 "\n"
839 "Sitä ennen ehkä kuitenkin selausominaisuudet...\n"
840 "\n"
841 "Tallenteiden sijaintipaikka on $HOME/.tvkaista/tallenteet/.\n"
842 "\n";
837843
838int main(int argc, char *argv[])844int main(int argc, char *argv[])
839{845{
841 init_G();847 init_G();
842 gtk_init(&argc, &argv);848 gtk_init(&argc, &argv);
843 setenv("PERL_UNICODE", "SD", 1);849 setenv("PERL_UNICODE", "SD", 1);
850 write(1, intro, sizeof intro - 1);
844 gui();851 gui();
845 gtk_main();852 gtk_main();
846 return 0;853 return 0;