A Django site.
July 28, 2008

Doran Barton
fozzmoo
Fozzolog
» Battle Of The News Headlines - now on YouTube

A couple weeks ago, Glenn Beck started doing a new bit on his radio program: "Battle Of The News Headlines" where he takes news headlines of the day about either Barack Obama or John McCain and pits them against one another. Then, after four or five of these headlines are revealed for each candidate, a winner is declared.

I found this to be hilarious and an ingenious way to demonstrate just how ridiculously biased (twiterpated, obsessed, etc.) the mainstream media is with B.O.

After hearing Glenn do this 3-4 minute bit for a couple of days, I came up with the idea of making some YouTube videos to go along with the audio of his show. And now, I've created video to go along with all eight of the "battles" aired so far. Enjoy.

On another note, while I'm editing these videos using a Windows application, I'm using open source software on Linux to edit the audio, create the graphic elements used in the video, and transcoding the video in preparation for upload to YouTube.

» Doran Barton

A couple weeks ago, Glenn Beck started doing a new bit on his radio program: "Battle Of The News Headlines" where he takes news headlines of the day about either Barack Obama or John McCain and pits them against one another. Then, after four or five of these headlines are revealed for each candidate, a winner is declared.

I found this to be hilarious and an ingenious way to demonstrate just how ridiculously biased (twiterpated, obsessed, etc.) the mainstream media is with B.O.

After hearing Glenn do this 3-4 minute bit for a couple of days, I came up with the idea of making some YouTube videos to go along with the audio of his show. And now, I've created video to go along with all eight of the "battles" aired so far. Enjoy.

On another note, while I'm editing these videos using a Windows application, I'm using open source software on Linux to edit the audio, create the graphic elements used in the video, and transcoding the video in preparation for upload to YouTube.

June 5, 2008

Doran Barton
fozzmoo
Fozzolog
» Using open source tools to capture my favorite radio program audio stream

Listen to any kind of syndicated talk radio program and you'll usually hear about some companion website the program has. Usually, there are a handful of free things you can get on a program's website, but many of these sites have a pay-to-play members' area where the really good content is. This includes MP3 downloads of the shows, access to live audio and/or video streams, special behind-the-scenes content, forums, desktop backgrounds, etc.

The MP3 downloads are very convenient for people who don't have the luxury of sitting in front of a radio (or driving a car) for a solid three hours while a radio program is broadcast (with advertisements). It's also a boon for people who find radio advertisements annoying.

The only problem with the MP3 downloads is that theme music and produced portions of the program can not, by law, be included in the MP3 file because otherwise the MP3 would be a copyright violation.

Live streams, on the other hand, are not subject to the above described restriction because they're like a broadcast in nature. They're not a time-shift of the original program. So, if you listen to the live stream or even listen to a pre-recorded program as a stream, music and produced segments may be included.

I listen to the Glenn Beck radio program quite often. I used to download the MP3 files to listen to in the car, but it got annoying everytime Glenn and his producers would put together a segment like "Sportscasters at the 2031 animal-human hybrid baseball games", or "The History Of the Democratic Superdelegates" and I would hear Glenn say, "Listen to this... [pause] Oh man! That was great! Wasn't that great, Stu? Oh yeah! Alright! Dan? Wasn't that just the best? Yeah. Oh yeah."

I decided I needed to figure out how to save a stream.

I knew it was possible. Lots of software applications exist for any operating systems that will convert audio from a live stream into a static WAV file or similar. The open source program mplayer is one such example.

Breaking it down

First of all, I needed to figure out how the stream content made its way to my computer.

After I've logged into the Glenn Beck website as an Insider, I can click a link to listen to a stream of a particular hour of the program (or the whole program) in Windows Media format or RealAudio format. I figured I'd have better luck extracting the audio from the Windows Media format, so I went that route. Instead of just clicking the link and letting my web browser find some program that could handle the content, I saved the content to a file and then looked at the file.

The file it saved was a fairly straightforward XML file that looked something like this:

