1
0
Fork 0
mirror of https://github.com/Yetangitu/ampache synced 2025-10-03 09:49:30 +02:00

Add: song_lyrics to Ampache #327 (thx alister55)

This commit is contained in:
momo-i 2009-02-24 04:18:33 +00:00
parent ef2a0a794d
commit 14ef536151
9 changed files with 99 additions and 8 deletions

View file

@ -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
?>

View file

@ -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
?>

View file

@ -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';

View file

@ -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;

View file

@ -106,3 +106,6 @@ msgstr ""
msgid "System"
msgstr ""
#: Database words
msgid "Show Lyrics"
msgstr ""

View file

@ -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

View file

@ -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;

View file

@ -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;

View file

@ -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>