Showing posts with label Random. Show all posts
Showing posts with label Random. Show all posts

Saturday, September 11, 2010

Mythbuntu and Tivo Premier

I was using Windows 7 for my secondary media server and was very frustrated with its performance when it came to Tivo desktop,  which is the WORST part of Tivo.  Tivo should be able to stream video to another server,  and there are many opensource applications to do this but of course Tivo has other things to focus on like a terrible new interface and a buggy new OS, but I digress.   I love my Tivo but I don't want to have to buy two of them to watch shows in a different room.  So I left Windows 7 and its lackluster performance for Mythbuntu,  now I just needed to get my Tivo programs to Mythbuntu.  Thanks to the work from the Tivodecode Project and Ed Salisbury's Perl Script I was able to replicate the features of TivoToGo in Linux with a much better playback and keep everything in Boxee.  Here is Ed’s Script:


#!/usr/bin/perl
# TiVo Dump
# Copy TiVo programs from a Series3 TiVo
# by Ed Salisbury (ed@edsalisbury.net)
# http://www.edsalisbury.net
# (c)2009 Ed Salisbury, Some Rights Reserved
#
# External Utilities Required:
# * curl
# * tivodecode
#
# External Perl Modules Required:
# * Net::TiVo
# * XML::Simple
# * Text::Unidecode;
#
# Usage:
# tivo_dump
#
# License:
# Except where otherwise noted, this work is licensed under Creative Commons
#   Attribution ShareAlike 3.0.
#
# You are free:
#   * to Share - to copy, distribute and transmit the work
#   * to Remix - to adapt the work
#
# Under the following conditions:
#   * Attribution. You must attribute the work in the manner specified by the
#     author or licensor (but not in any way that suggests that they endorse
#     you or your use of the work).
#   * Share Alike. If you alter, transform, or build upon this work, you may
#     distribute the resulting work only under the same, similar or a
#     compatible license.
#   * For any reuse or distribution, you must make clear to others the license
#     terms of this work. The best way to do this is with a link to the
#     license's web page (http://creativecommons.org/licenses/by-sa/3.0/)
#   * Any of the above conditions can be waived if you get permission from the
#     copyright holder.
#   * Nothing in this license impairs or restricts the author's moral rights.

use warnings;
use strict;
use Net::TiVo;
use XML::Simple;
use utf8;
use Text::Unidecode;

sub fix_chars($);

# User-Configurable Variables
my $HOST = "";      # Hostname/IP of the TiVo
my $MAK = "";       # The Media Access Key of the TiVo
my $VIDEO_DIR = ""; # Where the programs get saved
my $COPY_SUGGESTIONS = 0; # If you want to copy "Suggested" programs, set this to 1

my $USER = "tivo";
my $TMPFILE = "/tmp/$$.xml";
my $PROGRAMS_FILE = "/home/username/.tivo_programs";
$|++;

# External Utilities
my $CURL = "/usr/bin/curl";
my $TIVODECODE = "/usr/local/bin/tivodecode";

my @PREV;

# Connect to the TiVo
print "Connecting to TiVo at $HOST... ";
my $tivo = Net::TiVo->new(host => $HOST, mac => $MAK);
my @folders = $tivo->folders();
if (@folders)
{
    print "OK\n";
}
else
{
    print "FAIL\n";
    exit();
}

# Load the file that has the previously saved programs
open(IN, $PROGRAMS_FILE);
while ()
{
    chop();
    push(@PREV, $_);
}
close (IN);

