yukes33
21
Hi,
I can share my “work” if you want. I just want to say that the code will not be pretty as I am a noob and without the help on this forum, I couldn’t have done half of the work.
I changed the plugin so that the published articles are sent to Wallabag (my read it later service).
function hook_house_keeping() {
/* since HOOK_UPDATE_TASK is not available to user plugins, this hook is a next best thing */
Debug::log("caching media of starred articles for user " . $this->host->get_owner_uid() . "...");
$sth = $this->pdo->prepare("SELECT content, ttrss_entries.title,
ttrss_user_entries.owner_uid, link, site_url, ttrss_entries.id, plugin_data
FROM ttrss_entries, ttrss_user_entries LEFT JOIN ttrss_feeds ON
(ttrss_user_entries.feed_id = ttrss_feeds.id)
WHERE ref_id = ttrss_entries.id AND
published = true AND
site_url != '' AND
ttrss_user_entries.owner_uid = ? AND
plugin_data NOT LIKE '%share_published%'
ORDER BY ".sql_random_function()." LIMIT 100");
if ($sth->execute([$this->host->get_owner_uid()])) {
$usth = $this->pdo->prepare("UPDATE ttrss_entries SET plugin_data = ? WHERE id = ?");
while ($line = $sth->fetch()) {
Debug::log("processing article " . $line["title"], Debug::$LOG_VERBOSE);
if ($line["site_url"]) {
$plugin_data = "share_published,${line['owner_uid']}:" . $line["plugin_data"];
$usth->execute([$plugin_data, $line['id']]);
/* Send to Wallabag
$this->_oauth();
$this->_send( $line["title"], $line["link"], 'filter');
/* Delete from published article list
$stmt = $this->pdo->prepare("UPDATE ttrss_user_entries SET published = false");
$stmt->execute();
reinob
22
Thanks a lot @jukes33!
I will try it as soon as I can. Hopefully I’ll get it to work with Raindrop, otherwise I might switch to Wallabag (was #2 in my list of replacements for Pocket…)
Thanks again!
fox
23
that got recently refactored in the Db class btw.
Hi fox,
I just updated some packages, including ttrss, and got an error on this line (you predicted my future 10 days before it happens).
I tried to change this line (removing ORDER BY ".sql_random_function()." for example) but failed everytime.
Do you have an idea on how I could make it work again ?
Thanks in advance
The function was moved into a class so you have to use that: Db::sql_random_function()
Hi and thanks for the quick answer. I just got it working by myself replacing it with RAND() but your solution is much more clean.
Thanks again and have a good day.
Using the method makes your plugin more portable as it will take care of PostreSQL or MySQL depending on what database TT-RSS is running.