How to Archive a Newscast

Let’s there’s a newscast that has footage implicating you, and that you want to archive it so that you have totems of your past years down the road. If it comes from a certain Canadian public broadcaster, you can use cURL and rtmpdump to store it.

First, you go to the page where the stream can be seen.

You then load up the source code for the page. In Google Chrome, this is done by typing in CTRL-Shift-J or by going into the Tools menu.

You’ll find a line for the streaming video that’s displayed:

<param name="flashvars" value="ID=player&RSI=cbc-production&URI=http%3A%2F%2Ffeed.theplatform.com%2Ff%2Fh9dtGB%2Fr3VD0FujBumK&url=http%3A%2F%2Flink.theplatform.com%2Fs%2Fh9dtGB%2FVnA1AdNwKLyHfCVIfJHJA8QY9Me6enym%3FisPLS%3Dfalse%26airdate%3D1337731200000%26mbr%3Dtrue%26site%3Dcbc.news.ca%26zone%3Dnews%26shortClip%3Dfalse%26sport%3Dnot_applicable%26show%3Dcbc_news_ottawa_at_600%26audioonly%3Dfalse%26liveondemand%3Dondemand">

From that line, you’ll copy the contents of the value attribute:

ID=player&RSI=cbc-production&URI=http%3A%2F%2Ffeed.theplatform.com%2Ff%2Fh9dtGB%2Fr3VD0FujBumK&url=http%3A%2F%2Flink.theplatform.com%2Fs%2Fh9dtGB%2FVnA1AdNwKLyHfCVIfJHJA8QY9Me6enym%3FisPLS%3Dfalse%26airdate%3D1337731200000%26mbr%3Dtrue%26site%3Dcbc.news.ca%26zone%3Dnews%26shortClip%3Dfalse%26sport%3Dnot_applicable%26show%3Dcbc_news_ottawa_at_600%26audioonly%3Dfalse%26liveondemand%3Dondemand

There are many websites that will decode the contents for you. It uses what’s known as Percent Encoding to represent symbols and white space. So you pass the contents through such a website:

The decoded string looks like this:

ID=player&RSI=cbc-production&URI=http://feed.theplatform.com/f/h9dtGB/r3VD0FujBumK&url=http://link.theplatform.com/s/h9dtGB/VnA1AdNwKLyHfCVIfJHJA8QY9Me6enym?isPLS=false&airdate=1337731200000&mbr=true&site=cbc.news.ca&zone=news&shortClip=false&sport=not_applicable&show=cbc_news_ottawa_at_600&audioonly=false&liveondemand=ondemand

From this string, you extract the URL:

http://link.theplatform.com/s/h9dtGB/VnA1AdNwKLyHfCVIfJHJA8QY9Me6enym?isPLS=false&airdate=1337731200000&mbr=true&site=cbc.news.ca&zone=news&shortClip=false&sport=not_applicable&show=cbc_news_ottawa_at_600&audioonly=false&liveondemand=ondemand

You then call the cURL command to pull in the resource pointed to by the link:

curl "http://link.theplatform.com/s/h9dtGB/VnA1AdNwKLyHfCVIfJHJA8QY9Me6enym?isPLS=false&airdate=1337731200000&mbr=true&site=cbc.news.ca&zone=news&shortClip=false&sport=not_applicable&show=cbc_news_ottawa_at_600&audioonly=false&liveondemand=ondemand"

An XML page will spit out:

This is what the XML document looks like. Each request provides a unique result, as a single-use authentication key is always generated:

