-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathget-programme.pl
More file actions
23 lines (17 loc) · 784 Bytes
/
get-programme.pl
File metadata and controls
23 lines (17 loc) · 784 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/usr/bin/perl
# Simple script to get current programme from sqlite db
my $now = time();
my $db = "tvg"; # sqlite file
use DBI;
my $dbh = DBI->connect("dbi:SQLite:dbname=$db","","", {RaiseError=>1, sqlite_journal_mode => 'WAL', ReadOnly => 1}) or die("db disconnected");
my $curpr = $dbh->prepare("select channel, title, category, description , (100 * ($now - start) / (stop - start))
from programmes where channel = ? and start <= $now and stop >= $now
limit 1");
my $ch = $ARGV[0]; # channel name
#print $ch;
$curpr->execute(${ch});
my ($title, $cat, $desc, $percentage);
$curpr->bind_columns(\$ch, \$title, \$cat, \$desc, \$percentage);
while ($curpr->fetch) {
print "${title}\t${percentage}\t${cat}\t${desc}\n";
}