Sunday 17 April 2011

Windows 7 Media Center: Recorded TV Movies and DVD images in (and only in) Movie library


I have hundreds of films recorded off the TV and a fair few movies on DVD. This makes finding and viewing TV programs and series slow and cluttered. I needed a solution that would allow these films to all appear in (and only in) the “Movies” browser and hopefully allow me to fetch missing meta-data. This needed to work on media centre extenders as I have this kit:
1 Custom built PC with 3TB of storage, 3 DVBT tuners, Windows 7
4 Linksys DMA2100 extenders (latest firmware)
This setup means I don’t have to worry about the noise of the main PC and I get the flexibility to watch recorded programs and listen to music anywhere I might want to in the house relatively inexpensively. It is fairly common for us to start watching something in the kitchen while clearing up after our evening meal and then finish watching it in the lounge (so the resume feature is great).
It turns out this is a bit of a mission to accomplish.
For the impatient and tech savvy you could just download this: http://andy.boura.co.uk/downloads/MoveRecordedTvMovies.exe and this:http://babgvant.com/files/folders/misc/entry5687.aspx (run without parameters for some basic help) and figure the rest out yourself in order to accomplish the TV movies bit...alternatively read on below…

Challenge 1: DVD playback on extenders

After a fair bit of digging I came up with the following solution:
  1. Rip the DVD or bypass the copy protection (if your countries legal system allows)
    Free option: DVD Shrink 
    – works very well
    - check the checksum when you download as the downloads not available from the central location
    http://www.dvdshrink.org/what_en.php
    Commercial option: AnyDVD (HD):- works very well
    - works at the device driver level so can simplify workflow of other programs
    - expensive with lifetime licence costing 109 euro
    http://www.slysoft.com/en/anydvdhd.html
  2. Create a folder with the name and year of release of the film you are copying
  3. Create a dvr-ms version of the DVD in this folder
    Free option: DVRMS Toolbox (toDVRMS etc…)

    - a bit of a learning curve to get it working
    - I didn’t have time to fully figure it out (joining VOBS for example) but perhaps you do….
    http://babgvant.com/files/folders/dvrmstoolbox/default.aspx
    Commercial option: VideoRedo
    - works well and is easy to use
    - in conjunction with AnyDVD can do a single stage conversion
    - Fairly expensive at $75
    http://www.videoredo.com
  4. Get the meta data for the filmThere are several free options here. They each work somewhat differently so it’s probably worth you experimenting a bit and deciding which you like best:
    My Movieshttp://www.mymovies.dk/
    Yammmhttp://thegreenbutton.com/forums/p/73390/359121.aspx
    - DVD Library Managerhttp://thegreenbutton.com/forums/p/73390/359121.aspx
    Personally I found My Movies to have the most complete movie information and although some of the features require a purchase of points or contribution of meta data I believe the free version is sufficient for the basic meta data retrieval. I haven’t yet figured out how to correct things if it’s decided on the wrong version of a particular film…
  5. At this point my DVD (without interactive features and menus!) is available on my PC and extenders via the “Movies” section of Windows 7 media center and also through the “My Movies” plug-in. If you want interactive DVD menus you can only do it on the PC not the extenders but I did get this working:
    - DVD image using DVDShrink into a folder called DVD Movies
    -- Make this folder available in Media Center’s library
    - Follow process as above called DVD Movies (transcoded)
    -- Add this folder on the extenders but not the PC
I messed about with the various real-time transcoders but found it unreliable and certain functionality like resume and moving about within the film was either temperamental or not supported. I also realised that life’s too short for the extra features and waiting for menus anyway – I’d rather just play the movie!
I’m also not bothered about the MS format lock-in thing – there’s plenty of command line tools will convert dvr-ms into more open standards so I just set it going for however long it takes if / when the need arises. In the mean time I’ll have a working system thank you…

Challenge 2: Getting Recorded TV Movies to appear in (and only in) my “Movies” section (and update / correct meta data as required)


