GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   Programmers, how hard would this be? (https://gfy.com/showthread.php?t=803998)

Jace 01-31-2008 12:34 AM

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?

fr0gman 01-31-2008 12:43 AM

Interesting... I will hit up a dude and see what he can do.

Jace 01-31-2008 12:45 AM

Quote:

Originally Posted by fr0gman (Post 13721053)
Interesting... I will hit up a dude and see what he can do.

if he needs to contact me he can icq me 3 9 9 6 0 8 4 8 2

I would be willing to pay for it, I have this script installed on like 10 domains and it would be sweet to have this available on them all

LOOPNAME Se Vende! 01-31-2008 12:46 AM

Sorry I can not help you good luck

fr0gman 01-31-2008 12:49 AM

Quote:

Originally Posted by Jace (Post 13721062)
if he needs to contact me he can icq me 3 9 9 6 0 8 4 8 2

I would be willing to pay for it, I have this script installed on like 10 domains and it would be sweet to have this available on them all


You know Steve in NY (aka Hudson) right?

wpkings 01-31-2008 12:52 AM

Hey Jace,
It's not hard at all...unfortunately I'm very tired right now and may not be completely understanding you correctly, but it sounds like you would just need to add 'lyric_text' to the SELECT query, and loop that into an element, for example:

Code:

<lyrics>' . $mysql_array['lyric_text']) . '</lyrics>
Of course with the appropriate strip if necessary..
Like I said I'm tired but if you want to shoot an email to wpkings at gmail then I can take a look at it tomorrow. From the sound of it, it's like a 10 min job that wouldn't really cost anything.

mr.K© 01-31-2008 01:05 AM

Yeah, that's right. and you might want to put a cdata block around the lyric text else your rss would break in case of any special chars.

Dynamix 01-31-2008 01:18 AM

Quote:

Originally Posted by Jace (Post 13721037)
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 SQL query isn't pulling by date, it's just pulling the most recent 20 songs, meaning there will never be an empty results set so there's no need to randomize.

wpkings 01-31-2008 01:18 AM

And obviously the result limit is set with LIMIT:
Code:

$ex_sql = mysql_query( "select lyric_id, lyric_artist, lyric_title from lyrics where approved='1' order by lyric_id desc limit 20");
So you could just change that LIMIT 20 to LIMIT 40 etc

And yes, like mr.K mentioned...
Code:

<lyrics><![CDATA[' . $mysql_array['lyric_text']) . ']]></lyrics>
But there might be a better way.

The other part with the random lyrics isn't hard but I'd probably give you the wrong code if I tried now, so that can wait until tomorrow :)

Dynamix 01-31-2008 01:20 AM

Nevermind I think I realize what you mean.. can you paste the column name in the SQL database for date added, and also the format (likely YYYY-MM-DD but want to be sure)

Jace 01-31-2008 01:20 AM

Quote:

Originally Posted by Dynamix (Post 13721125)
The SQL query isn't pulling by date, it's just pulling the most recent 20 songs, meaning there will never be an empty results set so there's no need to randomize.

but what if I don't update new lyrics for a month, will the same lyrics be sitting in the rss feed for a month?

I want to use it to update blogs, and if the songs never rotate then the blog will pull the same songs every day

Jace 01-31-2008 01:21 AM

Quote:

Originally Posted by wpkings (Post 13721075)
Hey Jace,
It's not hard at all...unfortunately I'm very tired right now and may not be completely understanding you correctly, but it sounds like you would just need to add 'lyric_text' to the SELECT query, and loop that into an element, for example:

Code:

<lyrics>' . $mysql_array['lyric_text']) . '</lyrics>
Of course with the appropriate strip if necessary..
Like I said I'm tired but if you want to shoot an email to wpkings at gmail then I can take a look at it tomorrow. From the sound of it, it's like a 10 min job that wouldn't really cost anything.

quite simply, I want the song lyrics in the rss feed, not just the title

can I hit you up tomorrow to do this?

Jace 01-31-2008 01:22 AM

Quote:

Originally Posted by wpkings (Post 13721127)
And obviously the result limit is set with LIMIT:
Code:

$ex_sql = mysql_query( "select lyric_id, lyric_artist, lyric_title from lyrics where approved='1' order by lyric_id desc limit 20");
So you could just change that LIMIT 20 to LIMIT 40 etc

And yes, like mr.K mentioned...
Code:

<lyrics><![CDATA[' . $mysql_array['lyric_text']) . ']]></lyrics>
But there might be a better way.

The other part with the random lyrics isn't hard but I'd probably give you the wrong code if I tried now, so that can wait until tomorrow :)

yeah, i figured out the amount of articles pulled, that was easy

now I just need to figure out how to get the lyrics to show up too

Dynamix 01-31-2008 01:23 AM

Paste column name for full lyrics text, date, and sample date.. I'll get this cooked up for you before heading to bed :)

Jace 01-31-2008 01:25 AM

lyric_text is the sql column that holds all the lyrics data

