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');
|
\PicoFeed\Logging::log('Item parsed correctly');
|
||||||
|
|
||||||
// Insert only new item
|
// Get item record in database, if any
|
||||||
if ($db->table('items')->eq('id', $item->id)->count() !== 1) {
|
$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');
|
\PicoFeed\Logging::log('Item added to the database');
|
||||||
|
|
||||||
@ -442,6 +448,16 @@ function update_all($feed_id, array $items, $grabber = false)
|
|||||||
'language' => $item->language,
|
'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 {
|
else {
|
||||||
\PicoFeed\Logging::log('Item already in the database');
|
\PicoFeed\Logging::log('Item already in the database');
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user