I was writing a plugin w/ ‘HOOK_FETCH_FEED’ and my feed always came in as “[Unknown]” w/o a site url, even though I was supplying a valid XML feed w/ all the details. I found the place in feeds.php where the subscription happens and I have the following suggested patch (below). Once I subscribed with the patch in place, my subscriptions came in with title and site url just fine.
Caveat: not extensively tested yet; though I have subscribed to 1 xml feed, 1 html feed where I chose 1 sub-feed, and 3 gocomics for the af_comics plugin.
--- feeds.php-dist 2019-03-07 08:21:29.385836900 -0600
+++ feeds.php 2019-03-07 08:18:56.894413500 -0600
@@ -1208,10 +1208,21 @@
} else {
$sth = $pdo->prepare(
"INSERT INTO ttrss_feeds
- (owner_uid,feed_url,title,cat_id, auth_login,auth_pass,update_method,auth_pass_encrypted)
- VALUES (?, ?, ?, ?, ?, ?, 0, false)");
+ (owner_uid,feed_url,title,cat_id,site_url,auth_login,auth_pass,update_method,auth_pass_encrypted)
+ VALUES (?, ?, ?, ?, ?, ?, ?, 0, false)");
- $sth->execute([$_SESSION['uid'], $url, "[Unknown]", $cat_id, (string)$auth_login, (string)$auth_pass]);
+ $title = "[Unknown]";
+ $site_url = '';
+
+ $rss = new FeedParser($contents);
+ $rss->init();
+
+ if (!$rss->error()) {
+ $title = $rss->get_title();
+ $site_url = $rss->get_link();
+ }
+
+ $sth->execute([$_SESSION['uid'], $url, $title, $cat_id, $site_url, (string)$auth_login, (string)$auth_pass]);
$sth = $pdo->prepare("SELECT id FROM ttrss_feeds WHERE feed_url = ?
AND owner_uid = ?");
And patch af_comics to return basic information:
--- init.php-dist 2019-02-28 11:09:48.380812800 -0600
+++ init.php 2019-03-07 08:53:38.135080100 -0600
@@ -160,8 +160,11 @@
if ($auth_login || $auth_pass)
return $contents;
- if (preg_match('#^https?://www\.gocomics\.com/([-a-z0-9]+)$#i', $url))
- return '<?xml version="1.0" encoding="utf-8"?>'; // Get is_html() to return false.
+ if (preg_match('#^https?://www\.gocomics\.com/([-a-z0-9]+)$#i', $url, $matches))
+ return "<?xml version='1.0' encoding='utf-8'?>
+<feed xmlns='http://www.w3.org/2005/Atom'><title>" . ucfirst($matches[1]) . " Daily Strip</title>
+<generator uri='http://tt-rss.org/'>Tiny Tiny RSS/19.2 (dfd3a4e)</generator>
+<link href='$matches[0]' /></feed>"; // Make is_html() return false and supply basic info to subscribe with.
return $contents;
}
Thoughts?