<smil xmlns="http://www.w3.org/2005/SMIL21/Language">
<head>
<meta base="rtmp://cp37429.edgefcs.net/ondemand/?auth=daFcQdKcOaMbPbJavbLabboaod9dpbPasbb-bpVonT-b4-nnr_CqvZvkHoyBC&amp;aifp=v0001&amp;slist=netstorage"/>
</head>
<body>
<ref src="http://ad.doubleclick.net/pfadx/cbc.news.ca/news/sz=320x240;show=cbc_news_ottawa_at_600;sport=not_applicable;season=;section=;event=;liveondemand=;shortClip=false;audioonly=false;companions=;playerType=" type="video/x-flv" no-skip="true" tags="preroll">
</ref>
<ref src="http://ad.doubleclick.net/pfadx/cbc.news.ca/news/sz=320x240;show=cbc_news_ottawa_at_600;sport=not_applicable;season=;section=;event=;liveondemand=;shortClip=false;audioonly=false;companions=;playerType=" type="video/x-flv" no-skip="true" tags="preroll">
</ref>
<switch>
<video src="netstorage/Ottawa-17_59_48-2012-05-22.mp4" system-bitrate="763019" height="360" width="640"/>
<ref src="netstorage/Ottawa-17_59_48-2012-05-22.mp4" title="CBC News: Ottawa - May 22, 2012" abstract="CBC TV News, Weather and Sports from Ottawa" copyright="CBC Production" dur="1804069ms" guid="_jgXa48TJCzx8HSS_Jth0STefpFW7OK9" categories="News/Canada/Ottawa" type="video/mp4" height="360" width="640">
<param name="adCategory" value="news"/>
<param name="adRules" value="2_2_0"/>
<param name="adSite" value="cbc.news.ca"/>
<param name="airDay" value="(not specified)"/>
<param name="aired" value="false"/>
<param name="audioVideo" value="Video"/>
<param name="availableInHD" value="(not specified)"/>
<param name="availableInMobile" value="false"/>
<param name="camera" value="(not specified)"/>
<param name="commentsEnabled" value="Yes"/>
<param name="contentArea" value="News"/>
<param name="deletethis_shareable" value="true"/>
<param name="genre" value="News"/>
<param name="includesThumbnail" value="false"/>
<param name="isPLS" value="false"/>
<param name="isToBeReleased" value="false"/>
<param name="league" value="(not specified)"/>
<param name="liveOndemand" value="On-Demand"/>
<param name="region" value="Ottawa"/>
<param name="relatedURL1" value="CBC Ottawa|http://www.cbc.ca/ottawa/|_blank"/>
<param name="shareable" value="Yes"/>
<param name="show" value="CBC News: Ottawa at 6:00"/>
<param name="sport" value="(not applicable)"/>
<param name="sportGroup" value="(not specified)"/>
<param name="subtitles" value="Yes"/>
<param name="syndicate" value="Yes"/>
<param name="type" value="(not specified)"/>
<param name="unapprovedDate" value="2524626000000"/>
<param name="configurationError" value="false"/>
<param name="missingFiles" value="false"/>
<param name="missingMetadata" value="false"/>
</ref>
</switch>
</body>

From the feed above, the URL in the base attribute of the meta tag is split up and fed into the parameters of the rtmpdump command, as is the src attribute of the video tag. This produces a command that looks like the following:

rtmpdump -r "rtmp://cp37429.edgefcs.net" -a "ondemand/?auth=daFcQdKcOaMbPbJavbLabboaod9dpbPasbb-bpVonT-b4-nnr_CqvZvkHoyBC&amp;aifp=v0001&amp;slist=netstorage" -y "mp4:netstorage/Ottawa-17_59_48-2012-05-22.mp4" -o news.mp4

In the example above, the newscast was set to be stored in a file called “news.mp4.” It’s important to note that the command can only be invoked the once, using up the unique authentication key. If you screw up, you’ll need to request another of those XML documents to get a new key.

Calling the rtmpdump command downloads the newscast:

Which takes a while, but eventually finishes:

You can then watch it on your local computer:

And there you have it. A moment of your life stored in such a way that it won’t disappear tomorrow.


Comments

One response to “How to Archive a Newscast”

  1. Jeremy Avatar
    Jeremy

    Or…OR!!!…you can set up your camera/iGadget in front of your monitor and record.

    You’re welcome 🙂