For those of you that use the TiVo SDK to allow your TiVo view your photos and music on your perl based server, you may find the following beacon script useful. It simply tells the TiVo where your home media server is located.
It is based on this script but I discovered that the TiVo box doesn't care if it can't send a reply to the beacon so I was able to take out unnecessary bits. I'm in the process of creating a new TiVo.pm that is based on the specifications that won't be restricted as TiVo's tivo.pm module is. I am hoping to eventually get the new TiVo code into CPAN but it will be a month or so before the backend tivo.pm is ready even for consideration.
/usr/local/bin/tivo_beacon#!/usr/bin/perl use strict; use warnings; use IO::Socket; use Sys::Hostname; use vars qw( $RUNNING ); ###################################### sub TermHandle; ###################################### ###################################### sub TermHandle { $SIG{INT} = sub { exit 0; }; $RUNNING = 0; } ###################################### ###################################### my $broadcast_address = "192.168.1.255"; my $tivo_port = 2190; my $BeaconInterval = 2; my $socket; my $dest; my $hostname; my $data; # Signal Handler TermHandle(); $hostname = Sys::Hostname::hostname; $data = "tivoconnect=1\n" . "swversion=beta1\n" . "method=broadcast\n" . "identity=$hostname\n" . "machine=$hostname\n" . "platform=pc/linux\n" . "services=TiVoMediaServer:80/http\n"; $RUNNING = 1; # Let's create an UDP socket and set it up for broadcast $socket = IO::Socket::INET->new(Proto => 'udp') or die $@; $socket->sockopt(SO_BROADCAST() => 1) or die "sockopt: $!"; $dest = sockaddr_in($tivo_port, inet_aton($broadcast_address)); while ($RUNNING) { my $sendret = send ($socket, $data, 0, $dest); print "Broadcast Error: $!\n" unless ($sendret); sleep $BeaconInterval; } close $socket; print "Beacon finished.\n";
I put the perl script into /usr/local/tivo_beacon and run it as the nobody user. Because I'm lazy, I've modified the /etc/init.d/skeleton rc script on my SuSE box to start it up and shut it down. I haven't removed the unnecessary stuff in the rc script so please be kind.
/etc/init.d/tivo_beacon#! /bin/sh TIVOBEACON_BIN=/usr/local/bin/tivo_beacon test -x "$TIVOBEACON_BIN" || { echo "$TIVOBEACON_BIN not installed"; if [ "$1" = "stop" ]; then exit 0; else exit 5; fi; } . /etc/rc.status # Reset status of this service rc_reset case "$1" in start) echo -n "Starting TiVo Beacon " startproc -u nobody $TIVOBEACON_BIN rc_status -v ;; stop) echo -n "Shutting down TiVo Beacon " killproc -TERM $TIVOBEACON_BIN # Remember status and be verbose rc_status -v ;; try-restart|condrestart) if test "$1" = "condrestart"; then echo "${attn} Use try-restart ${done}" \ "(LSB)${attn} rather than condrestart" \ " ${warn}(RH)${norm}" fi $0 status if test $? = 0; then $0 restart else rc_reset # Not running is not a failure. fi # Remember status and be quiet rc_status ;; restart) $0 stop $0 start # Remember status and be quiet rc_status ;; force-reload) echo -n "Reload service TIVOBEACON " rc_status -v ## Otherwise: $0 restart rc_status ;; reload) ;; status) ;; *) echo "Usage: $0 {start|stop|status|try-restart|restart}" exit 1 ;; esac rc_exit
I hope someone is able to find a use for this :-)
Jason L. Froebe
Update: removed the subroutineNo one has seen what you have seen, and until that happens, we're all going to think that you're nuts. - Jack O'Neil, Stargate SG-1
In reply to Beacon for your TiVo Home Media Server by jfroebe
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |