3 # Copyright and License:
5 # Copyright (C) 2007-2009
6 # gregor herrmann <gregor+debian@comodo.priv.at>,
7 # Philipp Spitzer <philipp@spitzer.priv.at>
9 # This program is free software; you can redistribute it and/or modify it
10 # under the terms of the GNU General Public License version 2 as published
11 # by the Free Software Foundation.
12 # This program is distributed in the hope that it will be useful, but
13 # WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 # General Public License for more details.
16 # You should have received a copy of the GNU General Public License along
17 # with this program; if not, write to the Free Software Foundation, Inc.,
18 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA, or point
19 # your browser to http://www.gnu.org/licenses/gpl.html
33 if (-r "$ENV{HOME}/.teleschorschrc") {
34 $configfile = "$ENV{HOME}/.teleschorschrc";
35 } elsif (-r "/etc/teleschorschrc") {
36 $configfile = "/etc/teleschorschrc";
38 error "Neiter /etc/teleschorschrc nor $ENV{HOME}/.teleschorschrc found";
42 if (DateTime->now->hour < 12) {
43 $defaultdate = DateTime->now->subtract(days => 1)->dmy(' ');
45 $defaultdate = DateTime->now->dmy(' ');
48 my %playeroptions = ("vlc" => "--start-time", "gmplayer" => "-cache 512 -ss");
52 tie %cfg, 'Config::IniFiles', ( -file => $configfile, -allowcontinue => 1)
53 or error "Can't read $configfile: $!";
54 my @channels = sort keys %cfg;
58 foreach my $c (@channels) {
59 $result .= "$c '$cfg{$c}{'FULLNAME'}' off ";
65 my $channellist = &create_list;
66 my @args=("Xdialog --stdout --title 'TeleSchorsch' --no-tags --radiolist 'Choose your preferred stream:' 0 0 0 $channellist --calendar 'Date' 0 0 $defaultdate --timebox 'Offset\n(Start at beginning of stream: 0:0:0, start at position 3 minutes: 0:3:0, ...)' 0 0 0 0 0");
67 my $selection = qx/@args/ or error "@args: $? // $!\n\n";
68 my ($stream, $date, $offset) = split (/\n/, $selection);
71 my ($hours, $minutes, $seconds) = split(/:/, $offset);
72 my $offsetseconds = $hours * 3600 + $minutes * 60 + $seconds;
74 my ($day, $month, $year) = split(/\//, $date);
75 my $dt = DateTime->new(year => $year, month => $month, day => $day);
76 my $y = $dt->strftime("%y");
77 my $Y = $dt->strftime("%Y");
78 my $m = $dt->strftime("%m");
79 my $d = $dt->strftime("%d");
80 my $dt_DE = DateTime->from_object(object => $dt, locale => qx(locale -a | grep ^de_ | head -n 1));
81 my $dow_DE = $dt_DE->strftime("%A");
83 # get missing parameters
84 my $player = $cfg{$stream}{'PLAYER'};
86 my $url = $cfg{$stream}{'STATICURL'};
88 $url =~ s/(\${\w+?})/$1/eeg;
91 @args=("$player \"$url\" " . ${playeroptions}{$player} . " $offsetseconds");
92 print "Calling @args ...\n";
94 or error "@args: $? // $!";