A HTTP proxy with filters

This idea was sparked by Channel 4’s online player 4OD. It makes you watch adverts like you were watching a television, some before, some after, and even some in the middle. It makes sense I guess, they still have to get paid. Except all this is happening on my computer, so I’m sure I can do something about it.

First thought, ad blockers. Don’t work, it’s all stuff within a flash object I essentially still want to use (to watch the actual content) and all the ad blockers I can find are actually still pretty simple, they just block URLs.

Some WebKit “Web Inspector”ing and a bit of wiresharking later and I find the URLs of the adverts being shown. They’re all from CDNs and have complicated session URLs, so I make a general pattern for their URLs to give to an ad blocker. When the video files are blocked, the 4OD player declares there is a problem (which I guess there is really), and stops playing. So it’s going to be more complicated than that.

More wiresharking. Let’s find out where the flash object is getting these video URLs from. From an XML document, with a nice clear structure showing where the adverts are and when to play them. If only there was a way of just removing that <adverts> tag. A browser extension (like greasemonkey or Safari extensions) could change the content of stuff fetched by the browser, but the XML document is being requested and processed by the flash plugin, so that’s out. Some kernel extension to intercept network calls? Sounds messy and beyond me. A proxy, except a misbehaving one that alters content before it forwards it (like those stories of those American ISPs that do the opposite of what I’m trying to do, inserting ads)? That could work. Is there something that already does this? Maybe, but uncertain if it’s configurable enough, and it costs. So that’s out. Can I make one? Good question.

I’d been hearing a lot about Node.js, a platform based around javascript and designed to make the evented model of javascript (like AJAX) available for use with general programming, especially IO. It was a language I already had a lot of experience with, and had libraries for HTTP requests and responses. And the evented model was supposed to make stuff like this fast and efficient. So should be perfect.

The way proxies work is pretty intuitive, and there’s plenty of documentation about it. Making a simple one in node took less than 50 lines, and it worked! Adding filtering rules was simple, I didn’t need to configure my proxy, I could just rewrite it however I wanted! The first thing I tried was removing the <adverts> tag in URLs that matched the 4OD XML info document and it worked. The adverts simply disappeared! A bit of smartening up and I had an easy to use (for me) system to handle any task like this when I need it!

iPod to ’80s boombox

I first started looking into vintage boomboxes when a friend got one those BOSE iPod docks. I thought a small set set of speakers that sounded good and could fill a room was a great idea. My first thought was that the new wave of iPod docks were made small so they would be portable, except they had no batteries and no handle. All the ones that were actually portable were passive (driven by the iPod, so quiet and bad sounding) or very expensive and in sort of a wheeled flight case format.

I was getting into golden age hip-hop at the time so quickly thought of old boom boxes, but assumed they were all the massive ones you see on album covers and not up to todays audio standards. A bit of research proved there was actually a very comprehensive range of sizes in manufacture before they fell out of fashion. There is also a large boombox collectors community on the internet who have a lot to say about the sound quality. It turns out that a competitive market and a consumer demand for loudness resulted in boomboxes that I’m sure would outperform atleast passive speakers. I also realised that consumer audio equipment doesn’t include all the detail and new technology of studio equipment, and now that headphones and speakers are more of a commodity that gap has probably widened. I also have my own suspicions that a generation used to listening to poorly encoded MP3s on YouTube are probably less discerning of audio quality, and these iPod dock manufacturers have could have taken advantage of that to cut costs.

So I took to eBay and am now the owner of a JVC RC-656LB for around £40! It’s about a foot and a half in length and has a very classic ’80s look to it, which makes sense as apparently they started manufacture of that model in 1982. I first tried it by tuning the radio and how loud and clear it could get really surprised me. It was a much better system than I was anticipating, especially the bass response!

002vf

To begin with I was content to make tapes. I inherited a Hi-Fi with a cassette recorder from my old flat and had some fun learning about the different types of tapes and recording methods, such as Dolby noise reduction. I bought the last box of cassettes from my local Currys and burnt through them within a month or so. I quickly found the attraction in making mix tapes. Selecting tracks and matching the lengths of each side was very cathartic, I soon had more mix playlists than cassettes. I put some whole albums on  tape too, and was taken back to the days of CD players, where you couldn’t skip around between albums and artists. Generally limiting what I could easily play gave me a much better appreciation for the tracks I was choosing, and also made me think a lot more about what tracks to put on tape, what music I really liked and could listen to all day.

I was lucky enough to have a friend who had a lot of PA equipment going back decades, including boxes and boxes of TDK chrome tapes. Chrome tapes (Type II) have a different frequency response to normal ferric (Type I) tapes,  so the recording and playback equalisations could be changed to give a better dynamic range in the high frequencies (assuming your tape player can adjust for them). Due to his generosity I now have a practically unlimited supply of tapes of a higher quality then the ones I can find in shops!

The boombox was going everywhere, the kitchen, shower, garden, picnics, beaches and camping trips. It could last a good few weeks of every day use on 8 D cell batteries (around £10 as long you can find a bulk pack of 8, unfortunately it chewed through cheap batteries when I tried so they weren’t an option). On longer trips my friends contributed to battery costs when it ran out, so it wasn’t too uneconomical. While at home it runs of the mains. Being the only one who could make tapes I was enjoying having complete control of the music. One thing I hate is skipping between different tracks to appease different people, especially before a track has even finished. It makes it impossible to get into what you’re listening to. Once a tape is in the boombox it’s a hassle to put another in and wind it to the right spot, so the music is left alone. I don’t think I’m too malevolent of a music dictator, the only tape which seems to cause any consistent consternation is “Jazz hour (and a half)”…

I did look into playing music from an iPod as well. It has an analog input, but with a connector I haven’t seen before, described as “5 pin DIN”. I managed to find some specs on the pin layout and bought a cheapy 1/8″ jack to DIN cable. On first try I thought it wasn’t working, but when I turned the boombox all they way up I could hear music just faintly. I’m assuming that the DIN input expects a much higher line level than modern standards. The level is so low I’m sure some sort of preamp would safely boost the signal to a suitable amount. Some googling showed that as preamps are normally for audiophiles they are much too expensive, even basic headphone amplifiers. From there I read about the Chu Moy design of DIY headphone amplifier, but prebuilt kits are again, needlessly expensive. It looks like I could get the parts cheap enough, so it could be a future project…

In the end I settled on a cheap FM transmitter for my iPod. The sound quality can be iffy, depending on interference, but it’s good for a quick fix, and has the handy side effect of being able to control what’s playing without having to walk up to the boombox.

So all in all, I think I managed to put together a system that outperforms these modern iPod docks, and at a much more affordable price. It also has a huge amount of retro cool and gets looks and people asking about it. It’s also offered a great deal of fun, learning how to best use it, the history of the iconic boombox, and putting me more in touch with my favourite music and helping me share it with other people. It could be the start of a new hobby.