summaryrefslogtreecommitdiffstats
path: root/lib/class/album.class.php
diff options
context:
space:
mode:
authormartian <martian@ampache>2010-02-12 02:10:08 +0000
committermartian <martian@ampache>2010-02-12 02:10:08 +0000
commit134adf17af031d979542ac04e99ab3d5c35c5d67 (patch)
treecc95828d73fba0245072fc95afb337da7e55d74c /lib/class/album.class.php
parent1ef5754692b5d7dd42cd3cc8cb9ac4f8618e706c (diff)
downloadampache-134adf17af031d979542ac04e99ab3d5c35c5d67.tar.gz
ampache-134adf17af031d979542ac04e99ab3d5c35c5d67.tar.bz2
ampache-134adf17af031d979542ac04e99ab3d5c35c5d67.zip
google image search support
Diffstat (limited to 'lib/class/album.class.php')
-rw-r--r--lib/class/album.class.php33
1 files changed, 32 insertions, 1 deletions
diff --git a/lib/class/album.class.php b/lib/class/album.class.php
index 6abd8412..3fb56ebd 100644
--- a/lib/class/album.class.php
+++ b/lib/class/album.class.php
@@ -336,6 +336,9 @@ class Album extends database_object {
case 'get_lastfm_art':
$data = $this->{$method_name}($limit,$options);
break;
+ case 'get_google_art':
+ $data = $this->{$method_name}($limit);
+ break;
default:
$data = $this->{$method_name}($limit);
break;
@@ -413,6 +416,34 @@ class Album extends database_object {
} // get_lastfm_art
+ /**
+ * get_google_art
+ * This retrieves art by searching google image search
+ */
+ public function get_google_art($limit='') {
+ $images = array();
+
+ $search = $this->full_name;
+
+ if ($this->artist_count == '1')
+ $search = $this->artist_name . ', ' . $search;
+
+ $search = rawurlencode($search);
+
+ $html = file_get_contents("http://images.google.com/images?source=hp&q=$search&oq=&um=1&ie=UTF-8&sa=N&tab=wi&start=0&tbo=1");
+
+ if(preg_match_all("|\ssrc\=\"(http.+?)\"|", $html, $matches, PREG_PATTERN_ORDER))
+ foreach ($matches[1] as $match) {
+ $extension = "image/jpeg";
+
+ if (strrpos($extension, '.') !== false) $extension = substr($extension, strrpos($extension, '.') + 1);
+
+ $images[] = array('url' => $match, 'mime' => $extension);
+ }
+
+ return $images;
+ } // get_google_art
+
/*!
@function get_id3_art
@discussion looks for art from the id3 tags
@@ -737,7 +768,7 @@ class Album extends database_object {
if (empty($keywords)) {
$keywords = $this->full_name;
/* If this isn't a various album combine with artist name */
- if ($this->artist_count == '1') { $keywords .= ' ' . $this->artist; }
+ if ($this->artist_count == '1') { $keywords .= ' ' . $this->artist_name; }
}
/* Create Base Vars */