# Go through each folder on the TiVo
foreach my $folder (@folders)
{
    foreach my $item ($folder->{'xmlref'}{'Item'})
    {
        foreach my $video (@$item)
        {
            # Only process videos, not folders
            if ($video->{'Links'}{'Content'}{'ContentType'} eq "video/x-tivo-raw-tts")
            {
                # Choose video type based on the icon
                if ($video->{'Links'}{'CustomIcon'} && $video->{'Links'}{'CustomIcon'}{'Url'} eq "urn:tivo:image:suggestion-recording" && !$COPY_SUGGESTIONS)
                {
                    next;
                }
                if ($video->{'Links'}{'CustomIcon'} &&
                   ($video->{'Links'}{'CustomIcon'}{'Url'} eq "urn:tivo:image:in-progress-transfer" ||
                    $video->{'Links'}{'CustomIcon'}{'Url'} eq "urn:tivo:image:in-progress-recording"))
                {
                   next;
                }

                # Get program and episode titles
                my $program_title = $video->{'Details'}{'Title'};

                if ($video->{'Details'}{'EpisodeTitle'})
                {
                    $program_title .= " - " . $video->{'Details'}{'EpisodeTitle'};
                }

                # Get Program ID and Video URL
                my $video_url = $video->{'Links'}{'Content'}{'Url'};
                my $program_id = $video->{'Details'}{'ProgramId'};

                if (!$program_id)
                {
                    next;
                }

                # If previously copied, skip
                if (grep /^$program_id$/, @PREV)
                {
                    print "Skipping $program_title.\n";
                    next;
                }

                # get details XML file
                print "Getting details for $program_title... ";
                my $details_xml = $video->{'Links'}{'TiVoVideoDetails'}{'Url'};

                system("$CURL --digest -s -k -u $USER:$MAK -c /tmp/cookies.txt -o $TMPFILE \"$details_xml\"");
                if (-f $TMPFILE)
                {
                    print "OK\nProcessing details file... ";
                    my $xml = XML::Simple->new();
                    my $doc = $xml->XMLin($TMPFILE);
                    my %meta;
                    my $filepath;
                    my $filename;

                    # Get rating and convert to proper form
                    $meta{'tvRating'} = $doc->{'showing'}{'tvRating'}{'content'};
                    if ($meta{'tvRating'})
                    {
                        if ($meta{'tvRating'} eq "Y_7") { $meta{'tvRating'} = 'x1'; }
                        elsif ($meta{'tvRating'} eq "PG") { $meta{'tvRating'} = 'x4'; }
                        elsif ($meta{'tvRating'} eqfilepath = "$VIDEO_DIR/$series_title";
                        $filename = "$filepath/$series_title - $episode_number - $episode_title";
                    }
                    elsif ($series_title && $episode_title)
                    {
                        $filepath = "$VIDEO_DIR/$series_title";
                        $filename = "$filepath/$series_title - $episode_title";
                    }
                    elsif ($title)
                    {
                        $filepath = "$VIDEO_DIR/$title";
                        $filename = "$filepath/$title";
                    }
                    else
                    {
                        $filepath = "$VIDEO_DIR";
                        $filename = "$filepath/Unknown";
                    }
                    print "OK\n";

                    unless (-d $filepath)
                    {
                        print "Path $filepath doesn't exist, creating... ";
                        mkdir($filepath);
                        if (-d $filepath)
                        {
                            print "OK\n";
                        }
                        else
                        {
                            print "FAIL\n";
                            exit;
                        }
                    }

                    # Get the video with curl
                    print "Getting video... ";
                    system("$CURL --digest -s -k -u $USER:$MAK -c /tmp/cookies.txt -o \"$filename.tivo\" \"$video_url\"");
                    if (-f "$filename.tivo")
                    {
                        my $filesize = (stat("$filename.tivo"))[7];

                        if ($filesize > 0)
                        {
                            print "OK\n";

                            # Convert to MPG
                            print "Converting video to MPG format... ";
                            system("$TIVODECODE -m $MAK -o \"$filename.mpg\" \"$filename.tivo\" > /dev/null 2>&1");
                            if (-f "$filename.mpg")
                            {
                                print "OK\n";
                                unlink "$filename.tivo";
                                open(OUT, ">>$PROGRAMS_FILE");
                                print OUT "$program_id\n";
                                close(OUT);
                            }
                            else
                            {
                                print "FAIL\n";
                                exit();
                            }

                            # Output metadata file
                            print "Outputting metadata... ";
                            open (OUT, ">$filename.mpg.txt");

                            foreach my $key (keys %meta)
                            {
                                if ($meta{$key})
                                {
                                    if ($meta{$key} =~ /^ARRAY/)
                                    {
                                        foreach my $item (@{$meta{$key}})
                                        {
                                            unless ($item =~ /^HASH/)
                                            {
                                                print OUT "$key : " . fix_chars($item) . "\n";
                                            }
                                        }
                                    }
                                    else
                                    {
                                        unless ($item =~ /^HASH/)
                                        {
                                            if ($key eq "originalAirDate")
                                            {
                                                print OUT "$key : " . $meta{$key} . "\n";
                                            }
                                            else
                                            {
                                                print OUT "$key : " . fix_chars($meta{$key}) . "\n";
                                            }
                                        }
                                    }
                                }
                            }
                            unlink($TMPFILE);
                            close(OUT);
                            print "OK\n";
                        }
                        else
                        {
                            print "FAIL\n";
                        }
                    }
                    else
                    {
                        print "FAIL\n";
                        exit();
                    }
                }
                else
                {
                    print "FAIL\n";
                    exit();
                }
            }
        }
    }
}

# Convert any offending characters
sub fix_chars($)
{
    my ($data) = @_;

    $data = unidecode($data);

    $data =~ s/\:/ -/g;
    $data =~ s/\//-/g;
    $data =~ s/\\/-/g;
    $data =~ s/\?/-/g;
    $data =~ s/\*/-/g;

    return $data;
}


then just add it to your cron
0 0,6,12,18 * * * /usr/local/bin/tivo_dump >/dev/null 2>&1
An then your now playing or now playing and suggestions will all be copied to your Linux box every x hours.

Friday, September 3, 2010

How to program your MCE remote

To program buttons on your MCE remote control.

  1. Place the MCE remote control head to head (2 to 3 inches apart) with the remote control from which it is learning.
  2. On the MCE remote control press and hold the DVD MENU and OK buttons at the same time until the remote control lights turn off (2 seconds). The remote is now in learning mode.
  3. On the MCE remote control press and release the TV, VOL +, VOL – button, depending on which command you want it to learn. The MCE remote control lights blink once to confirm the selection.
  4. On the remote control that is teaching the command, press and hold the button that you want the corresponding button on the MCE remote control. The MCE remote control lights blink twice to confirm the selection. If the remote does not learn the command, the lights blink quickly four times. To try again repeat steps 1 through 4.
  5. Repeat steps 1 through 4 for the other buttons that can learn commands.

Mythtv revisited with Mythbuntu

image 4 years ago I built a HTPC using Fedora and the experience was miserable,  I had given up on a linux HTPC and moved to Windows and was relatively happy until my S.M.A.R.T. drive reported impending doom.  I had to save my data and rebuilt my server,  which made me want to revisit RAID 1 (mirroring) and Linux.  From my experience, linux was going to be an uphill battle so I picked a path of least resistance with Mythbuntu (http://www.mythbuntu.org/)  and I was very pleasantly surprised.  I have a 3ware raid controller which is very easily supported across all linux platforms (3ware 8006) with a ASUS M2N-E motherboard with a nvidia graphics card (Gigabyte 8400GS 512MB GV) .  I recommend a fanless graphics card. 

 

I installed Mythbuntu and my mce remote and everything worked like a charm out of the box, AMAZING!  I had to turn off the display blanking and uninstall the xscreensaver but that was relatively easy.  Just add the following lines to your xorg.conf

/etc/X11/xorg.conf

Section "ServerFlags"
Option "blank time" "0"
Option "standby time" "0"
Option "suspend time" "0"
Option "off time" "0"
EndSection

I also installed Miro, Subsonic, and qbittorrent.  Miro for mobile video streaming, Subsonic for mobile audio,  and qbittorrent for rss torrent downloads.

I dont use Mythtv instead I use boxee which I launch from mythtv via the following addition to the mythtv menu

/usr/share/mythtv/themes/defaultmenu/mainmenu.xml

After:
<mythmenu name="MAIN">

Put:

<button>
<type>MENU_BOXEE</type>
<text>Boxee</text>
<action>EXEC /opt/boxee/run-boxee-desktop</action>
</button>

On day two I am very pleased with the progress of Mythbuntu as Boxee box.

Saturday, July 10, 2010

Everyone has problems : Twitter and Reddit

For those of you out there that just expect everything to work on the internet,   here is a great internal view to some of the hard challenges that face some of the largest sites on the internet. 

Twitter listed its challenges as of late:
“Twitter has experienced several incidences of poor site performance and a high number of errors due to one of our internal sub-networks being over-capacity.
We're working hard to address the core issues causing these problems --more on that below-- but in the interests of the open exchange of information, wanted to pull back the curtain and give you deeper insight into what happened and how we're working to address this week's poor site performance.
What happened?
In brief, we made three mistakes:
* We put two critical, fast-growing, high-bandwith components on the same segment of our internal network.
* Our internal network wasn't appropriately being monitored.
* Our internal network was temporarily misconfigured.
What we're doing to fix it
* We've doubled the capacity of our internal network.
* We're improving the monitoring of our internal network.
* We're rebalancing the traffic on our internal network to redistribute the load.”
(http://engineering.twitter.com/2010/06/perfect-stormof-whales.html)

Reddit has also had some huge challenges with traffic:
“We've been kinda bummed at reddit these days. It seems like every week something comes up that slows performance to a crawl or even leads to a total site outage. And we almost never get a chance to release new features anymore.
Our four engineers -- KeyserSosa, jedberg, ketralnis, and myself -- are working full time (plus many evenings and weekends and sometimes even the middle of the night) just to keep things going. Perhaps we're doing it wrong: there might be ways to optimize our code, or technologies that could allow us to work more efficiently, but we're too busy to investigate these things, or to migrate to the ones that look promising. It becomes a vicious cycle.
The bottom line is, we need more resources.”
(http://blog.reddit.com/2010/07/reddit-needs-help.html)

Friday, July 9, 2010

UFO shuts down Chinese airport

The strange light appeared to glow as it swept through the night sky, to the alarm of local residents
Another photo from a different angle which shows a wide trail behind the object as it zips through the sky

According to the dailymail.co.uk the the Xiaoshan airport was closed and many flights were diverted when a UFO flew into the airports airspace. Chinese officials said the object was not made public because of a “military connection”.   It should be interesting to hear what this object is.

Wednesday, February 14, 2007

Parking Stub

I met with Steve Hearst of the Hearst family and to validate my parking ticket, he signed it.... just thought it was interesting ... a bit of California history.. a bit blurry though

hearst.jpg



Monday, November 20, 2006

Monday, May 8, 2006

Mike Relm

I saw this guy saturday, Check out a sampling of his show that night....


Saturday, March 11, 2006

Media Bistro

My friend Scott Ritchie and I were at Swig and ended up in a photo :
tn_13.jpg

Media Bistro Event page


Elly Chou's Macys Comercial

One of many of Elly's comercials that have aired in the US

The SkateMag

I got my photo in the SkateMag, years of skating never paid off, but a few beers with a friend did

http://www.netreveal.com/ddalton/images/2006/03/mag-thumb.jpg

Thursday, February 16, 2006

Donovan's Birthday at Supper Club

Martel Toler, Jean Wang and I having a few drinks at Donovans Supper Club party.
http://www.netreveal.com/ddalton/images/2006/03/memarteljean-thumb.jpg

Thursday, February 26, 2004

Electrobras Fire

I was sitting in my office in Rio De Janeiro and over looking the office building next to me one day and I saw the building start to smoke, the heat was so intense that the building actually cracked and they had concerns that it may fall. Electrobras was the power company in Rio that just happened to be in the middle of an investigation concerning fraud, the fire started in their records room.

building.png

Brazil: On 26 February 2004, around 0430 local time, a major fire broke out in the 22-story Electrobras building in Rio de Janeiro, located on the corner of Avenida Rio Branco and Presidente Vargas, one of the busiest sections in downtown Rio. There have been no reported victims from the fire, but firefighting officials are worried that the building could collapse due to the fire causing structural damage to the building. The fire has caused traffic to come to a standstill in the area.