I was sure someone would have solved this but I looked everywhere and only found people with the problem and not the solution! Having managed to get my dvr-ms version of DVDs to show up in my movies (and not recorded tv / videos) I was sure it could be done. From reading on the forums (theGreenButton in particular) I had determined that TV movies have a meta data flag identifying them as such so that Media Center knows to give them special treatment. I found a meta data viewer / editor that allowed me to peak at the various fields available / used ( http://blogs.msdn.com/toub/archive/2005/05/12/416874.aspx ).
I then started looking for a command line program that would allow me to write a simple batch file to move the correct dvr-ms / wtv files into a “TV Movies” folder, and create appropriately named container folders for the fetching of meta data. I hunted around a bit at found a few bits but nothing looked particularly simple but I did come across the dvrms.dll ( http://babgvant.com/files/folders/misc/entry5687.aspx ). This would allow me to programmatically access the fields I require and create the appropriate folders automatically. So I dusted of visual studio and set to work…there’s various bits of bootstrap and paraphernalia around it but the core of the program is pretty simple. I don’t expect it will win any awards for pretty code but I it suits my needs (feel free to skip passed if code isn’t your thing!). The complete source code snippet is below and should serve as an example of how to do this stuff – just create a C# command line project to stick it in:
   1: using System;
   2: using System.Collections.Generic;
   3: using System.Linq;
   4: using System.Text;
   5: using System.IO;
   6:  
   7: using Toub.MediaCenter.Dvrms.Metadata;
   8:  
   9: namespace MoveRecordedTVMovies
  10: {
  11:     class Program
  12:     {
  13:         static void Main(string[] args)
  14:         {
  15:             DirectoryInfo inDir, outDir;
  16:             List<FileInfo> files = new List<FileInfo>();
  17:  
  18:             if (args.Length < 2)
  19:             {
  20:                 Console.WriteLine("RecordedTvMovies <source folder> <target folder> [pause]");
  21:                 Console.WriteLine("<source folder>:\nThe folder to find the .wtv and .dvr-ms files in (normally this will be your Recorded TV folder)\n");
  22:                 Console.WriteLine("<target folder>:\nThe folder to create the individual movie folders in\n");
  23:                 Console.WriteLine("[pause]: \nEnter without square brackets to cause execution to halt until you press a key on error");
  24:                 Console.ReadKey();
  25:                 return;
  26:             }
  27:  
  28:             bool pauseOnError = (args.Length > 2) ? args[2] == "pause" : false;
  29:  
  30:             try
  31:             {
  32:                 inDir = new DirectoryInfo(args[0]);
  33:                 outDir = new DirectoryInfo(args[1]);
  34:  
  35:                 files.AddRange(inDir.GetFiles("*.wtv"));
  36:                 files.AddRange(inDir.GetFiles("*.dvr-ms"));
  37:             }
  38:             catch(Exception ex)
  39:             {
  40:                 Console.WriteLine("Couldn't open folder: " + args[0]);
  41:                 Console.WriteLine(ex);
  42:                 if (pauseOnError) Console.ReadKey();
  43:                 return;
  44:             }
  45:  
  46:             Console.WriteLine("Found " + files.Count.ToString() + " .wtv and .dvr-ms files");
  47:  
  48:             foreach(FileInfo fi in files)
  49:             {
  50:                 try
  51:                 {
  52:                     using (DvrmsMetadataEditor ed = new Toub.MediaCenter.Dvrms.Metadata.DvrmsMetadataEditor(fi.FullName))
  53:                     {
  54:                         bool isMovie = GetMeta(ed, "WM/MediaIsMovie") == "True";
  55:                         Console.WriteLine(isMovie.ToString() + ": " + GetMeta(ed, "Title") + " (" + GetMeta(ed, "WM/OriginalReleaseTime") + ")");
  56:  
  57:                         if (isMovie)
  58:                         {
  59:                             try
  60:                             {
  61:                                 DirectoryInfo movieDir = outDir.CreateSubdirectory(MovieFolderName(ed));
  62:                                 fi.MoveTo(movieDir.FullName + "/" + fi.Name);
  63:                             }
  64:                             catch (Exception ex)
  65:                             {
  66:                                 Console.WriteLine("Couldn't create folder and move movie: " + MovieFolderName(ed) + "/" + fi.Name);
  67:                                 Console.WriteLine(ex);
  68:                                 if(pauseOnError) Console.ReadKey();
  69:                             }
  70:                         }
  71:                     }
  72:                 }
  73:                 catch (Exception ex)
  74:                 {
  75:                     Console.WriteLine("Couldn't access meta data for: " + fi.Name);
  76:                     Console.WriteLine(ex);
  77:                     if (pauseOnError) Console.ReadKey();
  78:                 }
  79:             }
  80:        }
  81:  
  82:         static string GetMeta(Toub.MediaCenter.Dvrms.Metadata.DvrmsMetadataEditor ed, string metaKey)
  83:         { 
  84:             return DvrmsMetadataEditor.GetMetadataItemAsString(ed.GetAttributes(), metaKey);
  85:         }
  86:  
  87:         static string MovieFolderName(DvrmsMetadataEditor ed)
  88:         {
  89:             string date = GetMeta(ed, "WM/OriginalReleaseTime");
  90:             int hyphen = date.IndexOf("-");
  91:             if (hyphen > 0) date = date.Substring(0, hyphen);
  92:             return GetMeta(ed, "Title").Replace(':', ';') + " (" + date + ")";
  93:         }
  94:     }
  95: }
(Download source code here: http://andy.boura.co.uk/downloads/Program.cs.txt [remove.txt to compile] )
This dealt with the 300+ TV movies I had in a mixture of .wtv and .dvr-ms formats. The odd one didn’t have the date set correctly etc. but generally speaking it works well.
--- IF YOU STOPPED READING WHEN I SHOWED CODE START READING AGAIN NOW ---
You can download the command line program here:
    http://andy.boura.co.uk/downloads/MoveRecordedTvMovies.exe
You will need the latest .net framework from MS and the dvrms.dll from here:
    http://babgvant.com/files/folders/misc/entry5687.aspx
Using it is simple - I use this batch file:
   1: MoveRecordedTvMovies "B:\Recorded TV" "B:\TV Movies" pause
   2: MoveRecordedTvMovies "C:\Users\Public\Recorded TV" "C:\Users\Public\Public TV Movies" pause
   3: pause
(Download batch file here: http://andy.boura.co.uk/downloads/MoveMovies.bat.txt [remove.txt to run] ) )
Once you are happy it’s working as you require you may want to add it as a scheduled task within windows (if doing that you will probably want to remove line 3 from the batch file or you will have to manually close the batch file output each day…).

Final Thoughts and observations

  • This really shouldn’t have been so difficult if MS put just a bit more effort into Media Center…that said it’s much improved in Win 7.
  • Someone could write a plug-in for media center extenders that gave full interactive DVD menus if they had the know-how…I would pay a small premium for such a plug-in if anyone fancies writing it – and I’m sure many others would too…
  • I have found the built in Movies library to be a bit slow and sometimes get confused regarding loading the meta data and thumbnails from the folders. For this reason I’ve been tending to use the My Movies interface. That said unfortunately My Movies doesn’t support resume! I might hunt for another option…
Anyway, that’s all for now – bit of an essay in the end I’m afraid :) Hope you find it useful – if you did please leave a comment and other positive encouragement so I know it’s worth writing this sort of thing up in future as it does take quite a while!
Cheers
Andy

Thursday 20 January 2011

Tool suppliers

I have purchased tools and D.IY. suppliers online for many years. I find Screwfix often have the greatest range and best prices although it's always worth checking other stores - even Amazon has tools these days! Over the coming months I'll review some of my favourite purchases and post information on some of my projects.

Cheers
Andy

Thursday 13 January 2011

DropBox for file sharing between devices and synchronising Internet Explorer Favourites

DropBox is a pretty simple concept - it keeps copies of a folder, sub-folders and contents synchronised across multiple systems, devices, and the DropBox website. Additionally it keeps a history of file changes so you can retrieve old versions should you experience an oh-no-second (the moment in time when you have done something you regret that it's too late to stop it but the consequences have not yet hit). It's a freemium service - that is there's a free version but to get at certain features you have to pay up. In the case of DropBox you pay for additional capacity.

Using DropBox I can keep files accessible on:
  • my work laptop
  • my commuting net book
  • my Blackberry
  • and my iPad
Keeping work and personal apart
You can create a "Personal" folder and exclude that from syncronising to a work PC should you wish to keep certain files from being copied to work. In converse you can create a "Work" folder that gets copied to your blackberry and work PC but not your home PC for example. You should of course be aware that anything in your DropBox will also be on the DropBox website and this may restrict what corporate information you are able to use it for if any.

Sharing Internet Explorer Favourites between PCs
If like me you work on more than one device you may well have come across the situation where you have a link to something on one PC but are currently working from another. This situation shouldn't arise again if you set things up right. Indeed you will even be able to get at your favourites by accessing the DropBox website!
  1. Open your Favourites
  2. Right click on a folder and click "open"
  3. Navigate up levels until you see the "Favourites" folder
  4. In Windows 7: Right click->Properties->Location and move into your DropBox folder
  5. In older versions of Windows: Move your Favourites folder into your DropBox and use RegEdit to alter the registry key for "HKEY CURRENT USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders"
Alterations to your Favourites or to your Favourites bar should now be replicated on any PC you have altered to use this new location. (BTW you can create sub-folders in your favourites bar - a useful way of keeping sites organised for rapid access).

Cheers
Andy

P.S. If you found this useful and are not yet signed up to DropBox then please consider using this link ( http://db.tt/V9OaPij ) which will get both of us some extra storage space.

Wednesday 22 September 2010

Padding oracle attack on ASP.net a.k.a POET vs. ASP.net

I've been spending a bit of time at work looking at this...and a load more at home last night. It turns out once you get past all the jargon and attempts at security through obscurity it's fairly simple. First off - watch the following video - but keep in mind these things:
  1. This has nothing to do with any sort of Oracle database - the oracle in this case is referring to something that you are able to use to extract useful information from a server. 
  2. This is not restricted to DotNetNuke - it applies to pretty much all ASP.net applications.
  3. Don't get distracted by the bit after the DotNetNuke session token has been created because at this point it's game over and the rest is just a show.
  4. Don't get distracted by them setting custom errors to false - that setting is important but simply setting it to remoteOnly or whatever which is normal good practice is not enough to protect you!
  5. Don't blame me for "helping the bad guys" - all that damage has already been done as the exploit tool is out there. What's important now is that the good guys understand the risk and mitigations.

Friday 17 September 2010

Cycling: Folding bike for commuting - Raleigh Folda review and user guide

I wanted to get myself a folding bike for commuting having tried the Barclays cycle hire and been impressed with the ease of cycling and provision of cycling paths but put off by the lack of bikes and bike rack space in the mornings. I figured a folding bike could be used both ends of my journey and also it would be door-to-door unlike the cycle scheme. Some are crazy expensive and I wasn’t sure how much use I would get from it so I decided to take a bit of a gamble on a cheapy one from Amazon. It was made more of a gamble than it should have been due to a complete lack of pictures, reviews, or anything much at all on the internet about this bike. Well, now I’ve taken the plunge I can help you buy armed with much more detailed knowledge! If you find this information useful then please use the link on the right to go back to Amazon to buy as I’ll get a small amount of commission for my trouble at no cost to you!