<ASX VERSION="3.0">
  <TITLE>Glenn Beck</TITLE>
  <AUTHOR>Premiere Radio Networks</AUTHOR>
  <COPYRIGHT>Copyright 2008</COPYRIGHT>

 <ENTRY>

    <TITLE>Glenn Beck 1</TITLE>

    <AUTHOR>Premiere Radio Networks</AUTHOR>

    <COPYRIGHT>Copyright 2008</COPYRIGHT>
 

    <REF HREF="mms://a0011.v67134.c6713.g.vm.akamaistream.net/7/0011/6713/v08060322/glennbeck.download.akamai.com/6713/_!/shows/2008/06/03/GLENNBECKWIN20080603.WMA?auth=blahblahblahblahblah" />

    <REF HREF="http://a0011.v67134.c6713.g.vm.akamaistream.net/7/0011/6713/v08060322/glennbeck.download.akamai.com/6713/_!/shows/2008/06/03/GLENNBECKWIN20080603.WMA?auth=blahblahblahblahblahblah
  </ENTRY>

  <ENTRY>

    <TITLE>Glenn Beck 2</TITLE>

    <AUTHOR>Premiere Radio Networks</AUTHOR>

    <COPYRIGHT>Copyright 2008</COPYRIGHT>

    

    <REF HREF="mms://a0011.v67134.c6713.g.vm.akamaistream.net/7/0011/6713/v08060322/glennbeck.download.akamai.com/6713/_!/shows/2008/06/03/GLENNBECKWIN20080603_CLIP01.WMA?auth=blahblahblahblahblahblah" />

    <REF HREF="http://a0011.v67134.c6713.g.vm.akamaistream.net/7/0011/6713/v08060322/glennbeck.download.akamai.com/6713/_!/shows/2008/06/03/GLENNBECKWIN20080603_CLIP01.WMA?auth=blahblahblahblahandblah" />

  </ENTRY>

...and so on.

This XML defines the MMS URLs for each segment of the show. There are several segments each hour. These individual MMS URLs are what I needed to feed to the application that was going to convert the audio stream to a file. In my case, I decided to use mplayer because it's just so good at everything it does!

The command line for doing the stream-to-file conversion looks like this:

mplayer -vc null -vo null -ao pcm:fast:file=dumpfile.wav \
    'mms://a0011.v67134.c6713.g.vm.akamaistream.net/blahblahblah...'

The real magic in the above command is where I use -ao pcm to tell mplayer to use the PCM file writer audio output driver (instead of sending the audio to my speakers).

This gives me a WAV file which I'll want to convert to an MP3 or Ogg-Vorbis file.

To convert a WAV file generated by the mplayer command above to an MP3 file, I use the open source lame tool:

lame -mf -q2 dumpfile.wav GlennBeck.mp3

Or, convert it to Ogg-Vorbis (the completely open and better-sounding-than-MP3 lossy audio codec):

oggenc -q2 --downmix -o GlennBeck.ogg dumpfile.wav

I've now covered the basic mechanical components of converting an audio stream into an MP3 or Ogg-Vorbis file. Next I automate it all.

Automation

Because I'm a long-time Perl junkie, I investigated how I could use a Perl script to act as the glue between the components and get the whole process of capturing a stream and converting it to MP3 or Ogg-Vorbis.

In the above walk-through, I manually logged into the Glenn Beck website with my web browser. To really completely automate this puppy, I wanted the script to log in for me. It didn't take me very long to figure out the Perl CPAN module WWW::Mechanize was what I needed to use.

WWW::Mechanize does several handy things for the programmer. It loads and parses web pages and can follow links, populate forms, and other basic kinds of interaction. It keeps track of its own cookies and session data too.

To get into the Insider area of the Glenn Beck website, members must enter their username and password on the Insider login page.

Looking at the HTML source for this page, I learned the form was named "aform", the username field was named "iUName", and the password field was named "iPassword".

I now had all the information I needed for WWW::Mechanize to log in:

my $agent = WWW::Mechanize->new(
    cookie_jar  => {},
);
   
my $resp = $agent->get('http://www.glennbeck.com/content/insider');
   
if($resp->is_success) {
    $resp = $agent->submit_form(
        form_name   =>  'aform',
        fields      =>  {   'iUName'    =>  'myusername',
                                'iPassword' =>  'shhhhhhhh!', },
        button      =>  'submit');

Walking through the code above: First, I create the WWW::Mechanize object with an in-memory cookie jar (cookie_jar => {}). Next, I use the object to get() the log-in page. If everything works well so far, I tell the object to find the form named "aform", fill in the username and password fields, and submit the form.

One thing I realized as I was debugging my script was that after I logged in on the Insider page, I was immediately redirected to another page. In order for my script to work, it needed to follow the redirect. This was an easy fix:

my $agent = WWW::Mechanize->new(
    cookie_jar  => {},
    redirect_ok => 1,
);

The page I got redirected to has the links on it for the streaming audio, so I'm exactly where I want to be if I want to capture and convert the latest and greatest Glenn Beck Program audio stream.

WWW::Mechanize can find links within the page with a variety of methods. One of these leverages Perl's excellent support for regular expressions. You can also search for links by the order in which they appear. The link I'm looking for looks like this:

<a href="http://www.premiereinteractive.com/cgi-bin/members.cgi?stream=shows/GLENNBECKWIN20080604&site=glennbeck&type=win_show"><img src="http://media.glennbeck.com/images/common/header_media5off.jpg" name="icon5" width="26" height="34" border="0" id="icon5" onMouseOver="MM_swapImage('icon5','','http://media.glennbeck.com/images/common/header_media5on.jpg',1)" onMouseOut="MM_swapImgRestore()" /></a>

So, my script has the following:

$link = $agent->find_link( url_regex => qr/${datestr}.*win_show$/);
$resp = $agent->get($link);

This assumes I have a scalar variable $datestr that contains a formatted date for the show I want to capture.

Originally, I was going to use one of Perl's several XML-parsing modules to make sense of the XML in the stream link, but in the end all I needed was a regular expression to extract the mms: URLs.

my $xml = $resp->decoded_content;
my (@urls) = $xml =~ m/HREF="(mms:[^"]+)"/msg;

This gives me a list of URLs stored in @urls. Now I just need to feed them to mplayer:

$i = 1;
foreach my $u (@urls) {
    my $seq = sprintf("%02d", $i);
    my @cmd = ( 'mplayer', 
            '-vc', 'null', 
            '-vo', 'null',
            '-ao', "pcm:fast:file=${datestr}-${seq}.wav", 
            $u);
    system(@cmd);
    if ($? == -1) {
        print "failed to execute: $!\n";
    }
    elsif ($? & 127) {
        printf "child died with signal %d, %s coredump\n",
        ($? & 127),  ($? & 128) ? 'with' : 'without';
    }
    else {
        printf "child exited with value %d\n", $? >> 8;
    }

    $i++;
}

This little ditty creates an output file for each of the segment streams. These are named something like 20080604-05.wav.

When the loop is finished, I have several WAV files sitting on the disk. Now I need to somehow sew them all together into one big WAV file so I can convert it to an MP3 or Ogg-Vorbis file. For this, I turn to sox. I decided to have the Perl script generate a shell script to run all the sox and lame commands needed.

open FH, ">/tmp/${datestr}.sh";
foreach my $j (1..($i-1)) {
    my $seq = sprintf("%02d", $j);
    print FH 'sox ', "${datestr}-${seq}.wav", " -t raw - | cat >> /tmp/${datestr}.raw", "\n";
}
print FH 'sox -w -s -c 1 -r 22050 ', "/tmp/${datestr}.raw ${datestr}.wav\n";
print FH "lame -mf -q2 ${datestr}.wav ${datestr}.mp3 ";
print FH "--tt \"Glenn Beck Show - $datestr\" ";
print FH "--ta \"Glenn Beck\" --add-id3v2\n";
close FH;

Then, I run the shell script:

system('sh', "/tmp/${datestr}.sh");

Finally, I do a little cleanup:

unlink "/tmp/${datestr}.sh", "/tmp/${datestr}.raw", map({"${datestr}-$_.wav"} (1..($i-1)));

And, I'm done. There are many other ways I could have gone about doing this, but I found a way that worked and ran with it. I'd love to hear from people who have done something similar and how they did it.

February 14, 2008

Hans Fugal
no nic
The Fugue :
» Scanner Antennas

In a previous post I talked about my new scanner and my early antenna adventures. Now I am happily set up and done playing with antennas, so I thought I'd tell you what the final verdict is. Also, it has been requested that I post some pictures. The pictures are here, and I'll embed some of them in this post.

The antenna I'm using is actually not the one I described making in the previous post. It would have worked fine, but I found the functional equivalent at Radio Shack for $5, only slightly more robust. Here's a picture:

Clipped FM Antenna

It is sold as an FM antenna. I think the package said dipole, but it's actually a folded dipole. I clipped the ends to match my target frequency, then soldered the leads together and put some electrical tape on for protection. Even when it was just an FM antenna it got better reception than the rubber duckie.

