Ruben Laguna's blog

Apr 2, 2006 - 2 minute read - Comments - itunes

PHP Proxy and iTunes

It seems that the company I’m working on has blocked They have categorized it as entertaiment/radio so I cannot access the podcasts from Java Posse at work. I’m sync my iPod with the ITunes at work so I cannot hear them anymore. Because I’m not happy with the situation I tried to overcome the blocking using my connection at home, so after googling a little bit I found PHP Proxy that allows to access other sites throught it. So I installed at home and now I point my iTunes to retrieve the javaposse feed through it.

But I didn’t work off the shelf. It’s designed to work with web pages only so I had to tweak it a little bit:

  • Add ‘text/xml’ and ‘application/xml’ to list of Content-Type’s that PHP Proxy is able to understand

  • Add the tag to the list of “rewritten” tags.

  • Append the original file extension of the url to the rewritten links so iTunes can identify the the link as a playable podcast.

  • Use Apache 2.0 mod_rewrite to rewrite requests to index.php.xxxx back to index.php

The weird thing is that iTunes wouldn’t recognize a link like this one

http://mydomain/unrestricted/phpproxy/index.php?q=aHR0cDovL3Z ...

as a playable episode even when the content-type of the link is “video/x-m4v” and the type attribute of the enclosure tag is also “video/x-m4v”. The actual error says “there are no playable episodes ” .iTunes needs that the file extension in the url to be one of .mp3, .m4v, .mov or similar so I had to add code to add the right file extension next to the .php in the links and instruct the Apache web server to map al queries to back to index.php. So the link in the enclosure tag look like

http://mydomain/unrestricted/phpproxy/index.php.m4v?q=aHR0cDovL3Z ...

I tested it with the following podcast and it works like a charm

  1. diggnationvideo

  2. the java posse

  3. ask a ninja

  4. security now!

The actual mod_rewrite commands that you need to add to httpd.conf are

RewriteEngine on
RewriteRule ^/unrestricted/phpproxy/index.php.(.*) /unrestricted/phpproxy/index.php [PT]

The patch to index.php

and the patch to PHPProxy.class.php

I hope this mod will help if someone has the same problems with phpproxy and itunes.


Writely post Javascript + iTunes