Attachment 'mythtv.firewire.channels.pl'
Download
Toggle line numbers
1 #!/usr/bin/perl -w
2 # mythtv.firewire.channels.pl v1.0
3 # By: John Baab
4 # Email: john.baab@gmail.com
5 # Purpose:
6 #
7 # License:
8 #
9 # This Package is free software; you can redistribute it and/or
10 # modify it under the terms of the GNU General Public
11 # License as published by the Free Software Foundation; either
12 # version 2 of the License, or (at your option) any later version.
13 #
14 # This package is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 # General Public License for more details.
18 #
19 # You should have received a copy of the GNU General Public
20 # License along with this package; if not, write to the Free Software
21 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 #
23 # On Debian & Ubuntu systems, a complete copy of the GPL can be found under
24 # /usr/share/common-licenses/GPL-2, or (at your option) any later version
25
26 use DBI;
27 use DBD::mysql;
28 use MythTV;
29 use strict;
30
31 # Set default values
32 my $debug;
33 ##################################
34 # #
35 # Main code starts here !! #
36 # #
37 ##################################
38
39 my $usage = "\nHow to use mythtv.firewire.channels.pl : \n"
40 ."\nExample: mythtv.firewire.channels.pl\n";
41
42 # get this script's ARGS
43 #
44
45 my $num = $#ARGV + 1;
46
47 # if user hasn't passed enough arguments, die and print the usage info
48 #if ($num <= 2) {
49 # die "$usage";
50 #}
51
52 #
53 # Get all the arguments
54 #
55
56 foreach (@ARGV){
57
58 if ($_ =~ m/debug/) {
59 $debug = 1;
60 }
61 }
62
63 #
64 #
65 my $myth = new MythTV();
66 # connect to database
67 my $connect = $myth->{'dbh'};
68
69 my $query = "SELECT count(distinct(ch.channum))
70 FROM channel ch
71 join cardinput ci on ci.sourceid = ch.sourceid
72 join capturecard cc on cc.cardid = ci.cardid
73 where cc.cardtype = 'Firewire'";
74 #print $query;
75 my $query_handle = $connect->prepare($query);
76
77 # EXECUTE THE QUERY
78 $query_handle->execute() || die "Cannot connect to database \n";
79
80 my $totalChans = $query_handle->fetchrow_array;
81 print "$totalChans ";
82
83 # PREPARE THE QUERY
84 $query = "SELECT distinct(ch.channum), ch.callsign
85 FROM channel ch
86 join cardinput ci on ci.sourceid = ch.sourceid
87 join capturecard cc on cc.cardid = ci.cardid
88 where cc.cardtype = 'Firewire'
89 order by ch.channum+0";
90 #print $query;
91 $query_handle = $connect->prepare($query);
92
93 # EXECUTE THE QUERY
94 $query_handle->execute() || die "Cannot connect to database \n";
95
96 while ( my ($channum, $callsign) = $query_handle->fetchrow_array ) {
97 print "$channum $callsign ";
98 }
Attached Files
To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.You are not allowed to attach a file to this page.