Jace 01-31-2008 01:27 AM

there is also
temp_date
submit_date

Dynamix 01-31-2008 01:27 AM

what format is submit_date in? 2008-01-31 ?

Jace 01-31-2008 01:28 AM

this is weird though, all the dates are showing up as
0000-00-00 00:00:00

wpkings 01-31-2008 01:28 AM

Quote:

Originally Posted by Jace (Post 13721136)
quite simply, I want the song lyrics in the rss feed, not just the title

can I hit you up tomorrow to do this?

Sure if you don't get it figured out tonight, email wpkings at gmail or icq 442150682
Good luck

Nicky 01-31-2008 01:29 AM

Lot's of help here it seems, I suck at programming anyway lol

Jace 01-31-2008 01:30 AM

there is a lyric_id field though, you could randomize with that

but I only want the random thing when I don't add lyrics, if I add lyrics for the day there would be no random lyric

Dynamix 01-31-2008 01:30 AM

Not sure why your dates are screwy, assuming they worked this code ought to do the trick:

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

$sql_query = "select lyric_id, lyric_artist, lyric_title, lyric_text from lyrics where approved='1' order by lyric_id desc limit 20";

// Analyze date of latest entry
$date_chk= mysql_query("select submit_date from lyrics where approved='1' order by lyric_id desc limit 1");
$latest= mysql_fetch_array($date_chk);
$latest_date= split(" ",$latest['submit_date']);
if ($latest_date[0]!=date("Y-m-d")) $sql_query = "select lyric_id, lyric_artist, lyric_title, lyric_text from lyrics where approved='1' order by rand() limit 20";


$ex_sql = mysql_query( $sql_query );

$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>
<lyrics><![CDATA['.htmlspecialchars($mysql_array['lryic_text']).']]></lyrics>
<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>';

?>


Jace 01-31-2008 01:31 AM

Quote:

Originally Posted by Nicky (Post 13721160)
Lot's of help here it seems, I suck at programming anyway lol

gfy really actually does have some nice folks on here, usually late night though

btw, anyone that helps me will be paid something, and get some free hard links

Jace 01-31-2008 01:35 AM

Quote:

Originally Posted by Dynamix (Post 13721163)
Not sure why your dates are screwy, assuming they worked this code ought to do the trick:

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

$sql_query = "select lyric_id, lyric_artist, lyric_title, lyric_text from lyrics where approved='1' order by lyric_id desc limit 20";

// Analyze date of latest entry
$date_chk= mysql_query("select submit_date from lyrics where approved='1' order by lyric_id desc limit 1");
$latest= mysql_fetch_array($date_chk);
$latest_date= split(" ",$latest['submit_date']);
if ($latest_date[0]!=date("Y-m-d")) $sql_query = "select lyric_id, lyric_artist, lyric_title, lyric_text from lyrics where approved='1' order by rand() limit 20";


$ex_sql = mysql_query( $sql_query );

$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>
<lyrics><![CDATA['.htmlspecialchars($mysql_array['lryic_text']).']]></lyrics>
<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>';

?>


that is randomizing them every time it pulls the rss page up

http://lyrics.gamesandlyrics.com/rss.php

Dynamix 01-31-2008 01:37 AM

Quote:

Originally Posted by Jace (Post 13721175)
that is randomizing them every time it pulls the rss page up

http://lyrics.gamesandlyrics.com/rss.php

Right, because your date column is fucked up :/

Run this SQL query:

UPDATE lyrics set submit_date = '2008-01-30' where 0=0;

To set all dates to yesterday

Dynamix 01-31-2008 01:37 AM

Quote:

Originally Posted by Dynamix (Post 13721177)
Right, because your date column is fucked up :/

Run this SQL query:

UPDATE lyrics set submit_date = '2008-01-30' where 0=0;

To set all dates to yesterday

May want to set to today '2008-01-31' so it stops randomizing

Jace 01-31-2008 01:42 AM

now there is nothing there, haha

http://lyrics.gamesandlyrics.com/rss.php

i guess because it technically hasn't been entered yet

I know why all the dates are that way though, the sql dump I got was all set to have no submission dates, so when I start enterring them manually they will start having normal datwes

Jace 01-31-2008 01:43 AM

i set it back to 2008-01-30 so I can see what I am working with

thanks!!!!

now...to get the full lyrics text in there

Dynamix 01-31-2008 01:48 AM

add this after the first <link></link> set:

<lyrics>full lyrics</lyrics>

Dynamix 01-31-2008 01:49 AM

nope i lied... one sec

Dynamix 01-31-2008 01:56 AM

Change:
Code:

<lyrics><![CDATA['.htmlspecialchars($mysql_array['lryic_text']).']]></lyrics>
to:
Code:

<description><![CDATA['.htmlspecialchars($mysql_array['lryic_text']).']]></description>

Dynamix 01-31-2008 01:57 AM

and change my typo of lryic_text to lyric_text :)

Jace 01-31-2008 02:01 AM

Quote:

