Whisst RSS feed for Google Screensaver

by Jeff Alexander 6. April 2010 20:04

I've been busy all over the place trying to fill in some gaps in my knowledge for job interviews and I have another post to make about an application I'm working on to help make posting pictures to Facebook easier for my wife, Beccah, but that is still in progress. This was a quick and dirty implementation of an idea I had that I figured I should post...

I wanted to put a screen saver on my wife's netbook that would display pictures from our Windows Home Server and Google has a very nice screen saver that will do just that. When I installed it I noticed you could add RSS feeds to the screen saver and have it use a feed for the images source. That got me thinking that I could get the Grandma's setup with a screen saver to see pictures without having to download the pictures to their computers. But how would I source the feed?

Before Facebook was the main vehicle letting family see photo's of our 2 boys, I put together a Wordpress blog and installed the ZenPhoto photo gallery. My first thought for the Google screen saver was to put in a feed to those albums but it turns out Google is utilizing the Yahoo Media RSS specification and the feed generated by ZenPhoto isn't following that spec. Rather than devote my time to re-writing the ZenPhoto PHP feed generation code, I decided to take a different approach.

There is an awesome add-in to Windows Home Server call Whisst written by Adrew Grant that allows you to create public or private web pages served by your Windows Home Server. It's a very handy tool to test out ASP.Net web pages I'm working on, and make other pages available to family. If I need to share a large file with family sometimes I will make a quick web page and give them the directions to download and install on the page and serve it publicly. Whisst allows me to do this quickly and easily. Another feature of Whisst is that you can pick a folder of images and it will create a nice html wrapper around it to display the images. It's another easy way to let family see pictures and it's nice that it can be password protected if you want.

I remembered looking at the html wrapper code for Whiist at one point to see what it was doing and was pretty sure I could enhance what it was doing to serve an RSS Feed. I was going to see the Grandma's on Easter so I wanted to put this together quickly before I left. I didn't want to mess with the IIS config to make a handler for xml so I figured I would create an aspx page that would just return the xml feed but then I found an article about using an ashx handler instead so you don't have the overhead of instantiating a page.

I figured that someone somewhere had written an RSS Feed generator for .NET and I found the ASP.NET RSS Toolkit on CodePlex. The toolkit didn't have a built in class for generating media feeds but it does have a tool that will let you generate a class from a feed so I decided to try to generate a media feed class based off of a working media feed. The Google screen saver listed SmugMug as someone who generates photo feeds and I have a college buddy that works for SmugMug named Chris Abbey. I used his feed (thanks Chris) to generate a class to use with the RSS Toolkit and tweaked the parts it guessed wrong to get a nice class I can use with the RSS toolkit to generate my RSS Feed.

Again this was going to be a quick and dirty exercise so I could get it up and running and perhaps tweak it later. For now all the code in the handler is doing is finding all the .jpg's in the current folder and randomly picking at most 100 of them and generating a feed from those. I'm still unsure how the feed reading and updating is implemented in the Google screen saver but I did read that it didn't seem to look past the first 100 and didn't like to reload the feed. I think 100 random photo's on each feed load will work for now.

I created a folder in my photo's share called RSS and put copies of the photo's I wanted to create a feed for in there. I then used Whisst to create a public page called pictures for the RSS folder. I then copied over my rss.ashx file and the assembly and it worked. Both the Grandma's and our 2 laptops have the Google screen saver setup to feed from the Windows Home Server for the screen saver. All I needed to do was add http://myWHSName.homeserver.com/pictures/rss.ashx to set it up.

I will attach the project (or at least the files) to this post in the future but if anyone wants it before that happens let me know. In the future I should add in support for the image size and dimensions for the feed and maybe add some query string parameters. But I was just happy I was able to get it up and working in an evening and the Google screen saver doesn't seem to mind the rather bare feed.

-Jeff

 

 

Tags: ,

C# | Projects

Image Renamer Project

by Jeff Alexander 8. January 2010 00:38

Back when the .Net framework was just turning 1.1 I was asked to work on the first C# application by my employer which was mainly a C++ Win32 API shop. I was excited and read a couple C# books but I needed a project for it to really sink in. The quick project I started was a WinForms application to rename my digital photos. I was using a free utlity but wanted to make an application that did just what I wanted.

