update poster service

This commit is contained in:
j 2007-08-04 09:29:43 +00:00
commit cf8e33ec65
6 changed files with 36 additions and 14 deletions

View file

@ -1,10 +1,10 @@
<?php <?php
$id = $_GET['id']; $id = $_GET['id'];
$data = json_decode(file_get_contents("http://rlx:luxor@0xdb.org/$id/posterData.json"), true); $data = json_decode(file_get_contents("http://0xdb.org/$id/posterData.json"), true);
$director = utf8_decode($data['director']); $director = utf8_decode($data['director']);
$title = utf8_decode($data['title']); $title = utf8_decode($data['title']);
$url = "http://rlx:luxor@0xdb.org/$id/posterStill.png"; $url = "http://0xdb.org/$id/posterStill.png";
$md5 = md5("$director/$title"); $md5 = md5("$director/$title");
$rPoster = round(hexdec(substr($md5, 0, 2)) / 2); $rPoster = round(hexdec(substr($md5, 0, 2)) / 2);

File diff suppressed because one or more lines are too long

25
js.php Normal file
View file

@ -0,0 +1,25 @@
<?
$i = 0;
$path = 'posters/0xdb.org';
$dir = dir($path);
while ($file = $dir->read()) {
if (substr($file, 0, 1) != '.') {
$subdir = dir($path . '/' . $file);
while ($subfile = $subdir->read()) {
if (substr($subfile, 0, 1) != '.') {
$url = "http://services.0xdb.org/posters/$path/$file/$subfile";
$size = getimagesize($url);
echo "poster[$i] = [];\n";
echo "poster[$i]['url'] = '$url';\n";
echo "poster[$i]['width'] = " . $size[0] . ";\n";
echo "poster[$i]['height'] = " . $size[1] . ";\n";
$i++;
}
}
}
}
$rnd = floor(mt_rand() / mt_getrandmax() * count($poster));
?>

View file

@ -2,7 +2,9 @@
$id = str_pad($_GET['id'], 7, '0', STR_PAD_LEFT); $id = $_GET['id'];
if (strlen($id) < 7)
$id = str_pad($id, 7, '0', STR_PAD_LEFT);
$size = $_GET['size']; $size = $_GET['size'];
if ($size != 'large') if ($size != 'large')
$size = 'small'; $size = 'small';
@ -85,7 +87,7 @@ function returnPoster($id, $size) {
} }
foreach ($source as $value) { foreach ($source as $value) {
if ($file[$value]) if ($file[$value] && substr($file[$value], 0, 1) != '_')
returnImage($id, $size, $file[$value]); returnImage($id, $size, $file[$value]);
} }

View file

@ -1,9 +1,9 @@
<? <?php
include('php/library.php'); include('php/library.php');
if (!$id) if (!in_array(strlen($id), array(7, 34)))
die('poster.php returns a poster for a given IMDb id<br />usage: poster.php?id=ID[&size=SIZE]<br />ID: IMDb id<br />POSTER: small [128px] or large [512px]'); die ('poster.php returns a poster for a given IMDb id<br />usage: poster.php?id=ID[&size=SIZE]<br />ID: IMDb id<br />SIZE: small [128px] or large [512px]');
returnPoster($id, $size); returnPoster($id, $size);

View file

@ -1,5 +0,0 @@
add posters
--This line, and those below, will be ignored--
A .