It is attached to the radio via a TV balun (300Ω to 75Ω) and a female TV-style coax to male BNC adapter:

Scanner

I also constructed a dipole using coat hangers and electrical tape. I need to get a connector for this, since the balun is unnecessary, but even when I hook it up to the balun it does very well. I think the coat hanger being thicker helps. I think it even outperforms the folded dipole, both my custom one (not shown) and the FM antenna. A bit unwieldy though, compared to the FM antenna.

Coat Hanger Dipole

Speaking of baluns, I asked an expert and his unofficial opinion is that for reception only impedance mismatch isn't a big deal. Certainly seems to be the case in my limited experience (even with the TV balun, it's 75Ω when the scanner nominally wants 50Ω). Still, the TV balun makes a nice adapter, and it can't hurt. They're very cheap, too.

December 31, 2007

Hans Fugal
no nic
The Fugue :
» Scanner and Antenna

I got a handheld radio scanner for my birthday and Christmas with the cash I received (thanks, everyone!). I got a RadioShack PRO-84 on sale for $60. It can scan lots of different things, but I'm primarily interested in listening to aviation communications, which is from 108 MHz to 137 MHz. I've found the scanner to be quite satisfactory, with the minor annoyance that it is difficult to listen to an arbitrary frequency without assigning it to one of the 200 numbered channels (so I pick a channel or two as my temporary channels).

Although it works great for listening to traffic at the airport, for listening to traffic away from the airport (e.g. at home), the included "rubber duckie" antenna is not up to the task. So I set about making my own.

I went from knowing nothing about antennas to knowing just enough to sound like I know what I'm talking about, and apparently to build a simple one. I learned a few interesting things in the process.

One simple and decent antenna is the dipole. You may be familiar with a version of the dipole known as rabbit ears. What you may not realize is that the rabbit ears work best completely horizontal (not in a V shape) and adjusted in length to match the frequency of the desired television station. Also, they need to be pointed in the right direction (broadside the transmitter) for best reception, and they should be away from the TV. So much for TV antennas.

So I had decided on making a dipole, and started seeing claims that this variation called the folded dipole is "quieter" and has "more bandwidth". It is almost as simple to make as a dipole, so I decided to go with that. Now it was time to figure out how to make it cheaply. I'm happy to report I was able to make the antenna for $5 and change, and it works quite well. I am sitting in Pleasant Grove, scanner and antenna indoors, listening to Provo traffic, including planes on the ground. I imagine I'll have similar results at home where the terrain profile is similar between my house and the airport.

So here's what I did. I bought some TV twinlead (that stuff with two wires separated by insulation), one of those TV balun things, and a TV coax to BNC adapter. I cut the twin lead to 52 inches, then twisted the two wires together at each end. Then I cut one of the wires in the center and screwed the two leads to the balun. Then I attached the balun to the BNC connector and hooked it up to the radio. The improvement over the rubber duckie is very apparent.

TV Balun

I also toyed with just hooking one lead of the original 6-foot length of twin lead directly to the center of the coax/BNC adapter. This also works well (I presume this is a random wire antenna), and you could probably also use a coat hanger. This would make a good portable antenna for visiting the airport. Look, two antennas in one!

Here's some techincal tidbits about the antenna I made. 52 inches corresponds to 108 MHz. I will probably trim it to 122.7 MHz (KLRU CTAF) when I get home, but I wanted to err on the side of too long to start with. A folded dipole is 300Ω balanced, and my scanner wants a 50Ω unbalanced connection, which is where the balun comes in. It converts to 75Ω unbalanced, which is still not a perfect match but seems to work well enough. I have since found plans for what's called a "coaxial dipole", or "double bazooka" antenna, which claims to not need a balun and match 50Ω. There are also plans for a twelfth-wave matching transformer that will match 75Ω to 50Ω with about a foot of coax, but you need both 50Ω and 75Ω coax to do it. The cost of that could be a few cents if you have spare coax lying around, or $20 if you have to buy it new. If I have unsatisfactory reception at home, I may try the bazooka and/or the transformer and report.

November 8, 2007

Doran Barton
fozzmoo
Fozzolog
» The latest news from Glenn Beck-ville.

If you've read any of my blog entries before, you know I'm a fan of talk radio host Glenn Beck. There have been a couple of recent developments in the Glenniverse lately.

