Page 1 of 3

Script to get active tv channel

Posted: Thu Apr 12, 2012 8:18 am
by smilykoch
Hey guys..

i currently own a ue40d8005 and im looking for some kind of solution to get info about which active tv channel is being shown on the tv atm.

is this possible? i was thinking some kind of.. perl? script "asking" the tv for the info.. i only need an ID, name or something unique to that single channel..

something like this perhaps: viewtopic.php?f=12&t=1792 but the other way around?

Cheers! Smilykoch

Re: Script to get active tv channel

Posted: Wed Apr 18, 2012 12:47 pm
by smilykoch
No-one with knowledge of ANY way to get the active tv channel brought to a computer in some way?
really?

Re: Script to get active tv channel

Posted: Sat Apr 21, 2012 9:49 am
by erdem_ua
I remember that I already asked this question at somewhere...
Do you look at "Debug Menu?" You can find what channel is actually available from here.
But don't know what is http way to do that.

Re: Script to get active tv channel

Posted: Mon May 07, 2012 12:37 pm
by smilykoch
Okay.. so i the "debug menu" the currently active channel is showing.. but no current way of bringing this to the PC? either through HTTP, HDMI-CEC or ex-link?

Re: Script to get active tv channel

Posted: Mon May 07, 2012 12:49 pm
by juusso
Where exact have you got this in top debug menu?

Re: Script to get active tv channel

Posted: Tue May 08, 2012 2:05 am
by erdem_ua
juuso, I don't know where it is but I remember see such an info while playing...

This info at Debug menu, which is only available by ExLink port.
For bridging this info to TV, you can use USB to RS232 based converter...Put USB converter to TV USB port.
Than write a program to detect actual channel on TV (using serial connection to ExLink ) and put it into network (HTTP)..

Re: Script to get active tv channel

Posted: Tue May 08, 2012 3:19 am
by nobody
What? Debug menu? LOL!

To get the active channel you can simply use UPNP!

GetCurrentMainTVChannel

Code: Select all

<?xml version="1.0" encoding="UTF-8"?><Channel><ChType>DTV</ChType><MajorCh>8</MajorCh><MinorCh>65534</MinorCh><PTC>48</PTC><ProgNum>614</ProgNum></Channel>
You can also use:

GetWatchingInformation

Code: Select all

Only Hits on MTV (03:30AM~05:45AM)
To get the current airing program name (fetched from epg).

Or

GetCurrentProgramInformationURL

Which will return an URL from which you download an XML with cached EPG.

Re: Script to get active tv channel

Posted: Sat May 19, 2012 11:06 am
by smilykoch
Plz do explain a little more or give some links to some more info on this :)

i could really use this :)

Re: Script to get active tv channel

Posted: Sat May 19, 2012 4:17 pm
by Eduardo
TVAgent you can get from http://<ip tv>:52235/MainTVServer2/MainTVAgent2.xml

An example:

Code: Select all

#!/usr/bin/perl
# upnp_tv_agent.pl

use warnings;
use strict;

use Net::UPnP::ControlPoint;

my $upnp = Net::UPnP::ControlPoint->new();
my @devs = $upnp->search();
my $tv;

foreach my $dev ( @devs ) 
{
   foreach my $serv ( $dev->getservicelist() )
   {
      if ( $serv->getservicetype() =~ /TVAgent/ )
      {
         $tv = $serv;
         last;
      }
   }
}

die "TVAgent not found\n" unless $tv;

my $res = action( 'GetCurrentMainTVChannel' );
print "[*] $res->{CurrentChannel}\n";

$res = action( 'GetWatchingInformation' );
print "[*] $res->{TVMode}\n";
print "[*] $res->{WatchingInformation}\n";


exit 0;

# -----------------------------------------------------------------------------

sub action
{
   my ( $act, $args ) = @_;

   my $r = $tv->postaction( $act, $args );

   unless ( 200 == $r->getstatuscode() )
   {
      die "Error $act: ". $r->getstatuscode()."\n";
   }

   my $res = $r->getargumentlist();
   unless ( 'OK' eq $res->{Result} )
   {
      die "Error $act response $res->{Result}\n";
   }

   return $res;
}

# -----------------------------------------------------------------------------

__END__

Code: Select all

$ ./upnp_tv_agent.pl 
[*] <?xml version="1.0" encoding="UTF-8"?><Channel><ChType>DTV</ChType><MajorCh>1</MajorCh><MinorCh>65534</MinorCh><PTC>58</PTC><ProgNum>530</ProgNum></Channel>
[*] Tuner
[*] Tenis - Atp 1000 Roma on La 1 (03:59PM~06:16PM)

Re: Script to get active tv channel

Posted: Sat May 19, 2012 5:40 pm
by smilykoch
Cool.. Really! WOW thx!

i can access the XML file through my browser on: http://<ip tv>:52235/MainTVServer2/MainTVAgent2.xml

But it seems kinda empty? it looks like this: http://pastebin.com/jhSzuVSp

I really would like having a script to get it.. but i am not that good at Perl. could you explain your example script?
and would it be possible for me to create it in PHP as i currently have all my other scripts in PHP and i am fairly good at it :)

Cheers
Mathias Koch