Skip to content

Instantly share code, notes, and snippets.

Created December 10, 2013 08:34
Show Gist options
  • Save anonymous/7887403 to your computer and use it in GitHub Desktop.
Save anonymous/7887403 to your computer and use it in GitHub Desktop.
URL rewriter to work around XBMC's mirror being down
#!/usr/bin/perl
# Place this file somewhere that Squid can find it, and change access
# so that Squid can read and execute it.
# Include the following line in squid.conf, and un-comment it there:
#url_rewrite_program /etc/squid/rewrite.pl
# Restart Squid, and in your XBMC's Settings/Internet Settings give your
# squid server's name and port as the proxy to use.
# Change this line to your preferred mirror. It replaces mirrors.xbmc.org in the URL.
$mirror = "www.mirrorservice.org/sites/mirrors.xbmc.org";
$| = 1;
while (<>) {
@line = split;
$_ = $line[0];
if (m/^http:\/\/(mirrors\.xbmc\.org)\/(.*)/) {
print "http://" . $mirror . "/" . $2 . "\n";
} else {
print $_ . "\n";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment