Script to get active tv channel

Ideas and dreaming will go this forum

smilykoch
Posts: 13
Joined: Mon Mar 26, 2012 2:22 pm

Script to get active tv channel

Post 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
smilykoch
Posts: 13
Joined: Mon Mar 26, 2012 2:22 pm

Re: Script to get active tv channel

Post by smilykoch »

No-one with knowledge of ANY way to get the active tv channel brought to a computer in some way?
really?
User avatar
erdem_ua
SamyGO Admin
Posts: 3125
Joined: Thu Oct 01, 2009 6:02 am
Location: Istanbul, Turkey
Contact:

Re: Script to get active tv channel

Post 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.
smilykoch
Posts: 13
Joined: Mon Mar 26, 2012 2:22 pm

Re: Script to get active tv channel

Post 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?
User avatar
juusso
SamyGO Moderator
Posts: 10129
Joined: Sun Mar 07, 2010 6:20 pm

Re: Script to get active tv channel

Post by juusso »

Where exact have you got this in top debug menu?
LE40B653T5W,UE40D6750,UE65Q8C
Have questions? Read SamyGO Wiki, Search on forum first!
FFB (v0.8), FFB for CI+ . Get root on: C series, D series, E series, F series, H series. rooting K series, exeDSP/exeTV patches[C/D/E/F/H]

DO NOT EVER INSTALL FIRMWARE UPGRADE
User avatar
erdem_ua
SamyGO Admin
Posts: 3125
Joined: Thu Oct 01, 2009 6:02 am
Location: Istanbul, Turkey
Contact:

Re: Script to get active tv channel

Post 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)..
User avatar
nobody
Posts: 182
Joined: Sat Nov 12, 2011 1:45 am

Re: Script to get active tv channel

Post 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.
smilykoch
Posts: 13
Joined: Mon Mar 26, 2012 2:22 pm

Re: Script to get active tv channel

Post by smilykoch »

Plz do explain a little more or give some links to some more info on this :)

i could really use this :)
Eduardo
Posts: 9
Joined: Sat May 19, 2012 4:03 pm

Re: Script to get active tv channel

Post 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)
Eduardo
smilykoch
Posts: 13
Joined: Mon Mar 26, 2012 2:22 pm

Re: Script to get active tv channel

Post 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

Post Reply

Return to “[D] Brainstorm”