From a936e806307c280d255aca74b47a49745ff9bed9 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Fri, 15 Oct 2021 10:06:00 +0300 Subject: OPML improvements/fixes: * allow CLI import of OPML files (--opml-import) * visualize OPML structure when importing * add strict type hints to most OPML class methods --- update.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'update.php') diff --git a/update.php b/update.php index 67bf68f23..2ad4c963c 100755 --- a/update.php +++ b/update.php @@ -89,6 +89,7 @@ "force-refetch" => "debug update: force refetch feed data", "force-rehash" => "debug update: force rehash articles", "opml-export:" => ["USER:FILE", "export OPML of USER to FILE"], + "opml-import:" => ["USER:FILE", "import OPML for USER from FILE"], "user-list" => "list all users", # "user-add:" => ["USER[:PASSWORD]", "add USER, optionally without prompting for PASSWORD"], # "user-remove:" => ["USERNAME", "remove specified user"], @@ -380,6 +381,22 @@ $rc = $opml->opml_export($filename, $owner_uid, false, true, true); + Debug::log($rc ? "Success." : "Failed."); + } else { + Debug::log("User not found: $user"); + } + } + + if (isset($options["opml-import"])) { + list ($user, $filename) = explode(":", $options["opml-import"], 2); + + Debug::log("Importing feeds of user $user from OPML file $filename..."); + + if ($owner_uid = UserHelper::find_user_by_login($user)) { + $opml = new OPML(""); + + $rc = $opml->opml_import($owner_uid, $filename); + Debug::log($rc ? "Success." : "Failed."); } else { Debug::log("User not found: $user"); -- cgit v1.2.3