diff options
author | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2007-01-15 20:44:17 +0000 |
---|---|---|
committer | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2007-01-15 20:44:17 +0000 |
commit | 883a1d60d3993f606131108d8c5675617d94bc82 (patch) | |
tree | 213d9af47987ef68608217acc20bcd2726e9304b /lib | |
parent | 43cc00bb87743334aab8743eef056303ec126e1a (diff) | |
download | ampache-883a1d60d3993f606131108d8c5675617d94bc82.tar.gz ampache-883a1d60d3993f606131108d8c5675617d94bc82.tar.bz2 ampache-883a1d60d3993f606131108d8c5675617d94bc82.zip |
speed up amazon gather and fixed some logic issues, and switched to disks for the download icons
Diffstat (limited to 'lib')
-rw-r--r-- | lib/class/album.class.php | 35 | ||||
-rw-r--r-- | lib/class/song.class.php | 7 | ||||
-rw-r--r-- | lib/class/update.class.php | 4 |
3 files changed, 40 insertions, 6 deletions
diff --git a/lib/class/album.class.php b/lib/class/album.class.php index 67bf218e..1102d3d6 100644 --- a/lib/class/album.class.php +++ b/lib/class/album.class.php @@ -332,8 +332,6 @@ class Album { while ( FALSE !== ($file = @readdir($handle)) ) { $extension = substr($file,strlen($file)-3,4); - - /* If it's an image file */ if ($extension == "jpg" || $extension == "gif" || $extension == "png" || $extension == "jp2") { @@ -432,20 +430,49 @@ class Album { /* Setup the needed variables */ $max_pages_to_search = max(conf('max_amazon_results_pages'),$amazon->_default_results_pages); $pages_to_search = $max_pages_to_search; //init to max until we know better. + + // while we have pages to search do { - $search_results = array_merge($search_results, $amazon->search(array('artist' => $artist, 'album' => $albumname, 'keywords' => $keywords))); + $raw_results = $amazon->search(array('artist'=>$artist,'album'=>$albumname,'keywords'=>$keywords)); + + $total = count($raw_results) + count($search_results); + + // If we've gotten more then we wanted + if (!empty($limit) && $total > $limit) { + // We don't want ot re-count every loop + $i = $total; + while ($i > $limit) { + array_pop($raw_results); + $i--; + } + + debug_event('amazon-xml',"Found $total, Limit $limit reducing and breaking from loop",'5'); + // Merge the results and BREAK! + $search_results = array_merge($search_results,$raw_results); + break; + } // if limit defined + + $search_results = array_merge($search_results,$raw_results); $pages_to_search = min($max_pages_to_search, $amazon->_maxPage); debug_event('amazon-xml', "Searched results page " . ($amazon->_currentPage+1) . "/" . $pages_to_search,'5'); $amazon->_currentPage++; + } while($amazon->_currentPage < $pages_to_search); + // Only do the second search if the first actually returns something if (count($search_results)) { $final_results = $amazon->lookup($search_results); } - + /* Log this if we're doin debug */ debug_event('amazon-xml',"Searched using $keywords with " . conf('amazon_developer_key') . " as key " . count($final_results) . " results found",'5'); + + // If we've hit our limit + if (!empty($limit) && count($final_results) >= $limit) { + break; + } + } // end foreach /* Foreach through what we've found */ diff --git a/lib/class/song.class.php b/lib/class/song.class.php index 7378ee29..b64f195c 100644 --- a/lib/class/song.class.php +++ b/lib/class/song.class.php @@ -800,6 +800,7 @@ class Song { /* Define Variables we are going to need */ $username = scrub_out($GLOBALS['user']->username); $song_id = $this->id; + if (conf('require_session')) { if ($session_id) { $session_string = "&sid=" . $session_id; @@ -808,6 +809,7 @@ class Song { $session_string = "&sid=" . session_id(); } } // if they are requiring a session + $type = $this->type; if ($GLOBALS['user']->prefs['play_type'] == 'downsample') { @@ -816,12 +818,13 @@ class Song { /* Account for retarded players */ if ($song->type == 'flac') { $type = 'ogg'; } - $this->format_song(); + + $this->format(); $song_name = rawurlencode($this->f_artist_full . " - " . $this->title . "." . $this->type); $web_path = conf('web_path'); - if (conf('force_http_play') AND !$force_http) { + if (conf('force_http_play') OR !empty($force_http)) { $port = conf('http_port'); $web_path = preg_replace("/https/", "http",$web_path); $web_path = preg_replace("/:\d+/",":$port",$web_path); diff --git a/lib/class/update.class.php b/lib/class/update.class.php index a11108fe..9f9bbd7d 100644 --- a/lib/class/update.class.php +++ b/lib/class/update.class.php @@ -1709,6 +1709,9 @@ class Update { /* Clean Up Indexes */ + // Prevent the script from timing out + set_time_limit(0); + // Access List $sql = "ALTER TABLE `access_list` DROP INDEX `ip`"; $db_results = mysql_query($sql, dbh()); @@ -2004,6 +2007,7 @@ class Update { // Prevent the script from timing out set_time_limit(0); + /* Foreach through the old stuff and dump it back into the fresh table */ foreach ($results as $row) { |