The reason I wanted to rename digital camera photos was that I bought a network enabled hard drive and started copying all my photos over to it and made a horrible mistake!!! It seems that at one point the photo counter on my digital camera was reset. So when I started to copy a very large list of photos over I was presented with the question do you want to replace ones with the same filename? I had just selected a huge list of photos and just assumed that one or two of them overlapped and figured I would just let those few get re-copied and said to replace. It wasn't until I watched the whole thing progress to 100% until I realized that I probably just lost a ton of pictures since they had the same filename. Ughh...

That's when I decided to start renaming all my photos so that it doesn't happen again. I take the EXIF data and put the date and time the photo was taken in front of the filename. That way if the IMG1234.jpg part overlaps the date, hour, minutes, seconds will not. The best side effect of that is that when you print your digital photos at a lab they put the filename on the back of the photo and you have a cool way to tell when you took the picutre. I wrote a whole blog post about it at AskTheAdmin.com.

The Project:

I found some code to read the EXIF and put together a little WinForms application with a listView a progress bar and a rename button. Worked fine. My EXIF reader was a little slow but who cares it works right? I was a nice starter application, I used it to put together a UI in WinForms, and write some threaded code to keep the UI from getting blocked on long rename's and overall it was a good experience.

Over time I've changed the thread code to use a BackgroundWorker to play around with how it works and I've changed around the EXIF reader a few times to make it faster and try new things as the .Net Framework added image support.

Updates Round 1:

It was kind of a pain to pop in the memory card out of the camera, copy it to the server and rename them. It wasn't horrible but it wasn't quick and easy. I thought about writing something that would register itself as a handler so that the auto play might bring up an option that would copy them from the card to the server for me but after some research it felt like a lot of work and I don't always have that much time. After some thought I decided one way to make it easier would be that if I could pop the SD card in and just copy them to the server and have Windows Home Server do the rest for me. In hindsight I think the amount of work to do that was probably the same.

To do this I wrote a Windows service to delpoy on my Windows Home Server that would watch a directory and rename any files that came in and move them to the photos directory. Pretty straight forward, the only gotcha was that a FileWatcher gives you a Create notify as soon as the file shows up but it still may be in the process of copying and you can't read it until it's done. I ended up writing a simple wait loop that would test if it could open for read and wait to process that until it could.

Now all I had to do was copy the files to the server and they were renamed.

Updates Round 2:

At this point I built my own Windows Home server was using that to store my photos but the folder for my photo's was large, I mean really large. When I was just storing them for backup I didn't care how many there were but my wife hated trying to navigate 1 huge folder on her little netbook. So I broke out the pictures by the year they were taken in which was pretty easy since the first part of each photo had the year. But now the renamer service needed to be updated.

I was storing the folder locations in the Resouces segment of the application and now I needed to update that. I wanted to be able to adjust my settings easily and have the year folder copy done automatically. I wanted to be able to configure the Windows service settings from the settings page in the Windows Home Server console rather than write a little configuration dialog for the renamer service.

I found a template for Windows Home Server Add-Ins and it was simple to write a settings tab. Next I broke out the Resouces to an external XML file that I store in CommonApplicationData and now both the service and the Windows Home Server settings page read and update that xml file.

Now I'm able to Start/Stop the Windows service, update the watch directory/output directory from the Home Server console anywhere. I can even upload files remotely and have them sorted to the right folder.

What's next?

  • WPF

I have never really used WPF and I am currently moving the Rename UI to be a WPF application. The first thing I did was to throw away the BackgroundWorker code since all I have to do is bind the listView to an ObservableCollection and the list updating is handled automatically.

  • Unit testing

I have never been required to write unit tests at work. I have done a little bit of Test Driven Desgin and used unit tests in my existing code but I want to really sit down and start using proper tests. I'll try to write myself a blog post about it later. (Since I'm most likely the only one reading this blog...)

  • Auto Play agent

I still want my wife to be able to pop in the memory card and have the handler give her an option to move the files to the server and if she isn't attached copy them locally. This will require looking into registering file formats with autoplay and showing here a nice little WPF application to do the copy.

  • Installer

If my Windows Home Server should fail I would have to manually install the Windows service and Home Server Add-In on re-install. It would be a good Idea to write a quick installer for the add-in. That way when I rebuild the server it will still be in the add-in folder and I can just re-activate it and configure it within the Home Server.

Conclusion:

If you still reading this wall of text I guess I should say thanks. If you have any interest in the source code or how I did anything post a comment or send me an email and I'll try to answer. And my advice to learning something new is to try to find a reason to use it and go through the process that way.

-Jeff

Tags: , , , ,

ImageRenamer | Projects

Powered by BlogEngine.NET 1.5.0.7
Theme by Mads Kristensen Modified by Jeff Alexander