Welcome to Geoffrey Swift's βlog. Please subscribe to the Atom feed.


ITV Player adverts skipped

Watching the adverts on the ITV Player was taking up enough time, that it seemed worth blocking them in the web proxy.

Considered various ways of doing this, and found it's quite easy block any URLs which start with http://sam.itv.com/XTSERVER/

ITV Player makes requests for VAST XML file there. The XML files describe each advert, and are created by the "Atlas AdManager" server software.

Since blocking the files which contain the URL for the advert videos, I don't see any adverts when watching online with this station either.

Demand Five Adverts skipped

In an old post I detailed how to avoid advert videos on the 4oD service. I have again I made use of the redirect_program feature of the Squid web proxy, but this time the adverts from Channel Five's Demand Five service are being removed.

I set about analysing how Demand Five works, by using the Fiddler web debugger from Microsoft. It became apparent that similar to the Channel Four service, there was a play list of (Flash) video files in an XML format.

So I attempted using the exact same technique as for 4oD. I created a "man in the middle" to filter out the adverts from the Demand Five play list, using my own PHP and XSLT code. Unfortunately the doctored play list I generated was rejected by the Flash player as invalid, presumably because required elements (adverts) were lacking. It's not clear whether this an intentional feature in Demand Five or not! Either way a different technique was needed.

I have avoided seeing banner adverts for some time, by having Squid serve upa 1 pixel by 1 pixel transparent GIF instead. Since modifying the XML play list on the fly didn't work out, I decided to get Squid to serve up a video of 0 seconds duration in place of an advertisement.

I searched the web and found a suitable dummy Flash video of 0 seconds length to use. So I just needed to let Squid know I wanted the dummy video instead of the advert videos. To do this I added the following line was added to my existing Perl script squid-redirector.pl:

s@http://[^ ]*\.akamai\.net/[^ ]*five\.tv[^ ]*\.flv@http://www.trollied.org/~blimey/fake/dummy.flv@;

Now I can enjoy Neighbours without having to wait for the adverts to finish. This is particularly useful when the playback gets interrupted and you have to start from the beginning.

Goodbye 4oD adverts

DISCLAIMER: THIS HACK DOES NOT WORK WITH 40D ANY LONGER

I quite like using the 4oD service from Channel 4, I can watch their programs at a time that suits me without the regular ad breaks on live TV. The adverts appear just before the program starts instead, and although you can skip to the right part of a program once it's playing, you can't fast forward the adverts.

The program is delivered to the 4oD player as a play list for Windows Media Player in the ASX file format. The first few items in the play list are the URLs for adverts, and the last one is the actual TV program. To avoid having to sit through these adverts, I saw there was the potential to to intercept this play list and remove the entries pertaining to advertising.

To achieve this, I made use of the redirect_program feature of the Squid web proxy. In this case, it allows me to tell Squid to fetch the play list from my website rather than directly from Channel 4. I wrote the following Perl script based on the example in the Squid documentation:

#!/usr/bin/perl use URI::Escape; $|=1; while (<>) { s@(http://vodapp\.grid\.channel4\.com/c4site-web/playlist\.do\?[^ ]*)@"http://www.trollied.org/~blimey/4oD.php?url=" . uri_escape($1)@e; print; }

So when the 4oD client requests a play list from the vodapp.grid.channel4.com server, it instead requests the playlist from my website. My website then downloads the desired play list, and does the required filtering using PHP and XSLT.

This PHP, very simply downloads the play list into a DOM document and applies the the required XSLT to it.

<?php $basename = basename($_SERVER['SCRIPT_NAME'], '.php'); $xslfile = $basename . '.xsl'; $xmlfile = $_GET['url']; $xml = new DOMDocument; $xml->load($xmlfile); $xsl = new DOMDocument; $xsl->load($xslfile); $xslProc = new XSLTProcessor(); $xslProc->importStylesheet($xsl); header('Content-Type: video/x-ms-asf'); $doc = $xslProc->transformToDoc($xml); echo $doc->saveXML($doc->firstChild); ?>

Here's the XSL, that simply copies everything in the document except for any ENTRY that has a TITLE starting with the word advert.

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output omit-xml-declaration="yes" method="xml" media-type="video/x-ms-asf"/> <xsl:template match="/ASX/ENTRY"> <xsl:if test="not(starts-with(TITLE, 'Advert'))"> <xsl:copy-of select="."/> </xsl:if> </xsl:template> <xsl:template match="/ASX/*[name() != 'ENTRY']"> <xsl:copy-of select="."/> </xsl:template> <xsl:template match="/"> <ASX VERSION="3.0"> <xsl:apply-templates/> </ASX> </xsl:template> </xsl:stylesheet>