Originally Posted by Dynamix (Post 13721206)
and change my typo of lryic_text to lyric_text :)

oh shit, there it is!

http://lyrics.gamesandlyrics.com/rss.php

now, how do I get it to keep the html formatting?

Dynamix 01-31-2008 02:05 AM

Can you paste the PHP back? There's an error in there somewhere that needs correcting, view source you'll see the PHP warning.

Jace 01-31-2008 02:06 AM

Quote:

Originally Posted by Dynamix (Post 13721216)
Can you paste the PHP back? There's an error in there somewhere that needs correcting, view source you'll see the PHP warning.

yup, i see it

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://lyrics.gamesandlyrics.com/</link>';

$sql_query = "select lyric_id, lyric_artist, lyric_title, lyric_text from lyrics where approved='1' order by lyric_id desc limit 20";

// Analyze date of latest entry
$date_chk= mysql_query("select date from lyrics where approved='1' limit 1");
$latest= mysql_fetch_array($date_chk);
$latest_date= split(" ",$latest['date']);
if ($latest_date[0]!=date("Y-m-d")) $sql_query = "select lyric_id, lyric_artist, lyric_title, lyric_text from lyrics where approved='1' order by rand() limit 20";


$ex_sql = mysql_query( $sql_query );

$num_rows = mysql_num_rows($ex_sql);

if ( $num_rows >= 1) {

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

echo '<item>

<link>http://lyrics.gamesandlyrics.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>
<description><![CDATA['.htmlspecialchars($mysql_array['lyric_text']).']]></description>
<guid>http://lyrics.gamesandlyrics.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>';

?>


Jace 01-31-2008 02:07 AM

somewhere on this line

$date_chk= mysql_query("select date from lyrics where approved='1' limit 1");

Dynamix 01-31-2008 02:08 AM

Code:

<?

include_once "config.php";

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

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

echo '<rss version="2.0" xmlns:media="http://search.yahoo.com/mrss/">';

echo '<channel>

<title>lyrics</title>

<description>music lyrics</description>

<link>http://lyrics.gamesandlyrics.com/</link>';

$sql_query = "select lyric_id, lyric_artist, lyric_title, lyric_text from lyrics where approved='1' order by lyric_id desc limit 20";

// Analyze date of latest entry
$date_chk= mysql_query("select submit_date from lyrics where approved='1' limit 1");
$latest= @mysql_fetch_array($date_chk);
if ($latest){
        $latest_date= split(" ",$latest['submit_date']);
        if ($latest_date[0]!=date("Y-m-d")) $sql_query = "select lyric_id, lyric_artist, lyric_title, lyric_text from lyrics where approved='1' order by rand() limit 20";
}


$ex_sql = mysql_query( $sql_query );

$num_rows = mysql_num_rows($ex_sql);

if ( $num_rows >= 1) {

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

echo '<item>

<link>http://lyrics.gamesandlyrics.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>
<description><![CDATA['.htmlspecialchars($mysql_array['lyric_text']).']]></description>
<guid>http://lyrics.gamesandlyrics.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>';

?>


Dynamix 01-31-2008 02:08 AM

Yeah it's because 'date' isn't the column name, 'submit_date' is.. thought I changed that but obviously not :)

Jace 01-31-2008 02:10 AM

now how do I get the html to show up?

Dynamix 01-31-2008 02:13 AM

That's what I'm looking at.. comparing yours to MSNBC, the only difference is this line:

Code:

<rss version="2.0" xmlns:media="http://search.yahoo.com/mrss/">
But I thought that was only used to display media (video, photo, etc.)

Dynamix 01-31-2008 02:15 AM

i'm a moron. change this line:

Code:

<description><![CDATA['.htmlspecialchars($mysql_array['lyric_text']).']]></description>
to:

Code:

<description><![CDATA['.$mysql_array['lyric_text'].']]></description>

Jace 01-31-2008 02:29 AM

YOU FUCKING ROCK

http://lyrics.gamesandlyrics.com/rss.php

Jace 01-31-2008 02:29 AM

what is your epass?

Dynamix 01-31-2008 02:32 AM

PWMOORE@ Appreciate it, although it's not necessary.. just enjoy a mid-night challenge ;)

Jace 01-31-2008 02:39 AM

Quote:

Originally Posted by Dynamix (Post 13721258)
PWMOORE@ Appreciate it, although it's not necessary.. just enjoy a mid-night challenge ;)

sent :)

and no worries, I believe that everyone should get paid for the work they do :thumbsup

POed-poster 08-04-2008 01:19 AM

Quote:

Originally Posted by Jace (Post 13721037)
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?

How well are you doing with this site?

polle54 08-04-2008 02:29 AM

LOL I just read this old thread Dynamix is the only one who seemed to understand that you can't just put a <randomtext> tag in an rss feed :)
I thought every programmer and his mother understood rss from xml by now :)

raven1083 08-04-2008 02:30 AM

seems hard dude! Going to ask a friend for you!


All times are GMT -7. The time now is 02:24 PM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123