Glenn Beck First of all, The Telegraph -- a newspaper/website out of the UK -- ran a story all last week with their top-100 most influential United States liberals and conservatives. When Sean Hannity came in at number 44 and Bill O'Reilly showed up at number 82, I think most Glenn Beck fans expected he didn't make the list. On Friday, when numbers 1-20 were announced, Glenn showed up at number 18.

Here is the blurb they wrote about him:

A reformed alcoholic and former drug addict who converted to Mormonism, Glenn Beck boasts the fourth most popular talk radio show in America with about five million listeners each week. His hour-long nightly television show on CNN is referred to by the network as "an unconventional look at the news of the day" and gives Beck's conservative viewpoint an influential outlet in the American mainstream.

Beck recently stated he is "through with" George W. Bush, citing the issues of immigration reform and soaring government spending - a reflection of the views of many grassroots conservatives. A climate change sceptic and vocal advocate for more troops in Iraq. A persistent critic of political correctness, he has compared Al Gore to Goebbels and referred to Hillary Clinton as "Stalin in a pantsuit". With a growing audience in the key 25-54 demographic, he is a potential heir to Rush Limbaugh.

That was cool, but then, over the weekend, the New York Times ran an article titled "A Folksy Guy, in Recovery, Is About to Land Millions" which talks about Glenn signing a new 5-year contract with Premiere Radio Networks reportedly worth 50 million dollars!

Sounds like Mr. Beck is doing pretty dang well for himself. On Monday's radio show, Glenn mentioned that, as part of the contract renewal, he brought many of the people he worked with as part of his radio and television shows who worked for other companies to work directly for him. For some of these people, they received 70% increases in their salaries. Everyone who works for Glenn gets the best health insurance money can buy and Glenn's company pays their premiums IN FULL. He also has a charity matching program in which he will personally match any donation to any charity by any of his employees.

Glenn's rise to success has taken about eight years. He mentioned in 1999, he could barely afford a $695/mo rent payment. He didn't say it in so many words, but seemed to imply that he attributes a great deal of his success to his faithful tithe paying as a member of the LDS faith.

So, it's been a great week for Mr. Beck.

In other news... I'm a Glenn Beck Insider. That means I have paid out some hard-earned cash to Glenn Beck's company so that I can have exclusive access to MP3s of his radio program, live streams, and other goodies. That's not the other news, however. As a member of the Glenn Beck Insiders program, I also have access to an online forums application where Insiders can discuss various topics. Now, I've never been a fan of web forums or bulletin board software, especially the PHP varieties that seem to be so prevalent online, but this community has really grown on me.

A few weeks ago, I found out about the Flat Glenn project. This was a project started by an Insider named Mae Lynn who wanted to start something akin to Flat Stanley in which a small, flat cutout of Glenn Beck was shipped from location to location in the United States to various Insiders. The Insiders would then take photographs of the Flat Glenn (affectionately called FG by most) at historic or noteable places. These pictures have been posted electronically to the Insider forums and to Mae Lynn's forums at flatglenn.com.

This sounded to me like a lot of fun, so I started asking around about it. I found out FG was bound for Utah, Logan to be exact, in a couple weeks and then would be going to Salt Lake. I had hoped to get my hands on him for a couple days, but discovered there's a LONG list of people around the country waiting for their chance to host FG in their town, so I'll just have to wait my turn to be a host. But I did hook up with FG's host, Gina, in Salt Lake City and met her at Temple Square for some picture taking.

Here's a picture of me, Gina, and Flat Glenn:

Me, Gina, and Flat Glenn

To see all the pictures that were taken of Flat Glenn in Salt Lake City, go here.

September 20, 2007

Lars Rasmussen
lars-ut
Lars Rasmussen (Lars-UT)
» Google Angering Mobile Phone Companies & Becoming a Giant US ISP

Whether or not Google actually ends up buying the 700-MHz band, an additional player/competitor toying with multi-billion dollar spectrum is not pleasant for Verizon, AT&T, and Sprint. Such are the effects of capitalism - go Google!

Bob Cringely puts Google's 700MHz plans in perspective in his latest post - here's a taste:
"Imagine a hybrid wireless broadband mesh network using 700-MHz connections for backhaul and some truly mobile links and WiFi for local service."

With the aggregate of personal information supplied by users googling their search terms(especially while signed in to a google account such as Gmail), Google's servers aboundeth with information as to that which is being searched, purchased, emailed(your friend's Gmail emails are indexed as well), and blogged. Google owns the servers running this blog.

Mobile internet access is about to change very quickly.