View Single Post
Old 01-31-2008, 12:34 AM  
Jace
FBOP Class Of 2013
 
Industry Role:
Join Date: Jan 2004
Location: bumfuck, ky
Posts: 35,562
Programmers, how hard would this be?

I have a Lyrics script running on a site of mine, and it allows me to have an rss feed...the issue is that the rss only publishes the title of the lyric with a link to that lyric, plus it only lists the last 20 lyric posts

I want the feed to publish all the lyrics to that song, and also when the site hasn't been updated that day to publish a random lyric from the database...it has over 500,000 songs in it, so even if we set it to do any random song, the probability of it being a duplicate that the rss has seen recently is minimum

the script is Lyricing, you can see it in action here: http://www.lyricing.com/

the feed is http://www.lyricing.com/rss.php and the code to rss.php is

Code:
<?

include_once "config.php";

header("Content-type: text/xml");

echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";

echo '<rss version="2.0">';

echo '<channel>

<title>lyrics</title>

<description>music lyrics</description>

<link>http://www.domain.com/</link>';

$ex_sql = mysql_query( "select lyric_id, lyric_artist, lyric_title from lyrics where approved='1' order by lyric_id desc limit 20");

$num_rows = mysql_num_rows($ex_sql);

if ( $num_rows >= 1) {

while ($mysql_array = mysql_fetch_array($ex_sql)) {

echo '<item>

<link>http://www.domain.com/'.preg_replace('/([^a-zA-Z0-9]+)/', '-', $mysql_array['lyric_artist']).'/'.$mysql_array['lyric_id'].'-'.preg_replace('/([^a-zA-Z0-9]+)/', '-', $mysql_array['lyric_title']).'.html'.'</link>

<title>'.htmlspecialchars($mysql_array['lyric_artist']).' - '.htmlspecialchars($mysql_array['lyric_title']).'</title>
<guid>http://www.domain.com/'.preg_replace('/([^a-zA-Z0-9]+)/', '-', $mysql_array['lyric_artist']).'/'.$mysql_array['lyric_id'].'-'.preg_replace('/([^a-zA-Z0-9]+)/', '-', $mysql_array['lyric_title']).'.html'.'</guid>
</item>';

}

} else {

echo 'No latest lyrics available.';

}

echo '</channel></rss>';

?>
lyric_text is the field that stores the lyrics for each song

how hard would this be?

Last edited by Jace; 01-31-2008 at 12:35 AM..
Jace is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote