From 755ab35f6b6b0e78bbff6ca24f3f44008d9a4f71 Mon Sep 17 00:00:00 2001 From: Karl 'vollmerk' Vollmer Date: Sun, 29 Jul 2007 07:21:47 +0000 Subject: fixed the album art gathering, enabled art resizing and saving of said stuff... not sure if saving and retriving is saving any time. tweaked show test config wording --- lib/album.lib.php | 10 ++++++++++ lib/class/album.class.php | 29 +++++++++++++++++++++-------- lib/class/random.class.php | 2 +- lib/ui.lib.php | 14 +++++++++----- 4 files changed, 41 insertions(+), 14 deletions(-) (limited to 'lib') diff --git a/lib/album.lib.php b/lib/album.lib.php index 9b76d9a9..8812cb4c 100644 --- a/lib/album.lib.php +++ b/lib/album.lib.php @@ -38,6 +38,16 @@ function get_image_from_source($data) { return $data['raw']; } + // If it came from the database + if (isset($data['db'])) { + // Repull it + $album_id = Dba::escape($data['db']); + $sql = "SELECT * FROM `album_data` WHERE `album_id`='$album_id'"; + $db_results = Dba::query($sql); + $row = Dba::fetch_assoc($db_results); + return $row['art']; + } // came from the db + // Check to see if it's a URL if (isset($data['url'])) { $snoopy = new Snoopy(); diff --git a/lib/class/album.class.php b/lib/class/album.class.php index bc383f7c..62e6ac8c 100644 --- a/lib/class/album.class.php +++ b/lib/class/album.class.php @@ -216,7 +216,7 @@ class Album { $art = $this->get_db_art(); } - return $art; + return $art['0']; } // get_art @@ -259,9 +259,9 @@ class Album { case 'get_amazon_art': $data = $this->{$method_name}($options['keyword'],$limit); break; - case 'get_id3_art': - $data = $this->{$method_name}($limit); - break; + case 'get_lastfm_art': + $data = $this->{$method_name}($limit,$options); + break; default: $data = $this->{$method_name}($limit); break; @@ -288,12 +288,21 @@ class Album { * This returns the art as pulled from lastFM. This doesn't require * a special account, we just parse and run with it. */ - public function get_lastfm_art($limit) { + public function get_lastfm_art($limit,$options='') { // Create the parser object $lastfm = new LastFMSearch(); - $raw_data = $lastfm->search($this->artist_name,$this->name); + if (is_array($options)) { + $artist = $options['artist']; + $album = $options['album_name']; + } + else { + $artist = $this->artist_name; + $album = $this->name; + } + + $raw_data = $lastfm->search($artist,$album); if (!count($raw_data)) { return array(); } @@ -446,7 +455,9 @@ class Album { } else { return false; } - return $results; + $data = array(array('db_resized'=>$this->id,'raw'=>$results['art'],'mime'=>$results['art_mime'])); + + return $data; } // get_resized_db_art @@ -462,8 +473,10 @@ class Album { $results = Dba::fetch_assoc($db_results); if (!$results['art']) { return array(); } + + $data = array(array('db'=>$this->id,'raw'=>$results['art'],'mime'=>$results['art_mime'])); - return $results; + return $data; } // get_db_art diff --git a/lib/class/random.class.php b/lib/class/random.class.php index b24845e8..58be0463 100644 --- a/lib/class/random.class.php +++ b/lib/class/random.class.php @@ -32,7 +32,7 @@ class Random { * Constructor * nothing to see here, move along */ - private function __construct($id) { + public function __construct() { // Rien a faire diff --git a/lib/ui.lib.php b/lib/ui.lib.php index b89b4fea..ff863c78 100644 --- a/lib/ui.lib.php +++ b/lib/ui.lib.php @@ -514,15 +514,15 @@ function img_resize($image,$size,$type,$album_id) { /* Make sure they even want us to resize it */ if (!Config::get('resize_images')) { - return $image['art']; + return $image['raw']; } // Already resized - if ($image['resized']) { + if ($image['db_resized']) { debug_event('using_resized','using resized image for Album:' . $album_id,'2'); - return $image['art']; + return $image['raw']; } - $image = $image['art']; + $image = $image['raw']; if (!function_exists('gd_info')) { return false; } @@ -541,7 +541,10 @@ function img_resize($image,$size,$type,$album_id) { $src = imagecreatefromstring($image); - if (!$src) { return false; } + if (!$src) { + debug_event('IMG_RESIZE','Failed to create from string','3'); + return false; + } $width = imagesx($src); $height = imagesy($src); @@ -552,6 +555,7 @@ function img_resize($image,$size,$type,$album_id) { $img = imagecreatetruecolor($new_w,$new_h); if (!imagecopyresampled($img,$src,0,0,0,0,$new_w,$new_h,$width,$height)) { + debug_event('IMG_RESIZE','Failed to copy resample image','3'); return false; } -- cgit