tvkaista-0.985/Makefile tvkaista-0.986/Makefile
2#VERSION_CONTROLLED= tvkaista.sh tvkaista_gtkui.c tvkaista-helper.pl \2#VERSION_CONTROLLED= tvkaista.sh tvkaista_gtkui.c tvkaista-helper.pl \
3# tvkaista.desktop logo.pov tvkaista.png Makefile3# tvkaista.desktop logo.pov tvkaista.png Makefile
44
5VERSION=0.986
56
6all: tvkaista_gtkui tvkaista_gtkpw7all: tvkaista_gtkui tvkaista_gtkpw
78
8tvkaista_gtkui: tvkaista_gtkui.c tvkaista.desktop custom-list.o9tvkaista_gtkui: tvkaista_gtkui.c Makefile custom-list.o
9 sh $<10 sh $<
1011
11custom-list.o: custom-list.c custom-list.h12custom-list.o: custom-list.c custom-list.h
27 cp tvkaista_gtkpw "$$HOME"/.tvkaista28 cp tvkaista_gtkpw "$$HOME"/.tvkaista
28 cp tvkaista-helper.pl "$$HOME"/.tvkaista29 cp tvkaista-helper.pl "$$HOME"/.tvkaista
29 cp tvkaista.png "$$HOME"/.tvkaista30 cp tvkaista.png "$$HOME"/.tvkaista
30 cp tvkaista.menu "$$HOME"/.tvkaista31 sed 's|$$dest|'"$$HOME/.tvkaista|" tvkaista.menu \
32 > "$$HOME"/.tvkaista/tvkaista.menu
31 sed 's|$$dest|'"$$HOME/.tvkaista|" tvkaista.desktop \33 sed 's|$$dest|'"$$HOME/.tvkaista|" tvkaista.desktop \
32 > "$$HOME"/.tvkaista/tvkaista.desktop34 > "$$HOME"/.tvkaista/tvkaista.desktop
33 rm -f "$$HOME"/bin/tvkaista_gtk "$$HOME"/bin/tvkaista_gtkui \35 rm -f "$$HOME"/bin/tvkaista_gtk "$$HOME"/bin/tvkaista_gtkui \
40 || ln -sf ../.tvkaista/tvkaista.desktop "$$HOME"/Työpöytä42 || ln -sf ../.tvkaista/tvkaista.desktop "$$HOME"/Työpöytä
41 test -d "$$HOME"/.menu || mkdir "$$HOME"/.menu43 test -d "$$HOME"/.menu || mkdir "$$HOME"/.menu
42 ln -sf ../.tvkaista/tvkaista.menu "$$HOME"/.menu/tvkaista44 ln -sf ../.tvkaista/tvkaista.menu "$$HOME"/.menu/tvkaista
45# test -d "$$HOME/".icons || mkdir "$$HOME"/.icons
46# test -d "$$HOME/".icons/hicolor || mkdir "$$HOME"/.icons/hicolor
47# test -d "$$HOME/".icons/hicolor/48x48 || mkdir "$$HOME"/.icons/hicolor/48x48
48# test -d "$$HOME/".icons/hicolor/48x48/apps || mkdir "$$HOME"/.icons/hicolor/48x4
8/apps
49# rm -f "$$HOME/".icons/hicolor/48x48/apps/tvkaista_gtk.png
50# ln -s "$$HOME"/.tvkaista/tvkaista_gtk.png "$$HOME"/.icons/hicolor/48x48/apps
43 case `env which update-menus >/dev/null 2>&1` in /*) update-menus;;esac51 case `env which update-menus >/dev/null 2>&1` in /*) update-menus;;esac
52# case `env which update-icon-caches >/dev/null 2>&1` in /*) update-icon-caches "$
$HOME"/.icons/hicolor ;;esac
4453
45gitlog: #$(VERSION_CONTROLLED)54gitlog: #$(VERSION_CONTROLLED)
46 git log --name-status > $@55 git log --name-status > $@
4958
50targz: gitlog59targz: gitlog
51# requires recent-enough GNU tar60# requires recent-enough GNU tar
52 ver=`sed -n 's/Version=//p' tvkaista.desktop`; \61 ver=`sed -n 's/VERSION[=]//p' Makefile`; \
53 tar --transform "s|^|tvkaista-$$ver/|" -zcf tvkaista-$$ver.tar.gz \62 tar --transform "s|^|tvkaista-$$ver/|" -zcf tvkaista-$$ver.tar.gz \
54 tvkaista_gtkui.c tvkaista-helper.pl tvkaista.sh custom-list.c \63 tvkaista_gtkui.c tvkaista-helper.pl tvkaista.sh custom-list.c \
55 tvkaista_gtkpw.c tvkaista.desktop tvkaista.png custom-list.h \64 tvkaista_gtkpw.c tvkaista.desktop tvkaista.png custom-list.h \

tvkaista-0.985/gitlog tvkaista-0.986/gitlog
1commit 432e48fe9644923078590b4617e16de3ef8c2742
2Author: Tomi Ollila <too@iki.fi>
3Date: Sun Jan 3 21:53:45 2010 +0200
4
5 'make targz' ottaa version myös ;akefile:sta...
6
7M Makefile
8
9commit 8b6c5350ff998e6d55428cca57d4ce9da3c19729
10Author: Tomi Ollila <too@iki.fi>
11Date: Sun Jan 3 21:50:51 2010 +0200
12
13 Versio 0.986
14
15M Makefile
16
17commit 48a61bc8307e8d49a9c0d2c6193a11ef09ae7637
18Author: Tomi Ollila <too@iki.fi>
19Date: Sun Jan 3 21:50:26 2010 +0200
20
21 korjattu listin ajo 2 kertaa...
22
23M tvkaista_gtkui.c
24
25commit 15da79551e52ac6b820cbba30cfc02261ff647b8
26Author: Tomi Ollila <too@iki.fi>
27Date: Sun Jan 3 21:16:55 2010 +0200
28
29 tvkaista-helper kerää joitain tietoja omilla http-hauilla
30
31M tvkaista-helper.pl
32
33commit 59abc9c1221a8a2d4aa3051b96a5b01788762fbf
34Author: Muu <wubi@ubuntu.ubuntu-domain>
35Date: Sun Jan 3 13:48:33 2010 +0200
36
37 install fixes
38
39M Makefile
40M tvkaista.desktop
41M tvkaista.menu
42M tvkaista_gtkui.c
43
44commit 68c09eeee84a53f62acb90e20e6aed4d49f26852
45Author: Tomi Ollila <too@iki.fi>
46Date: Sun Jan 3 00:45:44 2010 +0200
47
48 koodia talteen...
49
50A base64_tiny.pl
51M tvkaista-helper.pl
52
1commit a8ff625b77e205f2eb6d78db94502087e500113f53commit a8ff625b77e205f2eb6d78db94502087e500113f
2Author: Tomi Ollila <too@iki.fi>54Author: Tomi Ollila <too@iki.fi>
3Date: Sat Jan 2 19:23:53 2010 +020055Date: Sat Jan 2 19:23:53 2010 +0200

tvkaista-0.985/tvkaista-helper.pl tvkaista-0.986/tvkaista-helper.pl
14use warnings;14use warnings;
1515
16use Time::Local qw( timegm );16use Time::Local qw( timegm );
17use Time::HiRes qw( gettimeofday );
18use MIME::Base64 qw( encode_base64 );17use MIME::Base64 qw( encode_base64 );
1918
20select STDERR;19select STDERR;
44{43{
45 my @t = localtime;44 my @t = localtime;
46 ($date, $time) = ( sprintf('%d-%02d-%02d', $t[5] + 1900, $t[4] + 1, $t[3]),45 ($date, $time) = ( sprintf('%d-%02d-%02d', $t[5] + 1900, $t[4] + 1, $t[3]),
47 sprintf('%02d:%02d:%02d', $t[2], $t[1], $t[0]) );46 sprintf('%02d%02d%02d', $t[2], $t[1], $t[0]) );
48 #print "$date -- $time\n";47 #print "$date -- $time\n";
49}48}
50getdatetime;49getdatetime;
50open LOG, '>>', 'run.log';
51print LOG "+ $date $time $0 @ARGV\n";
5152
52unless (-d "4/logs.$date") {53unless (-d "4/logs.$date") {
53 mkdir "4/logs.$date";54 mkdir "4/logs.$date";
104# '--save-headers', '-O', @_;105# '--save-headers', '-O', @_;
105}106}
106107
108use IO::Socket::INET;
109sub openhttpstream($$$)
110{
111 my ($redir, $host, $path) = ($_[0], $_[1], $_[2]);
112 while (1) {
113 # XXX check unauthorized, rotate tunnus (paitsi jos sama jonkun)!
114 $host = "$host:80" unless $host =~ /:/;
115 print "Opening host $host, path $path\n";
116 my $sock = IO::Socket::INET->new($host) or die "INET->new: $!\n";
117 print $sock "GET $path HTTP/1.0\r\n";
118 print $sock "User-Agent: tvkaista-helper.pl\r\n";
119 print $sock "Accept: */*\r\n";
120 print $sock "Connection: Close\r\n";
121 print $sock "Authorization: Basic $b64cred\r\n";
122 print $sock "\r\n";
123
124 print "--8<----8<----8<----8<--\n";
125 my ($moved, $location, $rc) = (0, undef, 0);
126 while (<$sock>) {
127 print $_;
128 if (/HTTP.*\s(\d+)\s/) {
129 $rc = $1;
130 $moved = 1 if $rc == 301 || $rc == 302;
131 next;
132 }
133 $location = $1 if /Location:\s+(https?:\/\/.*\S)\s*/;
134 # XXX check unauthorized, rotate tunnus (paitsi jos sama jonkun)!
135 last if (/^\s*$/);
136 }
137 print "-->8---->8---->8---->8--\n";
138 if ($moved) {
139 close $sock;
140 die "No location\n" unless defined $location;
141 if ($redir) {
142 $location =~ m|https?:\/\/(.*?)(/.*)|;
143 ($host, $path) = ($1, $2);
144 next;
145 }
146 return $location;
147 }
148 $path =~ /outputfilename=(.*)/;
149 return ($sock, $1, $rc);
150 }
151}
152
107my %months = ( Jan => 1, Feb => 2, Mar => 3, Apr => 4, May => 5, Jun => 6,153my %months = ( Jan => 1, Feb => 2, Mar => 3, Apr => 4, May => 5, Jun => 6,
108 Jul => 7, Aug => 8, Sep => 9, Oct => 10, Nov => 11, Dec => 12 );154 Jul => 7, Aug => 8, Sep => 9, Oct => 10, Nov => 11, Dec => 12 );
109155
162208
163sub update ()209sub update ()
164{210{
165 feedwget "4/today/channels-$time.rss", "4/today/channels-$time.log",211 feedwget "4/today/chnlist-$time.rss", "4/today/chnlist-$time.log",
166 'http://www.tvkaista.fi/feed/channels/';212 'http://alpha.tvkaista.fi/feed/channels/';
167 return 0 if -z "4/today/channels-$time.rss";213 return 0 if -z "4/today/chnlist-$time.rss";
168 open I, '<', "4/today/channels-$time.rss" or die $!;214 open I, '<', "4/today/chnlist-$time.rss" or die $!;
169 my (@channels, $linktail, $c);215 my (@channels, $linktail, $c);
170 while (<I>) { last if /<ttl>/; }216 while (<I>) { last if /<ttl>/; }
171 while (<I>) {217 while (<I>) {
177 $c = 100;223 $c = 100;
178224
179 my @urls;225 my @urls;
180 push @urls, "http://www.tvkaista.fi/feed/channels/$_/flv.rss"226 push @urls, "http://alpha.tvkaista.fi/feed/channels/$_/flv.rss"
181 foreach (@channels);227 foreach (@channels);
182228
183 feedwget "4/today/a-$time-now.rss", "4/today/a-$time-now.log", @urls;229 feedwget "4/today/chnls-now-$time.rss","4/today/chnls-now-$time.log", @urls;
184230
185 open I, '<', "4/today/a-$time-now.rss" or die $!;231 open I, '<', "4/today/chnls-now-$time.rss" or die $!;
186 fillprograms;232 fillprograms;
187 close I;233 close I;
188234
226 my @fst = stat $outputfile;272 my @fst = stat $outputfile;
227 next if (defined $fst[9] && $fst[9] > $daysecs+86400); # recent enough.273 next if (defined $fst[9] && $fst[9] > $daysecs+86400); # recent enough.
228274
229 push @urls, "http://www.tvkaista.fi/feed/archives/$di[4]/$di[3]/$di[2]"275 push @urls, "http://alpha.tvkaista.fi/feed/archives/$di[4]/$di[3]/$di[2]"
230 . "/channels/$_/flv.rss" foreach (@channels);276 . "/channels/$_/flv.rss" foreach (@channels);
231277
232 getdatetime;278 getdatetime;
233 feedwget "4/today/a-$di[3]-$di[2]-$time.rss",279 my $filedate = sprintf "%02d-%02d-$time", $di[3], $di[2];
280 feedwget "4/today/chnls-$filedate.rss",
234 "4/today/a-$di[3]-$di[2]-$time.log", @urls;281 "4/today/chnls-$filedate.log", @urls;
235 last WHILE unless -s "4/today/a-$di[3]-$di[2]-$time.rss";282 last WHILE unless -s "4/today/chnls-$filedate.rss";
236283
237 open I, '<', "4/today/a-$di[3]-$di[2]-$time.rss" or die $!;284 open I, '<', "4/today/chnls-$filedate.rss" or die $!;
238 fillprograms;285 fillprograms;
239 close I;286 close I;
240287
276 }323 }
277}324}
278325
279sub getsrt($$)
280{
281 #http://www.tvkaista.fi/netpvr/Download/774338.srt <- 2009-12 <-
282 #http://www.tvkaista.fi/recordings/download/774338.srt -> 2009-12 ->
283
284 my $tof = "$recdir/$_[0].srt";
285 my $log = "4/today/$_[0].log";
286
287 feedwget $tof,$log, "http://www.tvkaista.fi/recordings/download/$_[0].srt";
288
289 open I, '<', $log or return ( $_[0], 0 );
290
291 my ($namepfx, $haveit, $conlen) = ($_[0], 0, -1);
292 while (<I>) {
293 $namepfx = $1, $haveit = 1 if /outputfilename=(.*).srt\s*$/i;
294 $conlen = $1 if /^Pituus:\s+(\d+).*application.x-srt/;
295 }
296 close I;
297 if ($conlen > 0) {
298 $namepfx = 'tekstitys' if $_[1] ne 'wget';
299 rename $tof, "$recdir/$namepfx.srt"; }
300 else {
301 unlink $tof; }
302
303 return ($namepfx, $conlen);
304}
305
306my %speeds = qw ( 300k mp4 1M flv 2M h264 8M ts );326my %speeds = qw ( 300k mp4 1M flv 2M h264 8M ts );
307327
308sub play ($)328sub play ($)
311331
312 getpw;332 getpw;
313333
314 my ($namepfx, $srtflen) = getsrt($ARGV[2], $ARGV[1]);334 my $havesubtitles = 0;
335 my ($sock, $srtname, $rc) = openhttpstream 1,
336 'alpha.tvkaista.fi:80', "/recordings/download/$ARGV[2].srt";
315337
316 my $pagename = "4/today/play-$time.html";338 return 0 if $rc == 401; # Unauthorized.
317 my $logname = "4/today/play-$time.log";339
340 if ($rc == 200) {
341 # found subtitle content
342 open O, '>', "$recdir/$srtname" or die "XXX: $!\n";
343 binmode O; # (Input IO handle in raw mode; do not utf8 utf8 input...)
344 print O $_ while (<$sock>);
345 close O;
346 $havesubtitles = 1;
347 }
348 close $sock;
318349
319 my $format = $speeds{$ARGV[3]};350 my $format = $speeds{$ARGV[3]};
320351
321 feedwget $pagename, $logname, '--max-redirect', '0',352 my $url = openhttpstream 0,
322 "http://www.tvkaista.fi/recordings/download/$ARGV[2].$format";353 'alpha.tvkaista.fi:80', "/recordings/download/$ARGV[2].$format";
323
324 open I, '<', $logname or die "Can not open '$logname': $!\n";
325 my $url;
326 while (<I>) {
327 chomp ($url = $1) if /^Sijainti:\s+(http:\S+)/;
328 }
329 close I;
330 unless (defined $url) {
331 return 0 unless $_[0];
332 die "No content found!\n";
333 }
334354
335 chdir $recdir;355 chdir $recdir;
336356
337 my @list = ( $ARGV[1] );357 my @list = ( $ARGV[1] );
338 if ($ARGV[1] eq 'wget') {358 if ($ARGV[1] eq 'wget') {
339 push @list, '-O' , "$namepfx.$format";359 $url =~ /outputfilename=(.*)/;
360 push @list, '-O', $1;
340 }361 }
341 elsif ($ARGV[1] eq 'vlc') {362 elsif ($ARGV[1] eq 'vlc') {
342 push @list, '--sub-file', "$namepfx.srt" if $srtflen > 0;363 push @list, '--sub-file', $srtname if $havesubtitles;
343 }364 }
344 elsif ($ARGV[1] eq 'mplayer') {365 elsif ($ARGV[1] eq 'mplayer') {
345 push @list, '-utf8';366 push @list, '-cache', '1000';
346 push @list, '-sub', "$namepfx.srt" if $srtflen > 0;367 push @list, '-sub', $srtname, '-utf8' if $havesubtitles;
347 }368 }
348 elsif ($ARGV[1] eq 'xine') {369 elsif ($ARGV[1] eq 'xine') {
349 # how to give subtitle file as separate command line parameter ?370 # how to give subtitle file as separate command line parameter ?
354 system @list or warn "system(): $!\n";375 system @list or warn "system(): $!\n";
355 print "Executed @list\n";376 print "Executed @list\n";
356377
357 unlink "$namepfx.srt" if $srtflen > 0 && $ARGV[1] ne 'wget';378 unlink "$srtname" if $havesubtitles > 0 && $ARGV[1] ne 'wget';
358379
359 # add more checks & cleanups380 # add more checks & cleanups
360 exit 0;381 exit 0;
422 close I;443 close I;
423}444}
424print ("Q \n");445print ("Q \n");
446print STDERR ".\n";

tvkaista-0.985/tvkaista.desktop tvkaista-0.986/tvkaista.desktop
1[Desktop Entry]1[Desktop Entry]
2Version=1.0
2Encoding=UTF-83Encoding=UTF-8
3Version=0.985
4Name=tv kaista4Name=tv kaista
5Comment=gui-kilentti tvkaistalle5Comment=gui-kilentti tvkaistalle
6GenericName=tvkaista-kilentti6GenericName=tvkaista-kilentti

tvkaista-0.985/tvkaista.menu tvkaista-0.986/tvkaista.menu
2 needs="X11" \2 needs="X11" \
3 section="Applications/TV and Radio" \3 section="Applications/TV and Radio" \
4 title="tv kaista" \4 title="tv kaista" \
5 command="/p/home/too/.tvkaista/tvkaista.sh gui" \5 command="$dest/tvkaista.sh gui" \
6 icon="/p/home/too/.tvkaista/tvkaista.png" \6 icon="$dest/tvkaista_gtk" \
7 hints="Video"7 hints="Video"

tvkaista-0.985/tvkaista_gtkui.c tvkaista-0.986/tvkaista_gtkui.c
5WARN="$WARN -Wcast-align -Wpointer-arith " # -Wfloat-equal #-Werror5WARN="$WARN -Wcast-align -Wpointer-arith " # -Wfloat-equal #-Werror
6WARN="$WARN -W -Wwrite-strings -Wcast-qual -Wshadow" # -Wconversion6WARN="$WARN -W -Wwrite-strings -Wcast-qual -Wshadow" # -Wconversion
7FLAGS=`pkg-config --cflags --libs gtk+-2.0 | sed 's/-I/-isystem '/g`7FLAGS=`pkg-config --cflags --libs gtk+-2.0 | sed 's/-I/-isystem '/g`
8ver=`sed -n 's/Version=//p' tvkaista.desktop`8ver=`sed -n 's/VERSION=//p' Makefile`
9OPTS="$WARN $FLAGS -DVERSION=$ver -fstack-protector"9OPTS="$WARN $FLAGS -DVERSION=$ver -fstack-protector"
10case $1 in '') set x -ggdb10case $1 in '') set x -ggdb
11#case $1 in '') set x -O2 ### set x -ggdb11#case $1 in '') set x -O2 ### set x -ggdb
225 G.childexit_cb();225 G.childexit_cb();
226}226}
227227
228bool clear_childexit_cb(void)
229{
230 G.childexit_cb = null;
231 return false;
232}
233
234void execbgcommand(const char * command, char * const argv[])228void execbgcommand(const char * command, char * const argv[])
235{229{
236 switch(fork())230 switch(fork())
243 die("fork() failed:"); /* XXX */237 die("fork() failed:"); /* XXX */
244 default:238 default:
245 /*parent */239 /*parent */
246 G.childexit_cb = clear_childexit_cb; // default
247 return;240 return;
248 }241 }
249 (void)execvp(command, argv);242 (void)execvp(command, argv);
562 dest[n - 1] = '\0';555 dest[n - 1] = '\0';
563}556}
564557
565int fill_store(FILE * fh)558void fill_store(FILE * fh)
566{559{
567 char line[1024];560 char line[1024];
568561
618 case 'Q':611 case 'Q':
619 custom_list_full(W.listmodel);612 custom_list_full(W.listmodel);
620 do_filtering();613 do_filtering();
621 return true;614 return;
622 default:615 default:
623 fprintf(stderr, "Unknown line: '%s'\n", line);616 fprintf(stderr, "Unknown line: '%s'\n", line);
624 continue;617 continue;
638 }631 }
639 custom_list_full(W.listmodel);632 custom_list_full(W.listmodel);
640 do_filtering();633 do_filtering();
641 return false;634 return;
642}635}
643636
644void day_clicked(int promille)637void day_clicked(int promille)
10761069
1077bool relist_view(void)1070bool relist_view(void)
1078{1071{
1072 G.childexit_cb = null;
1079 gtk_tree_view_set_model(GTK_TREE_VIEW(W.listview), null);1073 gtk_tree_view_set_model(GTK_TREE_VIEW(W.listview), null);
1080 FILE * fh = runhelper("list");1074 FILE * fh = runhelper("list");
1081 clean_data();1075 clean_data();
1082 if (fill_store(fh)) {1076 fill_store(fh);
1083 g_idle_add(clear_childexit_cb, null);
1084 }
1085 pclose(fh);1077 pclose(fh);
1086 gtk_tree_view_set_model(GTK_TREE_VIEW(W.listview),1078 gtk_tree_view_set_model(GTK_TREE_VIEW(W.listview),
1087 GTK_TREE_MODEL(W.listmodel));1079 GTK_TREE_MODEL(W.listmodel));