<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>PeterKellner.net &#187; TiVo</title>
	<atom:link href="http://peterkellner.net/category/tivo/feed/" rel="self" type="application/rss+xml" />
	<link>http://peterkellner.net</link>
	<description>Microsoft Focused, JavaScript,HTML5 (ExtJS, SenchaTouch &#38; Windows 8 Metro)</description>
	<lastBuildDate>Fri, 11 May 2012 16:43:17 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Just the Exe&#8217;s for the Tivo Summaries Executables!</title>
		<link>http://peterkellner.net/2008/04/07/tivosummariesexe/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=tivosummariesexe</link>
		<comments>http://peterkellner.net/2008/04/07/tivosummariesexe/#comments</comments>
		<pubDate>Tue, 08 Apr 2008 03:49:56 +0000</pubDate>
		<dc:creator>Peter Kellner</dc:creator>
				<category><![CDATA[TiVo]]></category>

		<guid isPermaLink="false">http://peterkellner.net/2008/04/07/tivosummariesexe/</guid>
		<description><![CDATA[<p>The Exe files Tivo Summaries Graphs done in a previous article.  <br /><br /><a href="http://peterkellner.net/2008/01/18/tivospaceviewerwithlinq/" target="_blank">Article on Developing TiVo graphs</a></p>]]></description>
			<content:encoded><![CDATA[<p>Several people have asked for the executable files for the tivo summaries program I wrote a few months back.&#160; Here is a link to the original article and some gratuitous pictures of the results the program produces.</p>
<table cellspacing="0" cellpadding="2" width="400" border="0">
<tbody>
<tr>
<td valign="top" width="200"><a href="http://peterkellner.net/wp/wp-content/uploads/2008/04/tivopie.jpg"><img height="141" alt="tivopie" src="http://peterkellner.net/wp/wp-content/uploads/2008/04/tivopie-thumb.jpg" width="169" /></a> </td>
<td valign="top" width="200"><a href="http://peterkellner.net/wp/wp-content/uploads/2008/04/tivohdsd.jpg"><img height="142" alt="tivohdsd" src="http://peterkellner.net/wp/wp-content/uploads/2008/04/tivohdsd-thumb.jpg" width="240" /></a> </td>
</tr>
</tbody>
</table>
<p><a href="http://peterkellner.net/2008/01/18/tivospaceviewerwithlinq/" target="_blank">Article on Developing TiVo graphs</a></p>
<div class="wlWriterSmartContent" id="scid:fb3a1972-4489-4e52-abe7-25a00bb07fdf:fdf4bb52-9107-40d3-9485-733650c84080" style="padding-right: 0px; display: inline; padding-left: 0px; padding-bottom: 0px; margin: 0px; padding-top: 0px">
<p>Here is the Download For the executable files.  Put in their own directory. <a href="http://peterkellner.net/wp/wp-content/uploads/2008/04/tivosummariesexe.zip" target="_blank">Tivo Executable Zip File</a></p>
</p></div>
]]></content:encoded>
			<wfw:commentRss>http://peterkellner.net/2008/04/07/tivosummariesexe/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>A TiVo Disk Space Viewer, It&#8217;s all about LINQ to XML!</title>
		<link>http://peterkellner.net/2008/01/18/tivospaceviewerwithlinq/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=tivospaceviewerwithlinq</link>
		<comments>http://peterkellner.net/2008/01/18/tivospaceviewerwithlinq/#comments</comments>
		<pubDate>Sat, 19 Jan 2008 02:16:40 +0000</pubDate>
		<dc:creator>Peter Kellner</dc:creator>
				<category><![CDATA[LINQ]]></category>
		<category><![CDATA[TiVo]]></category>

		<guid isPermaLink="false">http://peterkellner.net/2008/01/18/tivospaceviewerwithlinq/</guid>
		<description><![CDATA[<p>Do you ever want to know exactly how much space each TV show on your TiVo is taking on your hard drive?&#160; Do you ever wonder how much space is consumed by high definition programs verses standard definition programs?&#160; For the answer, download the program associated with this article and you to can no those answers.&#160; Below area&#160; pictures of those graphs.&#160; Chances are though, if you are reading my blog, you really want to know about Microsoft technology, and specifically, this article is all about parsing the webservice data that comes from your TiVo.&#160; At the end of the article, there is a brief section on how to configure this program so if all you care about is running the program, skip all the LINQ stuff and just go to the Setup below.&#160; The exe and dll file necessary are attached there.</p> <p>Almost lastly, the application produced uses Windows Forms Programming.&#160; This article makes no attempt to discuss any of the windows forms programming issues.&#160; The code provided in Forms is simply a wrapper to look at all the fun LINQ commands.&#160; In addition, the graphs are done with the Open Source Project <a href="http://zedgraph.org/wiki/index.php?title=Main_Page">Zedgraph</a>.</p> <p>And lasty, this work is heavily based on the <a href="http://blogs.msdn.com/mswanson/archive/2007/12/02/tivo-gadget-for-vista.aspx">TiVo gadget beautifully done by Microsoft's Mike Swanson</a>.&#160; I won't spend much time talking about all the issues regarding setup and security.&#160; Mike has done a great job of that in his article.&#160; If you are running Windows Vista, I suggest you download his awesome sidebar gadget.</p> <p><a href="http://peterkellner.net/wp/wp-content/uploads/2008/01/tivopie.jpg"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="205" alt="tivopie" src="http://peterkellner.net/wp/wp-content/uploads/2008/01/tivopie-thumb.jpg" width="244" border="0"/></a>&#160;&#160;&#160;&#160;&#160; </p>]]></description>
			<content:encoded><![CDATA[<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px" id="scid:fb3a1972-4489-4e52-abe7-25a00bb07fdf:c19f4f5a-4c89-4092-975f-aeeabd6733fa" class="wlWriterSmartContent">
<p>Tivo Space Viewer Source Code <a href="http://peterkellner.net/wp/wp-content/uploads/2008/01/tivosummariesvs2008project.zip" target="_blank">VS2008 Project Complete</a></p>
</p></div>
<h2>Abstract</h2>
<p>Do you ever want to know exactly how much space each TV show on your TiVo is taking on your hard drive?&#160; Do you ever wonder how much space is consumed by high definition programs verses standard definition programs?&#160; For the answer, download the program associated with this article and you to can know those answers.&#160; Below area&#160; pictures of those graphs.&#160; Chances are though, if you are reading my blog, you really want to know about Microsoft technology, and specifically, this article is all about parsing the webservice data that comes from your TiVo.&#160; At the end of the article, there is a brief section on how to configure this program so if all you care about is running the program, skip all the LINQ stuff and just go to the Setup below.&#160; The exe and dll file necessary are attached there.</p>
<p> <span id="more-99"></span>
<p>Almost lastly, the application produced uses Windows Forms Programming.&#160; This article makes no attempt to discuss any of the windows forms programming issues.&#160; The code provided in Forms is simply a wrapper to look at all the fun LINQ commands.&#160; In addition, the graphs are done with the Open Source Project <a href="http://zedgraph.org/wiki/index.php?title=Main_Page">Zedgraph</a>.</p>
<p>And lastly, this work is heavily based on the <a href="http://blogs.msdn.com/mswanson/archive/2007/12/02/tivo-gadget-for-vista.aspx">TiVo gadget beautifully done by Microsoft&#8217;s Mike Swanson</a>.&#160; I won&#8217;t spend much time talking about all the issues regarding setup and security.&#160; Mike has done a great job of that in his article.&#160; If you are running Windows Vista, I suggest you download his awesome sidebar gadget.</p>
<p><a href="http://peterkellner.net/wp/wp-content/uploads/2008/01/tivopie.jpg"><img style="border-right-width: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" border="0" alt="tivopie" src="http://peterkellner.net/wp/wp-content/uploads/2008/01/tivopie-thumb.jpg" width="244" height="205" /></a>&#160;&#160;&#160;&#160; </p>
<p>(This shows TiVo Disk Usage by Recording Type&#160; (In Progress, Suggestions, etc.)</p>
<p><a href="http://peterkellner.net/wp/wp-content/uploads/2008/01/tivohdsd.jpg"><img style="border-right-width: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" border="0" alt="tivohdsd" src="http://peterkellner.net/wp/wp-content/uploads/2008/01/tivohdsd-thumb.jpg" width="244" height="146" /></a>&#160;</p>
<p>(This compares High Definition verses Standard Definition by Recording Type)</p>
<p>&#160; <a href="http://peterkellner.net/wp/wp-content/uploads/2008/01/tivolist.jpg"><img style="border-right-width: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" border="0" alt="tivolist" src="http://peterkellner.net/wp/wp-content/uploads/2008/01/tivolist-thumb.jpg" width="244" height="142" /></a></p>
<p>(And a very simple of what is stored including size and title)</p>
<p>&#160;</p>
<h1>The Basics</h1>
<p>Assuming you have a TiVo that exposes a web feed (works with TiVo Desktop) you&#8217;ve got a chance of this program working for you.&#160; I&#8217;m not at all an expert on TiVo, but I do have a series 3 unit and following the directions written by Mike Swanson to install his Vista Gadget, I got his program to work, and I use a similar mechanism to access the web feed.&#160; So, I suggest first thing to do is to download <a href="http://blogs.msdn.com/mswanson/archive/2007/12/02/tivo-gadget-for-vista.aspx">Mike&#8217;s Vista Sidebar Gadget</a> and make that work.</p>
<p>Once you have that working, you can unzip the file attached to this article, build it with Visual Studio 2008, then enter your TiVo service ID and Media Access Key into the running application, press &quot;Save Settings&quot; and your graphs should appear in the tabs.&#160; Here is what the running program looks like:</p>
<p><a title="Tivo Space Viewer" href="http://peterkellner.net/wp/wp-content/uploads/2008/01/tivospaceviewer.jpg"><img style="border-right-width: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" border="0" alt="TivoSpaceViewer" src="http://peterkellner.net/wp/wp-content/uploads/2008/01/tivospaceviewer-thumb.jpg" width="490" height="410" /></a></p>
<p>&#160;</p>
<h2>The TiVo Web Service Interface</h2>
<p>Without going into all the details about how the xml data is actually retrieved from the TiVo (you can checkout the code yourself), basically what happens is the TiVo provides to the application a full list of all the shows it has stored in XML.&#160; Each show is wrapped in an &lt;Item&gt; element.&#160; Below is one item for your reference.</p>
<div class="csharpcode">
<pre class="alt"><span class="lnum">   1:  </span><span class="kwrd">&lt;</span><span class="html">Item</span><span class="kwrd">&gt;</span></pre>
<pre><span class="lnum">   2:  </span><span class="kwrd">&lt;</span><span class="html">Details</span><span class="kwrd">&gt;</span></pre>
<pre class="alt"><span class="lnum">   3:  </span><span class="kwrd">&lt;</span><span class="html">ContentType</span><span class="kwrd">&gt;</span>video/x-tivo-raw-tts<span class="kwrd">&lt;/</span><span class="html">ContentType</span><span class="kwrd">&gt;</span></pre>
<pre><span class="lnum">   4:  </span><span class="kwrd">&lt;</span><span class="html">SourceFormat</span><span class="kwrd">&gt;</span>video/x-tivo-raw-tts<span class="kwrd">&lt;/</span><span class="html">SourceFormat</span><span class="kwrd">&gt;</span></pre>
<pre class="alt"><span class="lnum">   5:  </span><span class="kwrd">&lt;</span><span class="html">Title</span><span class="kwrd">&gt;</span>Cold Case<span class="kwrd">&lt;/</span><span class="html">Title</span><span class="kwrd">&gt;</span></pre>
<pre><span class="lnum">   6:  </span><span class="kwrd">&lt;</span><span class="html">SourceSize</span><span class="kwrd">&gt;</span>8105492480<span class="kwrd">&lt;/</span><span class="html">SourceSize</span><span class="kwrd">&gt;</span></pre>
<pre class="alt"><span class="lnum">   7:  </span><span class="kwrd">&lt;</span><span class="html">Duration</span><span class="kwrd">&gt;</span>3601000<span class="kwrd">&lt;/</span><span class="html">Duration</span><span class="kwrd">&gt;</span></pre>
<pre><span class="lnum">   8:  </span><span class="kwrd">&lt;</span><span class="html">CaptureDate</span><span class="kwrd">&gt;</span>0x4781B1CE<span class="kwrd">&lt;/</span><span class="html">CaptureDate</span><span class="kwrd">&gt;</span></pre>
<pre class="alt"><span class="lnum">   9:  </span><span class="kwrd">&lt;</span><span class="html">EpisodeTitle</span><span class="kwrd">&gt;</span>Sabotage<span class="kwrd">&lt;/</span><span class="html">EpisodeTitle</span><span class="kwrd">&gt;</span></pre>
<pre><span class="lnum">  10:  </span><span class="kwrd">&lt;</span><span class="html">Description</span><span class="kwrd">&gt;</span>The team searches for a serial ...<span class="kwrd">&lt;/</span><span class="html">Description</span><span class="kwrd">&gt;</span></pre>
<pre class="alt"><span class="lnum">  11:  </span><span class="kwrd">&lt;</span><span class="html">SourceChannel</span><span class="kwrd">&gt;</span>705<span class="kwrd">&lt;/</span><span class="html">SourceChannel</span><span class="kwrd">&gt;</span></pre>
<pre><span class="lnum">  12:  </span><span class="kwrd">&lt;</span><span class="html">SourceStation</span><span class="kwrd">&gt;</span>KPIXDT<span class="kwrd">&lt;/</span><span class="html">SourceStation</span><span class="kwrd">&gt;</span></pre>
<pre class="alt"><span class="lnum">  13:  </span><span class="kwrd">&lt;</span><span class="html">HighDefinition</span><span class="kwrd">&gt;</span>Yes<span class="kwrd">&lt;/</span><span class="html">HighDefinition</span><span class="kwrd">&gt;</span></pre>
<pre><span class="lnum">  14:  </span><span class="kwrd">&lt;</span><span class="html">ProgramId</span><span class="kwrd">&gt;</span>EP5927270107<span class="kwrd">&lt;/</span><span class="html">ProgramId</span><span class="kwrd">&gt;</span></pre>
<pre class="alt"><span class="lnum">  15:  </span><span class="kwrd">&lt;</span><span class="html">SeriesId</span><span class="kwrd">&gt;</span>SH592727<span class="kwrd">&lt;/</span><span class="html">SeriesId</span><span class="kwrd">&gt;</span></pre>
<pre><span class="lnum">  16:  </span><span class="kwrd">&lt;</span><span class="html">ByteOffset</span><span class="kwrd">&gt;</span>0<span class="kwrd">&lt;/</span><span class="html">ByteOffset</span><span class="kwrd">&gt;</span></pre>
<pre class="alt"><span class="lnum">  17:  </span><span class="kwrd">&lt;/</span><span class="html">Details</span><span class="kwrd">&gt;</span></pre>
<pre><span class="lnum">  18:  </span><span class="kwrd">&lt;</span><span class="html">Links</span><span class="kwrd">&gt;</span></pre>
<pre class="alt"><span class="lnum">  19:  </span><span class="kwrd">&lt;</span><span class="html">Content</span><span class="kwrd">&gt;</span></pre>
<pre><span class="lnum">  20:  </span><span class="kwrd">&lt;</span><span class="html">Url</span><span class="kwrd">&gt;</span>http://652-0001-5555-4444:80/downloa.T...<span class="kwrd">&lt;/</span><span class="html">Url</span><span class="kwrd">&gt;</span></pre>
<pre class="alt"><span class="lnum">  21:  </span><span class="kwrd">&lt;</span><span class="html">ContentType</span><span class="kwrd">&gt;</span>video/x-tivo-raw-tts<span class="kwrd">&lt;/</span><span class="html">ContentType</span><span class="kwrd">&gt;</span></pre>
<pre><span class="lnum">  22:  </span><span class="kwrd">&lt;/</span><span class="html">Content</span><span class="kwrd">&gt;</span></pre>
<pre class="alt"><span class="lnum">  23:  </span><span class="kwrd">&lt;</span><span class="html">CustomIcon</span><span class="kwrd">&gt;</span></pre>
<pre><span class="lnum">  24:  </span><span class="kwrd">&lt;</span><span class="html">Url</span><span class="kwrd">&gt;</span>urn:tivo:image:expired-recording<span class="kwrd">&lt;/</span><span class="html">Url</span><span class="kwrd">&gt;</span></pre>
<pre class="alt"><span class="lnum">  25:  </span><span class="kwrd">&lt;</span><span class="html">ContentType</span><span class="kwrd">&gt;</span>image/*<span class="kwrd">&lt;/</span><span class="html">ContentType</span><span class="kwrd">&gt;</span></pre>
<pre><span class="lnum">  26:  </span><span class="kwrd">&lt;</span><span class="html">AcceptsParams</span><span class="kwrd">&gt;</span>No<span class="kwrd">&lt;/</span><span class="html">AcceptsParams</span><span class="kwrd">&gt;</span></pre>
<pre class="alt"><span class="lnum">  27:  </span><span class="kwrd">&lt;/</span><span class="html">CustomIcon</span><span class="kwrd">&gt;</span></pre>
<pre><span class="lnum">  28:  </span><span class="kwrd">&lt;</span><span class="html">TiVoVideoDetails</span><span class="kwrd">&gt;</span></pre>
<pre class="alt"><span class="lnum">  29:  </span><span class="kwrd">&lt;</span><span class="html">Url</span><span class="kwrd">&gt;</span>https://4444-0001-6565-d...146267<span class="kwrd">&lt;/</span><span class="html">Url</span><span class="kwrd">&gt;</span></pre>
<pre><span class="lnum">  30:  </span><span class="kwrd">&lt;</span><span class="html">ContentType</span><span class="kwrd">&gt;</span>text/xml<span class="kwrd">&lt;/</span><span class="html">ContentType</span><span class="kwrd">&gt;</span></pre>
<pre class="alt"><span class="lnum">  31:  </span><span class="kwrd">&lt;</span><span class="html">AcceptsParams</span><span class="kwrd">&gt;</span>No<span class="kwrd">&lt;/</span><span class="html">AcceptsParams</span><span class="kwrd">&gt;</span></pre>
<pre><span class="lnum">  32:  </span><span class="kwrd">&lt;/</span><span class="html">TiVoVideoDetails</span><span class="kwrd">&gt;</span></pre>
<pre class="alt"><span class="lnum">  33:  </span><span class="kwrd">&lt;/</span><span class="html">Links</span><span class="kwrd">&gt;</span></pre>
<pre><span class="lnum">  34:  </span><span class="kwrd">&lt;/</span><span class="html">Item</span><span class="kwrd">&gt;</span></pre>
<pre class="alt"><span class="lnum">  35:  </span><span class="kwrd">&lt;</span><span class="html">Item</span><span class="kwrd">&gt;</span></pre>
</div>
<p>The data we are actually interested in is Duration (line 7), HighDefinition (line 13), Url (line 20) and Title (line 5).&#160; The entire purpose of using LINQ to XML is to extract this information from the repeating &lt;Item&gt; tag and have available for plotting.&#160; The next several sections explains in details how XML is used to extract this data.</p>
<p><span style="color: #0000ff"></span>&#160;</p>
<h2>Create a Generic List of Objects for Further Processing</h2>
<p>To figure out how much space is allocated to each recording type, we essentially need to do a sort and sum of type of recording (called url in our xml).&#160; The url tag is actually buried under the &lt;Links&gt; and &lt;Contents&gt; tags (see lines 18-20 above) so this is a little tricky.&#160; I&#8217;ll outline the steps we need to follow.</p>
<p>The first thing we do is create a simple type called TivoShowInfo.&#160; This type (really a class definition) is defined as follows:</p>
<div class="csharpcode">
<pre class="alt"><span class="lnum">   1:  </span><span class="kwrd">class</span> TivoShowInfo</pre>
<pre><span class="lnum">   2:  </span>    {</pre>
<pre class="alt"><span class="lnum">   3:  </span>       <span class="rem">/// &lt;summary&gt;</span></pre>
<pre><span class="lnum">   4:  </span>       <span class="rem">/// Initializes a new instance of the </span></pre>
<pre class="alt"><span class="lnum">   5:  </span>       <span class="rem">/// TivoShowInfo class.</span></pre>
<pre><span class="lnum">   6:  </span>       <span class="rem">/// &lt;/summary&gt;</span></pre>
<pre class="alt"><span class="lnum">   7:  </span>       <span class="rem">/// &lt;param name="title"&gt;&lt;/param&gt;</span></pre>
<pre><span class="lnum">   8:  </span>       <span class="rem">/// &lt;param name="duration"&gt;&lt;/param&gt;</span></pre>
<pre class="alt"><span class="lnum">   9:  </span>       <span class="rem">/// &lt;param name="numberBytes"&gt;&lt;/param&gt;</span></pre>
<pre><span class="lnum">  10:  </span>       <span class="rem">/// &lt;param name="showType"&gt;&lt;/param&gt;</span></pre>
<pre class="alt"><span class="lnum">  11:  </span>       <span class="kwrd">public</span> TivoShowInfo(<span class="kwrd">string</span> title, <span class="kwrd">int</span> duration,</pre>
<pre><span class="lnum">  12:  </span>       Int64 numberBytes, <span class="kwrd">string</span> showType,</pre>
<pre class="alt"><span class="lnum">  13:  </span>       <span class="kwrd">bool</span> highDefinition)</pre>
<pre><span class="lnum">  14:  </span>       {</pre>
<pre class="alt"><span class="lnum">  15:  </span>       _Title = title;</pre>
<pre><span class="lnum">  16:  </span>       _Duration = duration;</pre>
<pre class="alt"><span class="lnum">  17:  </span>       _NumberBytes = numberBytes;</pre>
<pre><span class="lnum">  18:  </span>       _ShowType = showType;</pre>
<pre class="alt"><span class="lnum">  19:  </span>       _HighDefinition = highDefinition;</pre>
<pre><span class="lnum">  20:  </span>} ... </pre>
</div>
<p>The reason we do this will become apparent in the next section as we build the list. So, let&#8217;s assume we have an XML file represented by a string (xmlString). First thing we have to do is create an XNamespace declaration to help us process the xml.&#160; The reason we need this is because the namespace is actually defined in the xml file itself so we need to reference it in our queries.</p>
<p><span style="color: #000000">Here is what the top of the XML looks like that comes from the TiVo:</span></p>
<div class="csharpcode">
<pre class="alt"><span class="lnum">   1:  </span><span class="kwrd">&lt;?</span><span class="html">xml</span> <span class="attr">version</span><span class="kwrd">="1.0"</span> <span class="attr">encoding</span><span class="kwrd">="utf-8"</span>?<span class="kwrd">&gt;</span></pre>
<pre><span class="lnum">   2:  </span><span class="kwrd">&lt;</span><span class="html">TiVoContainer</span></pre>
<pre class="alt"><span class="lnum">   3:  </span><span class="attr">xmlns</span><span class="kwrd">="http://www.tivo.com/developer/calypso-protocol-1.6/"</span><span class="kwrd">&gt;</span></pre>
<pre><span class="lnum">   4:  </span><span class="kwrd">&lt;</span><span class="html">Details</span><span class="kwrd">&gt;</span></pre>
</div>
<p>Notice on line 3 the xmlns tag. In our code, we can reference it with the c# code:</p>
<div class="csharpcode">
<pre class="alt"><span class="lnum">   1:  </span>XNamespace ns1 = http://www.tivo.com/developer/calypso-protocol-1.6/;</pre>
</div>
<p>Now we need to create a LINQ query to process the &lt;Item&gt; elements.</p>
<p>Here is what that Query looks like:</p>
<p><font color="#000000">1:</font>&#160; <span style="color: #0000ff">var</span><span style="color: #0000ff"> query =<br />
    <br /><font color="#000000">2:</font>&#160;&#160; </span><span style="color: #0000ff">from</span><span style="color: #0000ff"> item </span><span style="color: #0000ff">in</span><span style="color: #0000ff"> root.Descendants(ns1 + </span><span style="color: #2b91af">&quot;Item&quot;</span><span style="color: #0000ff">)<br />
    <br /><font color="#000000">3:</font>&#160;&#160; </span><span style="color: #0000ff">let</span><span style="color: #0000ff"> details = item.Element(ns1 + </span><span style="color: #2b91af">&quot;Details&quot;</span><span style="color: #0000ff">)<br />
    <br /><font color="#000000">4:</font>&#160;&#160; </span><span style="color: #0000ff">let</span><span style="color: #0000ff"> links = item.Element(ns1 + </span><span style="color: #2b91af">&quot;Links&quot;</span><span style="color: #0000ff">)<br />
    <br /><font color="#000000">5:</font>&#160;&#160; </span><span style="color: #0000ff">where</span><span style="color: #0000ff"> links.HasElements ==<br />
    <br /><font color="#000000">6:</font>&#160;&#160; </span><span style="color: #0000ff">true</span><span style="color: #0000ff"> &amp;&amp; links.Elements(</span><span style="color: #2b91af">&quot;CustomIcon&quot;</span><span style="color: #0000ff">) != </span><span style="color: #0000ff">null<br />
    <br /><font color="#000000">7:</font>&#160; </span><span style="color: #0000ff"></span><span style="color: #0000ff">select</span><span style="color: #0000ff"> </span><span style="color: #0000ff">new<br />
    <br /><font color="#000000">8:</font>&#160; </span><span style="color: #0000ff">{<br />
    <br /><font color="#000000">9:</font>&#160;&#160; Title = (</span><span style="color: #008000">String</span><span style="color: #0000ff">)details.Element(ns1 + </span><span style="color: #2b91af">&quot;Title&quot;</span><span style="color: #0000ff">),<br />
    <br /><font color="#000000">10:</font>&#160;&#160; Duration = (</span><span style="color: #008000">Int32</span><span style="color: #0000ff">)details.Element(ns1 + </span><span style="color: #2b91af">&quot;Duration&quot;</span><span style="color: #0000ff">),<br />
    <br /><font color="#000000">11:</font>&#160;&#160; Bytes = (</span><span style="color: #008000">Int64</span><span style="color: #0000ff">)details.Element(ns1 + </span><span style="color: #2b91af">&quot;SourceSize&quot;</span><span style="color: #0000ff">),<br />
    <br /><font color="#000000">12:</font>&#160;&#160; HighDefinition = </p>
<p><font color="#000000">13:</font>&#160;&#160; (</span><span style="color: #008000">String</span><span style="color: #0000ff">)details.Element(ns1 + </span><span style="color: #2b91af">&quot;HighDefinition&quot;</span><span style="color: #0000ff">),<br />
    <br /><font color="#000000">14:</font>&#160;&#160; IconUrl = </p>
<p><font color="#000000">15:</font>&#160;&#160; (</span><span style="color: #008000">XElement</span><span style="color: #0000ff">)links.Element(ns1 + </span><span style="color: #2b91af">&quot;CustomIcon&quot;</span><span style="color: #0000ff">)<br />
    <br /><font color="#000000">16:</font>&#160;&#160; };</span><span style="color: #0000ff"></span></p>
<p><span style="color: #000000">What this says is create an anonymous type called query (line 1). This object query is going to process the descendents of the Item tag.&#160; That is, what is between the &lt;item&gt; and &lt;/item&gt; tags.&#160; To do that, line 2 says &quot;from item in root.Descendants(..)&quot;.&#160; this means item is basically a variable and we are going to iterate through all the root.Descendants(..) of &quot;Item&quot;.&#160; The rest is just syntax.&#160; The goal is to create the &quot;var query&quot; which is really an enumeration of XML item elements.&#160; Our next step will be to use a simple foreach loop to run through that iteration.&#160; Before that, however, let&#8217;s look at the rest of the LINQ above and try to understand what it is doing.</span></p>
<p><span style="color: #000000">Line 3 and line 4 are let statements that assign the &lt;Details&gt; and &lt;Links&gt; to temporary variables.&#160; Line 5 says only include items where the element &lt;CustomIcon&gt; actually exists.&#160; This is necessary because there are some extra elements we want to skip over in the xm file.</span></p>
<p><span style="color: #000000">Finally, lines 7 through 16 are what creates the anonymous type which we can reference in our foreach statement when we iterate through query (which if you remember is enumerable).&#160; Basically, we are creating an anonymous type here that has the attributes: Title;Duration;Bytes;HighDefinition and IconUrl.&#160; These are dynamically created attributes of all different types (notice the casting to String,Int32,Int64 and XElement).</span></p>
<p><span style="color: #000000">Finally, we need to actually process this enumeration called query.&#160; The obvious way to process any enumeration is foreach.&#160; So, here goes:</span></p>
<div class="csharpcode">
<pre class="alt"><span class="lnum">   1:  </span><span class="kwrd">foreach</span> (var item <span class="kwrd">in</span> query)</pre>
<pre><span class="lnum">   2:  </span>{</pre>
<pre class="alt"><span class="lnum">   3:  </span>    <span class="kwrd">if</span> (item.IconUrl != <span class="kwrd">null</span>)</pre>
<pre><span class="lnum">   4:  </span>    {</pre>
<pre class="alt"><span class="lnum">   5:  </span>        <span class="kwrd">foreach</span> (XElement item1 <span class="kwrd">in</span> item.IconUrl.Nodes())</pre>
<pre><span class="lnum">   6:  </span>        {</pre>
<pre class="alt"><span class="lnum">   7:  </span>            <span class="kwrd">if</span> (item1.Name.LocalName.Equals(<span class="str">"Url"</span>))</pre>
<pre><span class="lnum">   8:  </span>            {</pre>
<pre class="alt"><span class="lnum">   9:  </span>                tivoShowInfoList.Add(</pre>
<pre><span class="lnum">  10:  </span>                <span class="kwrd">new</span> TivoShowInfo(</pre>
<pre class="alt"><span class="lnum">  11:  </span>                    item.Title,</pre>
<pre><span class="lnum">  12:  </span>                    item.Duration,</pre>
<pre class="alt"><span class="lnum">  13:  </span>                    item.Bytes,</pre>
<pre><span class="lnum">  14:  </span>                    item1.Value,</pre>
<pre class="alt"><span class="lnum">  15:  </span>                    item.HighDefinition.Equals(<span class="str">"Yes"</span>)</pre>
<pre><span class="lnum">  16:  </span>                    ? <span class="kwrd">true</span> : <span class="kwrd">false</span>)</pre>
<pre class="alt"><span class="lnum">  17:  </span>                );</pre>
<pre><span class="lnum">  18:  </span>            }</pre>
<pre class="alt"><span class="lnum">  19:  </span>        }</pre>
<pre><span class="lnum">  20:  </span>    }</pre>
<pre class="alt"><span class="lnum">  21:  </span>}</pre>
</div>
<p><span style="color: #0000ff"><span style="color: #000000">What we are doing here is iterating through the query and pulling apart the anonymous type attributes. Remembering that IconUrl was of type XElement, we are checking to see if that element is not null.&#160; If it is not null, we using another LINQ statement to iterate through it&#8217;s nodes, and if we find the node Url, we simply add to our generic collection of TivoShowInfo elements.&#160; That&#8217;s not a LINQ thing, but then we can operate on that generic collection with LINQ again to make up our graphs.&#160; The next several sections use this generic collection we just created.</span></span></p>
<h2>LINQ for Disk Usage By Recording Type</h2>
<p>Getting space by category uses the following LINQ to generate a generic list of KeyValuePairs.&#160; That is, we want a list that looks like:&#160; ShowCategory1;Percentage1 / ShowCategory2;Percentage2, etc.&#160; Here is the code that creates that followed by an explanation.</p>
<pre><font color="black">1:</font>&#160; <span style="color: #0000ff">public</span><span style="color: #0000ff"> </span><span style="color: #0000ff">static</span><span style="color: #0000ff"> </span><span style="color: #a31515">List</span><span style="color: #0000ff">&lt;</span><span style="color: #a31515">KeyValuePair</span><span style="color: #0000ff">&lt;</span><span style="color: #0000ff">string</span><span style="color: #0000ff">, </span><span style="color: #a31515">Int64</span><span style="color: #0000ff">&gt;&gt; <font color="black">2:</font>&#160;&#160; GetSpaceByCategory(</span><span style="color: #0000ff">string</span><span style="color: #0000ff"> xmlString)<font color="black">3:</font>&#160; {<font color="black">4:</font>&#160;&#160; </span><span style="color: #a31515">List</span><span style="color: #0000ff">&lt;</span><span style="color: #a31515">TivoShowInfo</span><span style="color: #0000ff">&gt; tivoShowInfoList = <font color="black">5:</font>&#160;&#160; GetTivoShowList(xmlString);

<font color="black">6:</font>&#160;&#160; </span><span style="color: #a31515">Int64</span><span style="color: #0000ff"> totalBytes = <font color="black">7:</font>&#160;&#160; (</span><span style="color: #0000ff">from</span><span style="color: #0000ff"> t </span><span style="color: #0000ff">in</span><span style="color: #0000ff"> tivoShowInfoList </span><span style="color: #0000ff">select</span><span style="color: #0000ff"> t.NumberBytes).Sum();

<font color="black">8:</font>&#160;&#160; </span><span style="color: #0000ff">var</span><span style="color: #0000ff"> categories =<font color="black">9:</font>&#160;&#160; </span><span style="color: #0000ff">from</span><span style="color: #0000ff"> s </span><span style="color: #0000ff">in</span><span style="color: #0000ff"> tivoShowInfoList<font color="black">10:</font>&#160;&#160; </span><span style="color: #0000ff">group</span><span style="color: #0000ff"> s </span><span style="color: #0000ff">by</span><span style="color: #0000ff"> s.ShowType </span><span style="color: #0000ff">into</span><span style="color: #0000ff"> g<font color="black">11:</font>&#160;&#160; </span><span style="color: #0000ff">select<font color="black">12:</font>&#160; </span><span style="color: #0000ff">        </span><span style="color: #0000ff">new<font color="black">13:</font>&#160; </span><span style="color: #0000ff">        {<font color="black">14:</font>&#160;&#160; ShowType1 = g.Key,<font color="black">15:</font>&#160;&#160; TotalBytes = g.Sum(s =&gt; s.NumberBytes)<font color="black">16:</font>&#160;&#160; };

<font color="black">17:</font>&#160;&#160; </span><span style="color: #a31515">List</span><span style="color: #0000ff">&lt;</span><span style="color: #a31515">KeyValuePair</span><span style="color: #0000ff">&lt;</span><span style="color: #0000ff">string</span><span style="color: #0000ff">, </span><span style="color: #a31515">Int64</span><span style="color: #0000ff">&gt;&gt; kvpList = <font color="black">18:</font>&#160;&#160; </span><span style="color: #0000ff">new</span><span style="color: #0000ff"> </span><span style="color: #a31515">List</span><span style="color: #0000ff">&lt;</span><span style="color: #a31515">KeyValuePair</span><span style="color: #0000ff">&lt;</span><span style="color: #0000ff">string</span><span style="color: #0000ff">, </span><span style="color: #a31515">Int64</span><span style="color: #0000ff">&gt;&gt;();<font color="black">19:</font>&#160;&#160; </span><span style="color: #0000ff">foreach</span><span style="color: #0000ff"> (</span><span style="color: #0000ff">var</span><span style="color: #0000ff"> c </span><span style="color: #0000ff">in</span><span style="color: #0000ff"> categories)<font color="black">20:</font>&#160;&#160; {<font color="black">21:</font>&#160;&#160; </span><span style="color: #a31515">Int64</span><span style="color: #0000ff"> val = (</span><span style="color: #a31515">Int64</span><span style="color: #0000ff">)c.TotalBytes;

<font color="black">22:</font>&#160;&#160; </span><span style="color: #a31515">KeyValuePair</span><span style="color: #0000ff">&lt;</span><span style="color: #0000ff">string</span><span style="color: #0000ff">, </span><span style="color: #a31515">Int64</span><span style="color: #0000ff">&gt; kvp = <font color="black">23:</font>&#160;&#160; </span><span style="color: #0000ff">new</span><span style="color: #0000ff"> </span><span style="color: #a31515">KeyValuePair</span><span style="color: #0000ff">&lt;</span><span style="color: #0000ff">string</span><span style="color: #0000ff">, </span><span style="color: #a31515">Int64</span><span style="color: #0000ff">&gt;(c.ShowType1, val);<font color="black">24:</font>&#160;&#160; kvpList.Add(kvp);<font color="black">25:</font>&#160;&#160; }<font color="black">26:</font>&#160;&#160; </span><span style="color: #0000ff">return</span><span style="color: #0000ff"> kvpList;<font color="black">27:</font>&#160; }</span></pre>
<p>&#160;</p>
<p>What is happening here is we are using the Generic collection (List) of TivoShowInfo to act as our LINQ source.&#160; We get this by calling the method GetTivoShowList on line 4 above. </p>
<p>The first thing we do (which is not really related to the big sort) is to simply get the total bytes stored on the TiVo.&#160; We do this by simply iterating over the generic List (tivoShowInfoList) with the command on line 7 (from t in tivoShowInfoList).&#160; The select creates an anonymous return type of t.NumberBytes.&#160; Essentially, behind the scenes, an anonyomous delegate is created that takes in t (the tivoShowInfoList list item) and returns an integer (t.NumberBytes) which is the size of the show in bytes.&#160; Then, by putting that all in ()&#8217;s creates an enumerated type.&#160; Since the enumerated type has an extension method associated with it called Sum(), we can call this and the return value will essentially Sum the values of NumberBytes for each entry.</p>
<p>Next, we need to perform a GroupBy function to get separate totals for each ShowType.&#160; to do this, we again iterate over the generic List in line 8.&#160; This time, we add line 10 which creates a group s by the show type.&#160; The anonymous delegate that is created has the key of the group by and also the number of bytes.&#160; The syntax s =&gt; s.NumberBytes on line 15 simply means create a delegate that takes in the parameter s (which is showtype group) and return the number of bytes of the item.&#160; Sum (in line 15) of course totals those bytes.</p>
<p>Finally, we iterate through the collection on lines 19 to create the KeyValuePair we will be returning.</p>
<p>&#160;</p>
<h2>LINQ for Disk Usage By High Def Verses Low Def</h2>
<p>The method GraphBarByHighDef is used to get this data.&#160; Below is the LINQ code used for this.</p>
<pre><font color="black">1:</font>&#160; <span style="color: #0000ff">var</span><span style="color: #0000ff"> query = (</span><span style="color: #0000ff">from</span><span style="color: #0000ff"> tivoList </span><span style="color: #0000ff">in</span><span style="color: #0000ff"> listTivoShowInfo<font color="black">2:</font>&#160;&#160; </span><span style="color: #0000ff">select</span><span style="color: #0000ff"> </span><span style="color: #0000ff">new<font color="black">3:</font>&#160; </span><span style="color: #0000ff">             {<font color="black">4:</font>&#160;&#160; tivoList.ShowType<font color="black">5:</font>&#160;&#160; }).Distinct();

<font color="black">6:</font>&#160; </span><span style="color: #008000">List</span><span style="color: #0000ff">&lt;</span><span style="color: #0000ff">string</span><span style="color: #0000ff">&gt; showTypeStringList = </span><span style="color: #0000ff">new</span><span style="color: #0000ff"> </span><span style="color: #008000">List</span><span style="color: #0000ff">&lt;</span><span style="color: #0000ff">string</span><span style="color: #0000ff">&gt;();<font color="black">7:</font>&#160; </span><span style="color: #0000ff">foreach</span><span style="color: #0000ff"> (</span><span style="color: #0000ff">var</span><span style="color: #0000ff"> val </span><span style="color: #0000ff">in</span><span style="color: #0000ff"> query)<font color="black">8:</font>&#160; {<font color="black">9:</font>&#160;&#160; </span><span style="color: #ff00ff">//string str = ShortenContentType(val.ShowType);<font color="black">10:</font>&#160; </span><span style="color: #0000ff">    showTypeStringList.Add(val.ShowType);<font color="black">11:</font>&#160; }

<font color="black">12:</font>&#160; </span><span style="color: #0000ff">string</span><span style="color: #0000ff">[] contentTypeList = </span><span style="color: #0000ff">new</span><span style="color: #0000ff"> </span><span style="color: #0000ff">string</span><span style="color: #0000ff">[showTypeStringList.Count];<font color="black">13:</font>&#160; </span><span style="color: #0000ff">double</span><span style="color: #0000ff">[] hdSize = </span><span style="color: #0000ff">new</span><span style="color: #0000ff"> </span><span style="color: #0000ff">double</span><span style="color: #0000ff">[showTypeStringList.Count];<font color="black">14:</font>&#160; </span><span style="color: #0000ff">double</span><span style="color: #0000ff">[] sdSize = </span><span style="color: #0000ff">new</span><span style="color: #0000ff"> </span><span style="color: #0000ff">double</span><span style="color: #0000ff">[showTypeStringList.Count];

<font color="black">15:</font>&#160; </span><span style="color: #0000ff">int</span><span style="color: #0000ff"> cnt = 0;<font color="black">16:</font>&#160; </span><span style="color: #0000ff">foreach</span><span style="color: #0000ff"> (</span><span style="color: #0000ff">string</span><span style="color: #0000ff"> s </span><span style="color: #0000ff">in</span><span style="color: #0000ff"> showTypeStringList)<font color="black">17:</font>&#160; {<font color="black">18:</font>&#160;&#160; contentTypeList[cnt] = ShortenContentType(s);<font color="black">19:</font>&#160;&#160; </span><span style="color: #0000ff">var</span><span style="color: #0000ff"> totalHDList = </span><span style="color: #0000ff">from</span><span style="color: #0000ff"> tivoList </span><span style="color: #0000ff">in</span><span style="color: #0000ff"> listTivoShowInfo<font color="black">20:</font>&#160;&#160; </span><span style="color: #0000ff">where</span><span style="color: #0000ff"> tivoList.ShowType.Equals(s) &amp;&amp;<font color="black">21:</font>&#160;&#160; tivoList.HighDefinition<font color="black">22:</font>&#160;&#160; </span><span style="color: #0000ff">select</span><span style="color: #0000ff"> </span><span style="color: #0000ff">new<font color="black">23:</font>&#160; </span><span style="color: #0000ff">                      {<font color="black">24:</font>&#160;&#160; Bytes = tivoList.NumberBytes<font color="black">25:</font>&#160;&#160; };

<font color="black">26:</font>&#160;&#160; hdSize[cnt] = <font color="black">27:</font>&#160;&#160; </span><span style="color: #008000">Convert</span><span style="color: #0000ff">.ToInt32(</span><span style="color: #008000">Convert</span><span style="color: #0000ff">.ToInt64(totalHDList.Sum(p =&gt; p.Bytes))<font color="black">28:</font>&#160;&#160; / INT_Constant_Billion);<font color="black">29:</font>&#160;&#160; </span><span style="color: #0000ff">var</span><span style="color: #0000ff"> totalSDList = </span><span style="color: #0000ff">from</span><span style="color: #0000ff"> tivoList </span><span style="color: #0000ff">in</span><span style="color: #0000ff"> listTivoShowInfo<font color="black">30:</font>&#160;&#160; </span><span style="color: #0000ff">where</span><span style="color: #0000ff"> tivoList.ShowType.Equals(s) &amp;&amp; <font color="black">31:</font>&#160;&#160; !tivoList.HighDefinition<font color="black">32:</font>&#160;&#160; </span><span style="color: #0000ff">select</span><span style="color: #0000ff"> </span><span style="color: #0000ff">new<font color="black">33:</font>&#160; </span><span style="color: #0000ff">                      {<font color="black">34:</font>&#160;&#160; Bytes = tivoList.NumberBytes<font color="black">35:</font>&#160;&#160; };

<font color="black">36:</font>&#160;&#160; sdSize[cnt] = <font color="black">37:</font>&#160;&#160; </span><span style="color: #008000">Convert</span><span style="color: #0000ff">.ToInt32(</span><span style="color: #008000">Convert</span><span style="color: #0000ff">.ToInt64(totalSDList.Sum(p =&gt; p.Bytes))<font color="black">38:</font>&#160;&#160; / INT_Constant_Billion);<font color="black">39:</font>&#160;&#160; cnt++;<font color="black">40:</font>&#160; }</span></pre>
<p>&#160;</p>
<p>The strategy here is to first generate a unique list of ShowTypes.&#160; Just like for the sum operation in the previous section, we want to create an enumeration of ShowType&#8217;s and from that, we want to call the Distinct (line 5) function to get the unique list.&#160; Again, the enumeration created is basically a full list of just ShowType&#8217;s for all the TiVo listings, and Distinct just gives us those that are unique.&#160; We need this because we want to create one bar for each ShowType.&#160; Our foreach (line 7 to 10) simply creates a generic List of ShowTypes we can iterate through (which we do on line 16).</p>
<p>Our objective is to create a string array of ShowType&#8217;s, a corresponding double array of High Def Sum&#8217;s and a double array of standard def Sums&#8217;s.&#160; We do this one ShowType at a time (hence the foreach loop on line 16.&#160; Line 18 extracts a nice short name of the ShowType (that is, urn:tivo:image:expired-recording turns into Expired).&#160; Then, line 19 simply says iterate through the entire collection of shows and only look at show&#8217;s of the type we are interested in (line 20) and return just the NumberBytes of that show (line 24).&#160; Line 26-27 simply totals that collection and stores the value in the&#160; array of doubles for High Definition.&#160; Lines 29-38 does the same thing for standard definition.&#160; Notice on lines 27 and 37, the expression p=&gt;p.Bytes is the new syntax for create an anonymous delegate that takes p in as a parameter and returns an integer p.Bytes.</p>
<p>&#160;</p>
<h2>LINQ for Simple Listing of Shows</h2>
<p>Creating a listing is the simplest thing of all to do with link.&#160; Here is the LINQ code.</p>
<pre><font color="black">1:</font>&#160; <span style="color: #0000ff">///</span><span style="color: #0000ff"> </span><span style="color: #0000ff">&lt;summary&gt;<font color="black">2:</font>&#160; ///</span><span style="color: #0000ff"> Generate a simple listing of all shows with space<font color="black">3:</font>&#160; </span><span style="color: #0000ff">///</span><span style="color: #0000ff"> </span><span style="color: #0000ff">&lt;/summary&gt;<font color="black">4:</font>&#160; </span><span style="color: #000000">private</span><span style="color: #808080"> </span><span style="color: #000000">void</span><span style="color: #808080"> ShowTivoListings(</span><span style="color: #000000">string</span><span style="color: #808080"> xmlString)<font color="black">5:</font>&#160; {<font color="black">6:</font>&#160;&#160; </span><span style="color: #a31515">List</span><span style="color: #808080">&lt;</span><span style="color: #a31515">TivoShowInfo</span><span style="color: #808080">&gt; listTivoShowInfo = <font color="black">7:</font>&#160;&#160; </span><span style="color: #a31515">TivoUtils</span><span style="color: #808080">.GetTivoShowList(xmlString);<font color="black">8:</font>&#160;&#160; </span><span style="color: #000000">var</span><span style="color: #808080"> query = </span><span style="color: #000000">from</span><span style="color: #808080"> tivoList </span><span style="color: #000000">in</span><span style="color: #808080"> listTivoShowInfo<font color="black">9:</font>&#160;&#160; </span><span style="color: #000000">orderby</span><span style="color: #808080"> tivoList.Title<font color="black">10:</font>&#160;&#160; </span><span style="color: #000000">select</span><span style="color: #808080"> tivoList;

<font color="black">11:</font>&#160;&#160; </span><span style="color: #000000">foreach</span><span style="color: #808080"> (</span><span style="color: #000000">var</span><span style="color: #808080"> item </span><span style="color: #000000">in</span><span style="color: #808080"> query)<font color="black">12:</font>&#160;&#160; {<font color="black">13:</font>&#160;&#160; </span><span style="color: #000000">double</span><span style="color: #808080"> gigabytes = <font color="black">14:</font>&#160;&#160; </span><span style="color: #a31515">Convert</span><span style="color: #808080">.ToDouble(<font color="black">15:</font>&#160;&#160; </span><span style="color: #a31515">Convert</span><span style="color: #808080">.ToDouble<font color="black">16:</font>&#160;&#160; (item.NumberBytes / <font color="black">17:</font>&#160;&#160; </span><span style="color: #a31515">Convert</span><span style="color: #808080">.ToDouble(INT_Constant_Billion)));

<font color="black">18:</font>&#160;&#160; </span><span style="color: #000000">string</span><span style="color: #808080"> displayString = <font color="black">19:</font>&#160;&#160; </span><span style="color: #a31515">String</span><span style="color: #808080">.Format(</span><span style="color: #ffff00">&quot;Size: {0:n} Status: {1} Title: {2}&quot;</span><span style="color: #808080">,<font color="black">20:</font>&#160;&#160; gigabytes,<font color="black">21:</font>&#160;&#160; ShortenContentType(item.ShowType),<font color="black">22:</font>&#160;&#160; item.Title);

<font color="black">23:</font>&#160;&#160; listBoxTivoListings.Items.Add(displayString);<font color="black">24:</font>&#160;&#160; }<font color="black">25:</font>&#160;&#160; SetSize();<font color="black">26:</font>&#160; }</span></pre>
<p>&#160;</p>
<p>Lines 6 and 7 get the Generic Collection just as in the two other displays.&#160; Lines 8 to 10 create the LINQ enumeration query which is ordered by Title and simply selected the entire record.&#160; lines 11 through 24 just iterate over the entire collection returned from the above LINQ expression.</p>
<h2>Remarks</h2>
<p>As I mentioned in the start, my only intent in this article is to explain the LINQ in this application.&#160; The forms program used to create this program, for me, is just a holder of LINQ objects.&#160; It would be great to see someone take what I&#8217;ve done and convert it to a WPF application.&#160; Including drill downs and better graphics whould be awesome.&#160; Who knows, this may be the start of an open source project.</p>
<h2>Thanks</h2>
<p>First, thanks to Mike Swanson for inspiring this application and doing the hard work of figuring out what is really going on with the TiVo on the local net.&#160; Without that, this would not have been possible.&#160; Second, thanks to Fabrice Marguerie, author of Manning&#8217;s book &quot;LINQ in Action&quot;.&#160; Fabrice tirelessly answered several of my very naive questions I posted on the internet forums.</p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:7dc1bd33-94bd-46fd-a20b-0131235bcd47:1ff45d80-ab57-4045-b0f3-e0280d6bc574" class="wlWriterSmartContent">
<table border="0" cellspacing="0" cellpadding="2" width="400">
<tbody>
<tr>
<td valign="top" width="400">
<p><a title="Amazon.com: LINQ in Action" href="http://www.amazon.com/exec/obidos/ASIN/1933988169/petkelsblo-20"><img border="0" align="left" src="http://images.amazon.com/images/P/1933988169.01.MZZZZZZZ.jpg" />Amazon.com: LINQ in Action</a></p>
</td>
</tr>
</tbody>
</table>
</div>
<p>&#160;</p>
<p>&#160;</p>
<h2>Appendix:&#160; How To Install and Run this TiVo Program</h2>
<p>If you just want to run the program and don&#8217;t care about all this LINQ stuff, here is what you have to do.</p>
<p>First, you need to get three things about your TiVo</p>
<p>1.&#160; It&#8217;s IP address.&#160; This can be found by navigating your TiVo to Message &amp; Settings, then Settings, then Phone and Network.</p>
<p>2.&#160; Your Media Access Key:&#160; Navigate to Message and Settings, then Account and System Information, then Media Access Key</p>
<p>3.&#160; Your TiVo Service Number: Navigate to Message and Settings, then Account &amp; System Information.</p>
<p>After you&#8217;ve done this, copy the files from the attached zip file</p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px" id="scid:fb3a1972-4489-4e52-abe7-25a00bb07fdf:a9a3dcb9-05ec-477c-a1ba-e69296ce5533" class="wlWriterSmartContent">
<p>Tivo Space Viewer Executable Files <a href="http://peterkellner.net/wp/wp-content/uploads/2008/01/tivosummaries.zip" target="_blank">Tivo Space Viewer Exe</a></p>
</div>
<p>to your desktop (Just drag and drop them to your windows or XP desktop.</p>
<p>The final thing to do is to add your Service number to your hosts file located at %SystemRoot%\system32\drivers\etc\hosts.</p>
<p>add a line for your TiVo Service number and IP as is shown in the following picture.</p>
<p><a title="TiVo Setup Screen on XP" href="http://peterkellner.net/misc/tivosetup.jpg">TiVo Setup Screen on XP</a></p>
<p><a href="http://peterkellner.net/wp/wp-content/uploads/2008/01/tivosetup.jpg"><img style="border-right-width: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" border="0" alt="tivosetup" src="http://peterkellner.net/wp/wp-content/uploads/2008/01/tivosetup-thumb.jpg" width="244" height="182" /></a></p>
<p>That&#8217;s it!&#160; click on TivoSummaries on your desktop.&#160; If this doesn&#8217;t work, I suggest getting <a href="http://blogs.msdn.com/mswanson/archive/2007/12/02/tivo-gadget-for-vista.aspx">Mike&#8217;s gadget</a> working, then trying this procedure again.</p>
]]></content:encoded>
			<wfw:commentRss>http://peterkellner.net/2008/01/18/tivospaceviewerwithlinq/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic
Page Caching using disk: enhanced (User agent is rejected)
Database Caching 11/35 queries in 0.012 seconds using disk: basic
Content Delivery Network via Amazon Web Services: S3: PetersBlogCDN.s3.amazonaws.com

Served from: peterkellner.net @ 2012-05-23 00:36:01 -->
