Ben Dodson

Freelance iOS, macOS, Apple Watch, and Apple TV Developer

iTunes TV Artwork Script

I have a large amount of TV shows stored in iTunes but not all of them were purchased there, particularly as you can buy a Blu-Ray of many TV shows for a fraction of the price of a Standard Definition download. The only issue I've had is that I lacked artwork for each of these shows. In the past, I'd just screenshot the 200px or so image that showed up in the iTunes store and use that, but since getting an Apple TV (which displays the artwork at a much larger size) I decided I needed a better solution. After a weekend of sorting out my iTunes library, I decided to take a look at the iTunes Search API and see if I couldn't find a way of getting that artwork. They provide a 100x100px thumbnail as part of the API response, but fortunately (with some URL experimentation) I found a way to get the full 600x600px artwork.

 You can find the working version on my projects page but I thought I'd share the code briefly below so you can see how it's done and adjust it for any other media available on iTunes (e.g. movies, music, apps).

<?php
$search = $_GET['show'];
if ($search) {
	$url = 'http://ax.itunes.apple.com/WebObjects/MZStoreServices.woa/wa/wsSearch?term='.urlencode($search).'&country=us&entity=tvSeason';
	$obj = json_decode(file_get_contents($url));
	$results = array();
	foreach ($obj->results as $result) {
		$data = array();
		$data['url'] = str_replace('100x100', '600x600', $result->artworkUrl100);
		$data['title'] = $result->collectionName;
		$results[] = $data;
	}
}
?>

As you can see, it makes a fairly standard API call to the US iTunes store (as that has far more content than any of the others) which returns a lot of information about the particular entity (in this case a TV series). However, the artwork URL provided is only good for a 100x100px image so I us a basic str_replace to change that to 600x600 (the only other size I've found that works is 200x200). Once that's done, I grab the title and stick it all in an array to loop through later - simple!

Hopefully this script will be of some use to you - it's certainly made my library look a lot nicer when browsing on an iPad or an Apple TV!

Review: Worldictionary for iOS » « Gamification, Social Validation, Gowalla, and moving on from Wallabee - What I learned at SXSW

Want to keep up to date? Sign up to my free newsletter which will give you exclusive updates on all of my projects along with early access to future apps.