summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKarl 'vollmerk' Vollmer <vollmer@ampache.org>2005-12-09 17:56:34 +0000
committerKarl 'vollmerk' Vollmer <vollmer@ampache.org>2005-12-09 17:56:34 +0000
commit4b5713c9b0b897afbdc2c29110d948bd62244569 (patch)
tree4d23bc189011795db07c8eea4df784e2cd8166b4
parent2b12112868cce750e83a015cb581d376f08a873b (diff)
downloadampache-4b5713c9b0b897afbdc2c29110d948bd62244569.tar.gz
ampache-4b5713c9b0b897afbdc2c29110d948bd62244569.tar.bz2
ampache-4b5713c9b0b897afbdc2c29110d948bd62244569.zip
added ability to specify custom album art search options
-rw-r--r--albums.php44
-rwxr-xr-xdocs/CHANGELOG2
-rw-r--r--lib/class/album.class.php59
-rw-r--r--modules/init.php2
-rw-r--r--templates/flag.inc4
-rw-r--r--templates/show_get_albumart.inc.php63
6 files changed, 134 insertions, 40 deletions
diff --git a/albums.php b/albums.php
index 051485a1..67d075c9 100644
--- a/albums.php
+++ b/albums.php
@@ -66,36 +66,42 @@ elseif (isset($album)) {
elseif ($_REQUEST['action'] === 'find_art') {
if (!$user->has_access('25')) { access_denied(); }
+
+ // csammis: In response to https://ampache.bountysource.com/Task.View?task_id=86,
+ // adding retry to album art searching. I hope my PHP style doesn't make vollmer cry,
+ // because that would make me cry...then my girlfriend would cry...then my cat would laugh.
+ // She's such a little trouper!
+
/* Echo notice if no amazon token is found, but it's enabled */
if (in_array('amazon',conf('album_art_order')) AND !conf('amazon_developer_key')) {
- echo "<br /><div class=\"fatalerror\">Error: No Amazon Developer Key set, amazon album art searching will not work</div>";
+ echo "<br /><div class=\"fatalerror\">" . _("Error") . ": " . _("No Amazon Developer Key set, amazon album art searching will not work") . "</div>";
}
+ // get the Album information
$album = new Album($_REQUEST['album_id']);
- $result = $album->find_art($_REQUEST['cover']);
+
+ // Attempt to find the art with what we've got
+ $result = $album->find_art($_REQUEST['cover'], $_REQUEST['artist_name'], $_REQUEST['album_name']);
+
if ($result) {
show_confirmation(_("Album Art Located"),_("Album Art information has been located in Amazon. If incorrect, click \"Reset Album Art\" below to remove the artwork."),"/albums.php?action=show&amp;album=" . $album->id);
echo "&nbsp;[ <a href=\"" . conf('web_path') . "/albums.php?action=clear_art&amp;album_id=" . $album->id . "\">Reset Album Art</a> ]";
echo "<p align=left><img src=\"" . conf('web_path') . "/albumart.php?id=" . $album->id . "\" /></p>";
- echo "<form name=\"coverart\" method=\"get\" action=\"".$_SERVER['PHP_SELF']."\">";
- echo "Enter URL to album art ";
- echo "<input type=\"text\" size=\"40\" id=\"cover\" name=\"cover\" value=\"\" />\n";
- echo "<input type=\"hidden\" name=\"action\" value=\"find_art\" />\n";
- echo "<input type=\"hidden\" name=\"album_id\" value=\"$album->id\" />\n";
- echo "<input type=\"submit\" value=\"" . _("Get Art") . "\" />\n";
- echo "</form>";
- }
- else {
- show_confirmation(_("Album Art Not Located"),_("Album Art could not be located at this time. This may be due to Amazon being busy, or the album not being present in their collection."),"/albums.php?action=show&amp;album=" . $album->id);
- echo "<form name=\"coverart\" method=\"get\" action=\"".$_SERVER['PHP_SELF']."\">";
- echo "Enter URL to album art ";
- echo "<input type=\"text\" size=\"40\" id=\"cover\" name=\"cover\" value=\"\" />";
- echo "<input type=\"hidden\" name=\"action\" value=\"find_art\" />";
- echo "<input type=\"hidden\" name=\"album_id\" value=\"$album->id\" />&nbsp;&nbsp;&nbsp;";
- echo "<input type=\"submit\" value=\"" . _("Get Art") . "\" />\n";
- echo "</form>";
}
+ else {
+ show_confirmation(_("Album Art Not Located"),_("Album Art could not be located at this time. This may be due to Amazon being busy, or the album not being present in their collection."),"/albums.php?action=show&amp;album=" . $album->id);
+ }
+
+ $albumname = $album->name;
+ $artistname = $album->artist;
+
+ // Remember the last typed entry, if there was one
+ if (isset($_REQUEST['album_name'])) { $albumname = scrub_in($_REQUEST['album_name']); }
+ if (isset($_REQUEST['artist_name'])) { $artistname = scrub_in($_REQUEST['artist_name']); }
+
+ include(conf('prefix') . '/templates/show_get_albumart.inc.php');
+
} // find_art
// Updates Album from tags
diff --git a/docs/CHANGELOG b/docs/CHANGELOG
index 8d613048..2dad9f50 100755
--- a/docs/CHANGELOG
+++ b/docs/CHANGELOG
@@ -4,6 +4,8 @@
--------------------------------------------------------------------------
v.3.3.2-Alpha4
+ - Added ability to re-define album art search (Thx csammis)
+ https://ampache.bountysource.com/Task.View?task_id=86
- Fixed a logic flaw where it would attempt to parse the m3u
before all songs were cataloged
https://ampache.bountysource.com/Task.View?task_id=122
diff --git a/lib/class/album.class.php b/lib/class/album.class.php
index af2cd200..9a4ecd6c 100644
--- a/lib/class/album.class.php
+++ b/lib/class/album.class.php
@@ -353,16 +353,35 @@ class Album {
@discussion searches amazon or a url
for the album art
//FIXME: Rename this POS
+
+ // csammis: To facilitate solution of https://ampache.bountysource.com/Task.View?task_id=86,
+ // added $artist and $albumname parameters to the method, and reworked the guts of the amazon
+ // search a little; replaced $this->name with $albumname and $this->artist with $artist.
+ // See /albums.php, ~line 80, for where these values are coming from.
*/
- function find_art($coverurl = '') {
+ function find_art($coverurl = '', $artist = '', $albumname = '') {
// No coverurl specified search amazon
if (empty($coverurl)) {
+
+ // Prevent the script from timing out
+ set_time_limit(0);
+
+ // csammis: Assign defaults to the arguments if they are empty
+ if(empty($artist)) {
+ $artist = $this->artist;
+ }
+ if(empty($albumname)) {
+ $albumname = $this->name;
+ }
+
+ // Create the Search Object
$amazon = new AmazonSearch(conf('amazon_developer_key'));
- // Prevent the script from timing out
- set_time_limit(0);
- $search_term = $this->artist . " " . $this->name;
- $amazon->search(array('artist' => $this->artist, 'album' => $this->name, 'keywords' => $serch_term));
+
+ $search_term = $artist . " " . $albumname;
+
+ $amazon->search(array('artist' => $artist, 'album' => $albumname, 'keywords' => $serch_term));
+
// Only do the second search if the first actually returns something
if (count($amazon->results)) {
$amazon->lookup($amazon->results);
@@ -377,9 +396,10 @@ class Album {
foreach ($amazon->results as $key=>$value) {
$results = $value;
break;
- } //FIXME:
+ } //FIXME
} // if no cover
+
// If we've specified a coverurl, create a fake Amazon array with it
else {
$results = array('LargeImage' => $coverurl);
@@ -436,26 +456,29 @@ class Album {
/* Default to false */
return false;
- } // find_art
+ } // find_art
- /*!
+ /*!
@function get_song_ids
@discussion returns a list of song_ids on the album
get_songs returns a list of song objects
- */
-
- // it seems get_songs really should call this,
- // but I don't feel comfortable imposing that - RCR
- function get_song_ids( $limit = 0 ) {
- $results = array();
- $sql = "SELECT id FROM song WHERE album='$this->id' ORDER BY track, title";
+ */
+ // it seems get_songs really should call this,
+ // but I don't feel comfortable imposing that - RCR
+ function get_song_ids( $limit = 0 ) {
+
+ $results = array();
+ $sql = "SELECT id FROM song WHERE album='$this->id' ORDER BY track, title";
+
if ($limit) { $sql .= " LIMIT $limit"; }
- $db_results = mysql_query($sql, dbh());
-
+
+ $db_results = mysql_query($sql, dbh());
+
while ($r = mysql_fetch_object($db_results)) {
$results[] = $r->id;
}
- return( $results );
+
+ return $results;
} // get_song_ids
} //end of album class
diff --git a/modules/init.php b/modules/init.php
index ad049062..c3eea572 100644
--- a/modules/init.php
+++ b/modules/init.php
@@ -83,7 +83,7 @@ if (!$results['conf']['allow_stream_playback']) {
}
$results['conf']['web_path'] = $http_type . $_SERVER['HTTP_HOST'] . $results['conf']['web_path'];
-$results['conf']['version'] = '3.3.2-Alpha3';
+$results['conf']['version'] = '3.3.2-Alpha4 (Build 001)';
$results['conf']['catalog_file_pattern']= 'mp3|mpc|m4p|m4a|mp4|aac|ogg|rm|wma|asf|flac|spx';
$results['libglue']['local_table'] = 'session';
$results['libglue']['local_sid'] = 'id';
diff --git a/templates/flag.inc b/templates/flag.inc
index 6e8a85a4..6a35ee7c 100644
--- a/templates/flag.inc
+++ b/templates/flag.inc
@@ -48,7 +48,7 @@ if ( $type == 'show_flagged_form' ) {
<p style="color: red;"><?php echo $flag_text ; ?></p>
<?php } ?>
-<form name="flag_song" method="post" action="<?php echo $_SERVER['PHP_SELF'];; ?>">
+<form name="flag_song" method="post" action="<?php echo conf('web_path'); ?>/flag.php">
<table class="tabledata" cellpadding="3" cellspacing="1">
<tr class="even">
<td>File:</td>
@@ -91,7 +91,7 @@ elseif ( $type == 'show_flagged_songs' ) {
this list to determine what songs you need to re-rip or tags you need to update.</p>
<?php if ( $flags ) { ?>
-<form name="flag_update" action="<?php echo $_SERVER['PHP_SELF'];; ?>" method="post">
+<form name="flag_update" action="<?php echo conf('web_path'); ?>/flag.php" method="post">
<table class="tabledata" cellspacing="0" cellpadding="0" border="1">
<tr class="table-header">
diff --git a/templates/show_get_albumart.inc.php b/templates/show_get_albumart.inc.php
new file mode 100644
index 00000000..2de886b3
--- /dev/null
+++ b/templates/show_get_albumart.inc.php
@@ -0,0 +1,63 @@
+<?php
+/*
+
+ Copyright (c) 2001 - 2006 Ampache.org
+ All rights reserved.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License
+ as published by the Free Software Foundation; either version 2
+ of the License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+*/
+?>
+
+<form name="coverart" method="get" action="<?php echo conf('web_path'); ?>/albums.php" style="Displain:inline;">
+<table class="text-box">
+<tr>
+ <td>
+ <span class="header1"><?php echo _("Customize Search"); ?></span>
+ </td>
+</tr>
+<tr>
+ <td>
+ <?php echo _("Artist"); ?>&nbsp;
+ </td>
+ <td>
+ <input type="text" size="20" id="artist_name" name="artist_name" value="<?php echo $artistname; ?>" />
+ </td>
+</tr>
+<tr>
+ <td>
+ <?php echo _("Album"); ?>&nbsp;
+ </td>
+ <td>
+ <input type="text" size="20" id="album_name" name="album_name" value="<?php echo $albumname; ?>" />
+ </td>
+</tr>
+<tr>
+ <td>
+ <?php echo _("Direct URL to Image"); ?>
+ </td>
+ <td>
+ <input type="text" size="40" id="cover" name="cover" value="" />
+ </td>
+</tr>
+<tr>
+ <td>
+ <input type="hidden" name="action" value="find_art" />
+ <input type="hidden" name="album_id" value="<?php echo $album->id; ?>" />
+ <input type="submit" value="<?php echo _("Get Art"); ?>" />
+ </td>
+</tr>
+</table>
+</form>