Update enclosure during a feed update (merge pull-request #199)
This commit is contained in:
parent
71f391ed7a
commit
64875e19cc
@ -419,8 +419,14 @@ function update_all($feed_id, array $items, $grabber = false)
|
||||
|
||||
\PicoFeed\Logging::log('Item parsed correctly');
|
||||
|
||||
// Insert only new item
|
||||
if ($db->table('items')->eq('id', $item->id)->count() !== 1) {
|
||||
// Get item record in database, if any
|
||||
$itemrec = $db
|
||||
->table('items')
|
||||
->columns('enclosure')
|
||||
->eq('id', $item->id)->findOne();
|
||||
|
||||
// Insert a new item
|
||||
if ($itemrec === null) {
|
||||
|
||||
\PicoFeed\Logging::log('Item added to the database');
|
||||
|
||||
@ -442,6 +448,16 @@ function update_all($feed_id, array $items, $grabber = false)
|
||||
'language' => $item->language,
|
||||
));
|
||||
}
|
||||
else if (isset($item->enclosure) && $item->enclosure && !$itemrec['enclosure']) {
|
||||
|
||||
\PicoFeed\Logging::log('Update item enclosure');
|
||||
|
||||
$db->table('items')->eq('id', $item->id)->save(array(
|
||||
'status' => 'unread',
|
||||
'enclosure' => $item->enclosure,
|
||||
'enclosure_type' => isset($item->enclosure_type) ? $item->enclosure_type : null,
|
||||
));
|
||||
}
|
||||
else {
|
||||
\PicoFeed\Logging::log('Item already in the database');
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user