Quote:
|
Originally Posted by juicecowboy Need help with this--
It works excellent. one thing - on initial import, there are like 10 stories. I usually discard many of them (so that user-submitted stories don't get buried in the queue). On the next import, it picks up the "discard" stories again and puts them in the queue. It makes for alot of work with mysqladmin but if the script could include "discarded" stories in the duplicate checking that would be great.
I'm not much of a coder but I'm hoping this isn't hard. Could someone give me a quick tutorial on how to make this script check queued and discard stories? |
I just limited the import with an "if...then" statement in the script. This works fine.
Here is the script with a limit on the number of import (in this case "3")...doesn't really get more simple than this...
PHP Code:
<?
require('rss_fetch.inc');
include('../config.php');
require(mnminclude.'link.php');
$rss_feeds=array (
array(
'url'=>"http://www.sfgate.com/rss/feeds/wine.xml",
'category'=>8,
'author'=>19,
// 'tags'=>'
),
array(
'url'=>"http://feeds.feedburner.com/VivisWineJournal",
'category'=>9,
'author'=>15,
// 'tags'=>'
),
echo "<ul>\n";
foreach ($rss_feeds as $feed ) {
$rss = fetch_rss($feed['url']);
echo "<li>Site: ", $rss->channel['title'], "<br>\n";
foreach ($rss->items as $item )
{
if ($i <= 3)
{
$item['author']=$feed['author'];
$item['category']=$feed['category'];
$title = $item[title];
$desc= $item[description];
echo "<ul>";
echo "<li>Processing <a href=$url>$title</a></li>\n";
rss_store($item);
echo "<li>Finished Processing <a href=$url>$title</a></li><br><br/>\n\n";
echo "</ul>";
}
$i++;
}
echo "</li>";
}
echo "</ul>";
function rss_store($item) {
$linkres=new Link;
$edit = false;
$linkres->get(trim($item['link']));
if(!$linkres->valid) {
rss_error($item['link']);
return;
}
if($linkres->duplicates($item['link']) > 0) {
rss_error($item['url']);
return;
}
$linkres->status='discard';
$linkres->author=$item['author'];
$linkres->title=$item['title'];
$linkres->content=$item['description'];
$linkres->id=0;
$linkres->category=$item['category'];
$linkres->randkey=rand(10000,10000000);
$linkres->read();
$linkres->status='queued';
$linkres->store();
return;
}
function rss_error($url){
echo "Skipped $url <br/>\n";
}
?>