Sunday, June 15, 2014

IMDb to Letterboxd Redirector

This post was made to host a simple JavaScript script I've written for quickly redirecting an IMDb link to its corresponding Letterboxd page with a Firefox keyword search. Syntax:

http://manyfeatures.blogspot.com/letterboxd#imdb=imdb link

Example:

http://manyfeatures.blogspot.com/letterboxd#imdb=http://www.imdb.com/title/tt1602620/?ref_=fn_tt_tt_1

Goes to:

http://letterboxd.com/film/amour/

You're reading this because you haven't accessed this page with a #imdb hash parameter, or JavaScript is turned off.

If you're interested, here's the PHP script I had been using for this before:

<?php
ob_start("ob_gzhandler");

if ($_GET['imdb']){
$url = $_GET['imdb'];
$parts = explode('/', $url);
$url = 'http://letterboxd.com/imdb/' . $parts[4];

function redirect($letterboxd, $statusCode = 303){
header('Location: ' . $letterboxd, true, $statusCode);
die();
}

redirect($url);
}

else{echo '<p>Parameter not provided.</p>';}
?>