Script to get active tv channel

Ideas and dreaming will go this forum

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

Re: Script to get active tv channel

Post by smilykoch » Mon May 21, 2012 9:04 am

Okay.. i tried the perl script on my XAMPP server..

i installed the NET:UPnP module and ran the script with the right perl path in top..

but it returns this error:
Can't call method "postaction" on an undefined value at C:/xampp/htdocs/XBMC/tv.pl line 43. ,

My script looks like this: (just like yours)

Code: Select all

#!"C:\xampp\perl\bin\perl.exe"
# tv.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__

What is wrong? :(

User avatar
juusso
SamyGO Moderator
Posts: 9794
Joined: Sun Mar 07, 2010 6:20 pm

Re: Script to get active tv channel

Post by juusso » Mon May 21, 2012 9:28 am

On mine D6750 i got another error:

Code: Select all

# ./upnp_tv_agent.pl
TVAgent not found
Dirrect access is impossible too:

Code: Select all

XML Parsing Error: no element found
Location: http://192.168.1.202:52235/MainTVServer2/MainTVAgent2.xml
Line Number 1, Column 1:
I think this works on D7 and D8 series only...
LE40B653T5W,UE40D6750
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, exeDSP/exeTV patches[C/D/E/F/H]

DO NOT EVER INSTALL FIRMWARE UPGRADE

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

Re: Script to get active tv channel

Post by smilykoch » Mon May 21, 2012 9:36 am

That should be no problem as im trying on my ue40d8005..

but i get the above mentioned error :s

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

Re: Script to get active tv channel

Post by smilykoch » Mon May 21, 2012 9:43 am

I made it to the next step!

if i run it through cmd i get this:
c:\xampp\htdocs\XBMC>perl tv.pl
[*] <?xml version="1.0" encoding="UTF-8"?><Channel><ChType>CANALDIGITALSAT</ChType><MajorCh>105</MajorCh><MinorCh>65534</MinorCh><PTC>571</PTC<ProgNum>3206</ProgNum></Channel>
Error GetWatchingInformation response NOTOK
And if i run the .pl script though my browser/webserver (XAMPP) i also get the error:
Error GetWatchingInformation response NOTOK ,

But why?

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

Re: Script to get active tv channel

Post by smilykoch » Mon May 21, 2012 10:11 am

Wooohoo! now it works..

but it seems "kinda" slow? the script takes about 2 seconds from execution to return of values? is this UPnP's fault? or is there a way of decreasing this time?

Thanks

User avatar
arris69
SamyGO Moderator
Posts: 1700
Joined: Fri Oct 02, 2009 8:52 am
Location: Austria/Vienna (no Kangaroos here)
Contact:

Re: Script to get active tv channel

Post by arris69 » Mon May 21, 2012 9:01 pm

Eduardo wrote:TVAgent you can get from http://<ip tv>:52235/MainTVServer2/MainTVAgent2.xml
ok, but this is the SCPDURL, from what xml its refered?
looks like not all d-series support this feature?
can you pls make an

Code: Select all

ls -alR /mtd_rwarea/dlna*
and pls. post output?

thnx
arris

Eduardo
Posts: 9
Joined: Sat May 19, 2012 4:03 pm

Re: Script to get active tv channel

Post by Eduardo » Mon May 21, 2012 10:59 pm

smilykoch wrote:... it looks like this: http://pastebin.com/jhSzuVSp ...
It's the same.
smilykoch wrote:... but it seems "kinda" slow? the script takes about 2 seconds from execution to return of values? is this UPnP's fault? or is there a way of decreasing this time?...
UPnP spend a lot of time searching
arris69 wrote:...this is the SCPDURL, from what xml its refered?...

Code: Select all

GET /MainTVServer2/MainTVServer2Desc.xml HTTP/1.0
Host: 192.168.10.224:52235
Content-Length: 0

HTTP/1.1 200 OK
CONTENT-LENGTH: 1217
CONTENT-TYPE: text/xml; charset="utf-8"
DATE: Thu, 01 Jan 1970 00:24:29 GMT
Server: DMRND/0.5

<?xml version="1.0"?>
<root xmlns="urn:schemas-upnp-org:device-1-0" xmlns:sec="http://www.sec.co.kr/dlna">
  <specVersion>
    <major>1</major>
    <minor>0</minor>
  </specVersion>
  <device>
    <deviceType>urn:samsung.com:device:MainTVServer2:1</deviceType>
    <friendlyName>[TV]UE46D7000</friendlyName>
    <manufacturer>Samsung Electronics</manufacturer>
    <manufacturerURL>http://www.samsung.com/sec</manufacturerURL>
    <modelDescription>Samsung TV MainTVServer2</modelDescription>
    <modelName>UE46D7000</modelName>
    <modelNumber>1.0</modelNumber>
    <modelURL>http://www.samsung.com/sec</modelURL>
    <serialNumber>20100621</serialNumber>
    <UDN>uuid:608fefb9-ba1c-3f12-a968-ddbec4cac48a</UDN>
    <UPC>123456789012</UPC>
    <sec:deviceID>P7CN4UQJMPT62</sec:deviceID>
    <serviceList>
      <service>
        <serviceType>urn:samsung.com:service:MainTVAgent2:1</serviceType>
        <serviceId>urn:samsung.com:serviceId:MainTVAgent2</serviceId>
..<controlURL>/MainTVServer2/control/MainTVAgent2</controlURL>
        <eventSubURL>/MainTVServer2/event/MainTVAgent2</eventSubURL>
..<SCPDURL>MainTVAgent2.xml</SCPDURL>
      </service>
</serviceList>
</device>
</root>
arris69 wrote:... looks like not all d-series support this feature?
can you pls make an

Code: Select all

ls -alR /mtd_rwarea/dlna*
and pls. post output?...
I'm so sorry, I haven't got root access, I have got an D7000 with firmware 1021 :-(
Eduardo

setti
SamyGO Project Donor
Posts: 70
Joined: Sat Jan 07, 2012 11:32 am

Re: Script to get active tv channel

Post by setti » Tue May 22, 2012 7:43 am

On D6500 with Firmware 1014:

Code: Select all

ls -alR /mtd_rwarea/dlna*                                                                                                                                                                                                                                                      
/mtd_rwarea/dlna_web_root:                                                                                                                                                                                                                                                     
drwxr-xr-x    1 root     0               0 Jan  1  1980 .                                                                                                                                                                                                                      
drwxr-xr-x    1 root     0               0 Jan  1  1970 ..                                                                                                                                                                                                                     
-rwxr-xr-x    1 root     0             776 Jan  1  1980 DmrAclConfig.xml                                                                                                                                                                                                       
-rwxr-xr-x    1 root     0             931 Jan  1  1980 RcrAclConfig.xml                                                                                                                                                                                                       
-rwxr-xr-x    1 root     0             508 Jan  1  1980 RcrMobileList.xml                                                                                                                                                                                                      
drwxr-xr-x    1 root     0               0 Jan  1  1980 dmr                                                                                                                                                                                                                    
drwxr-xr-x    1 root     0               0 Jan  1  1980 rcr                                                                                                                                                                                                                    
                                                                                                                                                                                                                                                                               
/mtd_rwarea/dlna_web_root/dmr:                                                                                                                                                                                                                                                 
drwxr-xr-x    1 root     0               0 Jan  1  1980 .                                                                                                                                                                                                                      
drwxr-xr-x    1 root     0               0 Jan  1  1980 ..                                                                                                                                                                                                                     
-rwxr-xr-x    1 root     0           18139 Jan  1  1980 AVTransport1.xml                                                                                                                                                                                                       
-rwxr-xr-x    1 root     0            5294 Jan  1  1980 ConnectionManager1.xml                                                                                                                                                                                                 
-rwxr-xr-x    1 root     0            9873 Jan  1  1980 RenderingControl1.xml                                                                                                                                                                                                  
-rwxr-xr-x    1 root     0            3099 Jan  1  1980 SamsungMRDesc.xml                                                                                                                                                                                                      
lrwxr-xr-x    1 root     0             108 Jan  1  1980 icon_LRG.jpg -> /mtd_appdata/Images_960x540/DMR/icon_LRG.jpg                                                                                                                                                           
lrwxr-xr-x    1 root     0             108 Jan  1  1980 icon_LRG.png -> /mtd_appdata/Images_960x540/DMR/icon_LRG.png                                                                                                                                                           
lrwxr-xr-x    1 root     0             108 Jan  1  1980 icon_SML.jpg -> /mtd_appdata/Images_960x540/DMR/icon_SML.jpg
lrwxr-xr-x    1 root     0             108 Jan  1  1980 icon_SML.png -> /mtd_appdata/Images_960x540/DMR/icon_SML.png

/mtd_rwarea/dlna_web_root/rcr:
drwxr-xr-x    1 root     0               0 Jan  1  1980 .
drwxr-xr-x    1 root     0               0 Jan  1  1980 ..
-rwxr-xr-x    1 root     0            1244 Jan  1  1980 RemoteControlReceiver.xml
-rwxr-xr-x    1 root     0            2787 Jan  1  1980 TestRCRService.xml

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

Re: Script to get active tv channel

Post by smilykoch » Tue May 22, 2012 4:41 pm

I dont have root access on my d8005 either.. sorry :s

User avatar
nobody
Posts: 182
Joined: Sat Nov 12, 2011 1:45 am

Re: Script to get active tv channel

Post by nobody » Wed Jun 06, 2012 7:19 pm

Developer Tools for UPnP? Technology
http://opentools.homeip.net/dev-tools-for-upnp

With devicespy you can test around.
And there are also sources.

Post Reply

Return to “[D] Brainstorm”