summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormomo-i <momo-i@ampache>2009-02-24 04:18:33 +0000
committermomo-i <momo-i@ampache>2009-02-24 04:18:33 +0000
commit14ef5361513ebf5a9d8086f17d098ab76e545d14 (patch)
treee1106f28f92796b61c7995f2fd4eeb4f4d7e0331
parentef2a0a794d0065126f65ed6dbdfcbf6d39b9db66 (diff)
downloadampache-14ef5361513ebf5a9d8086f17d098ab76e545d14.tar.gz
ampache-14ef5361513ebf5a9d8086f17d098ab76e545d14.tar.bz2
ampache-14ef5361513ebf5a9d8086f17d098ab76e545d14.zip
Add: song_lyrics to Ampache #327 (thx alister55)
-rw-r--r--lib/class/artist.class.php55
-rw-r--r--lib/class/update.class.php21
-rw-r--r--lib/init.php1
-rw-r--r--lib/preferences.php8
-rw-r--r--locale/base/translation-words.txt3
-rw-r--r--song.php5
-rw-r--r--sql/ampache.sql4
-rw-r--r--sql/ampache40.sql4
-rw-r--r--update.php6
9 files changed, 99 insertions, 8 deletions
diff --git a/lib/class/artist.class.php b/lib/class/artist.class.php
index fd9f9ee3..c60e7e62 100644
--- a/lib/class/artist.class.php
+++ b/lib/class/artist.class.php
@@ -281,6 +281,59 @@ class Artist extends database_object {
return $current_id;
} // update
-
+
+ /**
+ * get_song_lyrics
+ * gets the lyrics of $this->song
+ * if they are not in the database, fetch using LyricWiki (SOAP) and insert
+ */
+ function get_song_lyrics($song_id, $artist_name, $song_title) {
+
+ $sql = "SELECT lyrics FROM song_data WHERE `song_id`='" . Dba::escape($song_id) . "'";
+ $db_results = Dba::query($sql);
+
+ $results = Dba::fetch_assoc($db_results);
+
+ if (strlen($results['lyrics']) > 1) {
+ return html_entity_decode(strip_tags(($results['lyrics'])), ENT_QUOTES);
+ }
+ else {
+ $client = new nusoap_client('http://lyricwiki.org/server.php?wsdl', 'wsdl');
+
+ $err = $client->getError();
+
+ if ($err) { return $results = $err; }
+
+ // sall SOAP method
+ $result = $client->call("getSongResult", array("artist" => $artist_name, "song" => $song_title ));
+ // check for fault
+ if ($client->fault) {
+ return $results = "<h2>" . _('Fault') . "</h2>" . print_r($result);
+ }
+ else {
+ // check for errors
+ $err = $client->getError();
+
+ if ($err) {
+ return $results = "<h2>" . _('Error') . "</h2>" . $err;
+ }
+ else {
+ // if returned "Not found" do not add
+ if($result['lyrics'] == "Not found") {
+ $sorry = sprintf(_('Sorry Lyrics %s.'), $result['lyrics']);
+ return $sorry;
+ }
+ else {
+ // since we got lyrics, might as well add them to the database now (for future use)
+ $sql = "UPDATE `song_data` SET `lyrics` = '" . htmlspecialchars(strip_tags(($result['lyrics'])), ENT_QUOTES) . "' WHERE `song_id`='" . Dba::escape($song_id) . "'";
+ $db_results = Dba::query($sql);
+ // display result (lyrics)
+ //print_r($result);
+ return $results = strip_tags($result['lyrics']);
+ }
+ }
+ }
+ }
+ } // get_song_lyrics
} // end of artist class
?>
diff --git a/lib/class/update.class.php b/lib/class/update.class.php
index 2c6f13d9..156a972c 100644
--- a/lib/class/update.class.php
+++ b/lib/class/update.class.php
@@ -303,6 +303,10 @@ class Update {
$version[] = array('version'=>'350005','description'=>$update_string);
+ $update_string = "- Add data for Lyrics<br />";
+
+ $version[] = array('version'=>'350006','description'=>$update_string);
+
return $version;
} // populate_version
@@ -1590,5 +1594,22 @@ class Update {
} // update_350005
+ /**
+ * update_350006
+ * This update inserts the Lyrics pref table...
+ */
+ public static function update_350006() {
+
+ $sql = "INSERT INTO `preference` VALUES (69,'show_lyrics','0','Show Lyrics',0,'boolean','interface')";
+ $db_results = Dba::write($sql);
+
+ $sql = "INSERT INTO `user_preference` VALUES (1,69,'0')";
+ $db_results = Dba::write($sql);
+
+ self::set_version('db_version','350006');
+
+ return true;
+ } // update_350006
+
} // end update class
?>
diff --git a/lib/init.php b/lib/init.php
index deefc5b5..52c8b8cf 100644
--- a/lib/init.php
+++ b/lib/init.php
@@ -137,6 +137,7 @@ require_once $prefix . '/lib/class/database_object.abstract.php';
require_once $prefix . '/lib/class/media.interface.php';
require_once $prefix . '/modules/pearxmlrpc/rpc.php';
require_once $prefix . '/modules/getid3/getid3.php';
+require_once $prefix . '/modules/nusoap/nusoap.php';
require_once $prefix . '/modules/infotools/Snoopy.class.php';
require_once $prefix . '/modules/infotools/AmazonSearchEngine.class.php';
require_once $prefix . '/modules/infotools/lastfm.class.php';
diff --git a/lib/preferences.php b/lib/preferences.php
index 7dc24f5f..1e721216 100644
--- a/lib/preferences.php
+++ b/lib/preferences.php
@@ -263,6 +263,14 @@ function create_preference_input($name,$value) {
echo "\t<option value=\"always\"$always>" . _('Always') . "</option>\n";
echo "</select>\n";
break;
+ case 'show_lyrics':
+ if ($value == '1') { $is_true = "selected=\"selected\""; }
+ else { $is_false = "selected=\"selected\""; }
+ echo "<select name=\"$name\">\n";
+ echo "\t<option value=\"1\" $is_true>" . _("Enable") . "</option>\n";
+ echo "\t<option value=\"0\" $is_false>" . _("Disable") . "</option>\n";
+ echo "</select>\n";
+ break;
default:
echo "<input type=\"text\" size=\"$len\" name=\"$name\" value=\"$value\" />";
break;
diff --git a/locale/base/translation-words.txt b/locale/base/translation-words.txt
index 96bd79b5..c846c50a 100644
--- a/locale/base/translation-words.txt
+++ b/locale/base/translation-words.txt
@@ -106,3 +106,6 @@ msgstr ""
msgid "System"
msgstr ""
+#: Database words
+msgid "Show Lyrics"
+msgstr ""
diff --git a/song.php b/song.php
index 55e77eb6..ed070c8f 100644
--- a/song.php
+++ b/song.php
@@ -31,6 +31,11 @@ switch ($_REQUEST['action']) {
$song->format();
$song->fill_ext_info();
require_once Config::get('prefix') . '/templates/show_song.inc.php';
+ // does user want to display lyrics?
+ $show_lyrics = Config::get('show_lyrics');
+ if($show_lyrics == 1) {
+ require_once Config::get('prefix') . '/templates/show_lyrics.inc.php';
+ }
break;
} // end data collection
diff --git a/sql/ampache.sql b/sql/ampache.sql
index 51ad282c..9a306f4f 100644
--- a/sql/ampache.sql
+++ b/sql/ampache.sql
@@ -490,7 +490,7 @@ SET character_set_client = @saved_cs_client;
LOCK TABLES `preference` WRITE;
/*!40000 ALTER TABLE `preference` DISABLE KEYS */;
-INSERT INTO `preference` VALUES (1,'download','0','Allow Downloads',100,'boolean','options'),(4,'popular_threshold','10','Popular Threshold',25,'integer','interface'),(19,'sample_rate','32','Transcode Bitrate',25,'string','streaming'),(22,'site_title','Ampache :: Pour l\'Amour de la Musique','Website Title',100,'string','system'),(23,'lock_songs','0','Lock Songs',100,'boolean','system'),(24,'force_http_play','1','Forces Http play regardless of port',100,'boolean','system'),(25,'http_port','80','Non-Standard Http Port',100,'integer','system'),(41,'localplay_controller','0','Localplay Type',100,'special','options'),(29,'play_type','stream','Type of Playback',25,'special','streaming'),(31,'lang','en_US','Language',100,'special','interface'),(32,'playlist_type','m3u','Playlist Type',100,'special','playlist'),(33,'theme_name','classic','Theme',0,'special','interface'),(34,'ellipse_threshold_album','27','Album Ellipse Threshold',0,'integer','interface'),(35,'ellipse_threshold_artist','27','Artist Ellipse Threshold',0,'integer','interface'),(36,'ellipse_threshold_title','27','Title Ellipse Threshold',0,'integer','interface'),(51,'offset_limit','50','Offset Limit',5,'integer','interface'),(40,'localplay_level','0','Localplay Access',100,'special','options'),(44,'allow_stream_playback','1','Allow Streaming',100,'boolean','system'),(45,'allow_democratic_playback','0','Allow Democratic Play',100,'boolean','system'),(46,'allow_localplay_playback','0','Allow Localplay Play',100,'boolean','system'),(47,'stats_threshold','7','Statistics Day Threshold',25,'integer','interface'),(49,'min_object_count','1','Min Element Count',5,'integer','interface'),(52,'rate_limit','8192','Rate Limit',100,'integer','streaming'),(53,'playlist_method','default','Playlist Method',5,'string','playlist'),(55,'transcode','default','Transcoding',25,'string','streaming'),(57,'tags_userlist','','User to track', 0, 'string', 'tags');
+INSERT INTO `preference` VALUES (1,'download','0','Allow Downloads',100,'boolean','options'),(4,'popular_threshold','10','Popular Threshold',25,'integer','interface'),(19,'sample_rate','32','Transcode Bitrate',25,'string','streaming'),(22,'site_title','Ampache :: Pour l\'Amour de la Musique','Website Title',100,'string','system'),(23,'lock_songs','0','Lock Songs',100,'boolean','system'),(24,'force_http_play','1','Forces Http play regardless of port',100,'boolean','system'),(25,'http_port','80','Non-Standard Http Port',100,'integer','system'),(41,'localplay_controller','0','Localplay Type',100,'special','options'),(29,'play_type','stream','Type of Playback',25,'special','streaming'),(31,'lang','en_US','Language',100,'special','interface'),(32,'playlist_type','m3u','Playlist Type',100,'special','playlist'),(33,'theme_name','classic','Theme',0,'special','interface'),(34,'ellipse_threshold_album','27','Album Ellipse Threshold',0,'integer','interface'),(35,'ellipse_threshold_artist','27','Artist Ellipse Threshold',0,'integer','interface'),(36,'ellipse_threshold_title','27','Title Ellipse Threshold',0,'integer','interface'),(51,'offset_limit','50','Offset Limit',5,'integer','interface'),(40,'localplay_level','0','Localplay Access',100,'special','options'),(44,'allow_stream_playback','1','Allow Streaming',100,'boolean','system'),(45,'allow_democratic_playback','0','Allow Democratic Play',100,'boolean','system'),(46,'allow_localplay_playback','0','Allow Localplay Play',100,'boolean','system'),(47,'stats_threshold','7','Statistics Day Threshold',25,'integer','interface'),(49,'min_object_count','1','Min Element Count',5,'integer','interface'),(52,'rate_limit','8192','Rate Limit',100,'integer','streaming'),(53,'playlist_method','default','Playlist Method',5,'string','playlist'),(55,'transcode','default','Transcoding',25,'string','streaming'),(57,'tags_userlist','','User to track', 0, 'string', 'tags'),(69,'show_lyrics','0','Show Lyrics',0,'boolean','interface');
/*!40000 ALTER TABLE `preference` ENABLE KEYS */;
UNLOCK TABLES;
@@ -839,7 +839,7 @@ SET character_set_client = @saved_cs_client;
LOCK TABLES `user_preference` WRITE;
/*!40000 ALTER TABLE `user_preference` DISABLE KEYS */;
-INSERT INTO `user_preference` VALUES (-1,1,'0'),(-1,4,'10'),(-1,19,'32'),(-1,22,'Ampache :: Pour l\'Amour de la Musique'),(-1,23,'0'),(-1,24,'1'),(-1,25,'80'),(-1,41,'0'),(-1,29,'stream'),(-1,31,'en_US'),(-1,32,'m3u'),(-1,33,'classic'),(-1,34,'27'),(-1,35,'27'),(-1,36,'27'),(-1,51,'50'),(-1,40,'0'),(-1,44,'1'),(-1,45,'0'),(-1,46,'0'),(-1,47,'7'),(-1,49,'1'),(-1,52,'8192'),(-1,53,'default'),(-1,55,'default');
+INSERT INTO `user_preference` VALUES (-1,1,'0'),(-1,4,'10'),(-1,19,'32'),(-1,22,'Ampache :: Pour l\'Amour de la Musique'),(-1,23,'0'),(-1,24,'1'),(-1,25,'80'),(-1,41,'0'),(-1,29,'stream'),(-1,31,'en_US'),(-1,32,'m3u'),(-1,33,'classic'),(-1,34,'27'),(-1,35,'27'),(-1,36,'27'),(-1,51,'50'),(-1,40,'0'),(-1,44,'1'),(-1,45,'0'),(-1,46,'0'),(-1,47,'7'),(-1,49,'1'),(-1,52,'8192'),(-1,53,'default'),(-1,55,'default'),(1,69,'0');
/*!40000 ALTER TABLE `user_preference` ENABLE KEYS */;
UNLOCK TABLES;
diff --git a/sql/ampache40.sql b/sql/ampache40.sql
index 65c0e1f2..e2c21dd7 100644
--- a/sql/ampache40.sql
+++ b/sql/ampache40.sql
@@ -485,7 +485,7 @@ SET character_set_client = @saved_cs_client;
LOCK TABLES `preference` WRITE;
/*!40000 ALTER TABLE `preference` DISABLE KEYS */;
-INSERT INTO `preference` VALUES (1,'download','0','Allow Downloads',100,'boolean','options'),(4,'popular_threshold','10','Popular Threshold',25,'integer','interface'),(19,'sample_rate','32','Transcode Bitrate',25,'string','streaming'),(22,'site_title','Ampache :: Pour l\'Amour de la Musique','Website Title',100,'string','system'),(23,'lock_songs','0','Lock Songs',100,'boolean','system'),(24,'force_http_play','1','Forces Http play regardless of port',100,'boolean','system'),(25,'http_port','80','Non-Standard Http Port',100,'integer','system'),(41,'localplay_controller','0','Localplay Type',100,'special','options'),(29,'play_type','stream','Type of Playback',25,'special','streaming'),(31,'lang','en_US','Language',100,'special','interface'),(32,'playlist_type','m3u','Playlist Type',100,'special','playlist'),(33,'theme_name','classic','Theme',0,'special','interface'),(34,'ellipse_threshold_album','27','Album Ellipse Threshold',0,'integer','interface'),(35,'ellipse_threshold_artist','27','Artist Ellipse Threshold',0,'integer','interface'),(36,'ellipse_threshold_title','27','Title Ellipse Threshold',0,'integer','interface'),(51,'offset_limit','50','Offset Limit',5,'integer','interface'),(40,'localplay_level','0','Localplay Access',100,'special','options'),(44,'allow_stream_playback','1','Allow Streaming',100,'boolean','system'),(45,'allow_democratic_playback','0','Allow Democratic Play',100,'boolean','system'),(46,'allow_localplay_playback','0','Allow Localplay Play',100,'boolean','system'),(47,'stats_threshold','7','Statistics Day Threshold',25,'integer','interface'),(49,'min_object_count','1','Min Element Count',5,'integer','interface'),(52,'rate_limit','8192','Rate Limit',100,'integer','streaming'),(53,'playlist_method','default','Playlist Method',5,'string','playlist'),(55,'transcode','default','Transcoding',25,'string','streaming');
+INSERT INTO `preference` VALUES (1,'download','0','Allow Downloads',100,'boolean','options'),(4,'popular_threshold','10','Popular Threshold',25,'integer','interface'),(19,'sample_rate','32','Transcode Bitrate',25,'string','streaming'),(22,'site_title','Ampache :: Pour l\'Amour de la Musique','Website Title',100,'string','system'),(23,'lock_songs','0','Lock Songs',100,'boolean','system'),(24,'force_http_play','1','Forces Http play regardless of port',100,'boolean','system'),(25,'http_port','80','Non-Standard Http Port',100,'integer','system'),(41,'localplay_controller','0','Localplay Type',100,'special','options'),(29,'play_type','stream','Type of Playback',25,'special','streaming'),(31,'lang','en_US','Language',100,'special','interface'),(32,'playlist_type','m3u','Playlist Type',100,'special','playlist'),(33,'theme_name','classic','Theme',0,'special','interface'),(34,'ellipse_threshold_album','27','Album Ellipse Threshold',0,'integer','interface'),(35,'ellipse_threshold_artist','27','Artist Ellipse Threshold',0,'integer','interface'),(36,'ellipse_threshold_title','27','Title Ellipse Threshold',0,'integer','interface'),(51,'offset_limit','50','Offset Limit',5,'integer','interface'),(40,'localplay_level','0','Localplay Access',100,'special','options'),(44,'allow_stream_playback','1','Allow Streaming',100,'boolean','system'),(45,'allow_democratic_playback','0','Allow Democratic Play',100,'boolean','system'),(46,'allow_localplay_playback','0','Allow Localplay Play',100,'boolean','system'),(47,'stats_threshold','7','Statistics Day Threshold',25,'integer','interface'),(49,'min_object_count','1','Min Element Count',5,'integer','interface'),(52,'rate_limit','8192','Rate Limit',100,'integer','streaming'),(53,'playlist_method','default','Playlist Method',5,'string','playlist'),(55,'transcode','default','Transcoding',25,'string','streaming',),(69,'show_lyrics','0','Show Lyrics',0,'boolean','interface');
/*!40000 ALTER TABLE `preference` ENABLE KEYS */;
UNLOCK TABLES;
@@ -832,7 +832,7 @@ SET character_set_client = @saved_cs_client;
LOCK TABLES `user_preference` WRITE;
/*!40000 ALTER TABLE `user_preference` DISABLE KEYS */;
-INSERT INTO `user_preference` VALUES (-1,1,'0'),(-1,4,'10'),(-1,19,'32'),(-1,22,'Ampache :: Pour l\'Amour de la Musique'),(-1,23,'0'),(-1,24,'1'),(-1,25,'80'),(-1,41,'0'),(-1,29,'stream'),(-1,31,'en_US'),(-1,32,'m3u'),(-1,33,'classic'),(-1,34,'27'),(-1,35,'27'),(-1,36,'27'),(-1,51,'50'),(-1,40,'0'),(-1,44,'1'),(-1,45,'0'),(-1,46,'0'),(-1,47,'7'),(-1,49,'1'),(-1,52,'8192'),(-1,53,'default'),(-1,55,'default');
+INSERT INTO `user_preference` VALUES (-1,1,'0'),(-1,4,'10'),(-1,19,'32'),(-1,22,'Ampache :: Pour l\'Amour de la Musique'),(-1,23,'0'),(-1,24,'1'),(-1,25,'80'),(-1,41,'0'),(-1,29,'stream'),(-1,31,'en_US'),(-1,32,'m3u'),(-1,33,'classic'),(-1,34,'27'),(-1,35,'27'),(-1,36,'27'),(-1,51,'50'),(-1,40,'0'),(-1,44,'1'),(-1,45,'0'),(-1,46,'0'),(-1,47,'7'),(-1,49,'1'),(-1,52,'8192'),(-1,53,'default'),(-1,55,'default'),(1,69,'0');
/*!40000 ALTER TABLE `user_preference` ENABLE KEYS */;
UNLOCK TABLES;
diff --git a/update.php b/update.php
index 1e741dd7..fd32dc1e 100644
--- a/update.php
+++ b/update.php
@@ -53,8 +53,8 @@ $htmllang = str_replace("_","-",Config::get('lang'));
</div>
<div id="text-box">
<div class="notify">
-This page handles all database updates to Ampache starting with <strong>3.3.3.5</strong>. According to your database your current version is: <strong><?php echo Update::format_version($version); ; ?></strong>.
-the following updates need to be performed<br /><br />
+<?php printf(_('This page handles all database updates to Ampache starting with <strong>3.3.3.5</strong>. According to your database your current version is: <strong>%s</strong>.'), Update::format_version($version)); ?>
+<?php echo _('the following updates need to be performed'); ?><br /><br />
<div style="font-size:1.2em;font-weight:bold;text-align:center;"><?php Error::display('general'); ?></div>
</div>
<div class="content">
@@ -65,7 +65,7 @@ the following updates need to be performed<br /><br />
</form>
</div>
<div id="bottom">
- <p><b>Ampache Installation.</b><br />
+ <p><b><?php echo _('Ampache Installation.'); ?></b><br />
Pour l'Amour de la Musique.</p>
</div>
</div>