From c889c5a1de49ab8e2b233eb7a2c1f02da7fbf005 Mon Sep 17 00:00:00 2001 From: hius07 <62179190+hius07@users.noreply.github.com> Date: Tue, 18 Aug 2026 14:38:37 +0300 Subject: [PATCH] opdsbrowser: fix detecting OPDS 2.0 (#15895) --- plugins/opds.koplugin/opdsbrowser.lua | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/plugins/opds.koplugin/opdsbrowser.lua b/plugins/opds.koplugin/opdsbrowser.lua index f8a49e96c..9986870e0 100644 --- a/plugins/opds.koplugin/opdsbrowser.lua +++ b/plugins/opds.koplugin/opdsbrowser.lua @@ -482,15 +482,16 @@ function OPDSBrowser:parseFeed(item_url) else feed = self:fetchFeed(item_url) end - local start = feed and feed:sub(1, 1) - if start == "<" then -- OPDS 1.x - return OPDSParser:parse(feed) - elseif start == "{" then -- OPDS 2.0 - local JSON = require("json") - local ret, result = pcall(JSON.decode, feed) - if ret then - result.is_opds2 = true - return result + if feed then + if feed:match("^%s*{") then -- OPDS 2.0 + local JSON = require("json") + local ret, result = pcall(JSON.decode, feed) + if ret then + result.is_opds2 = true + return result + end + else -- OPDS 1.x + return OPDSParser:parse(feed) end end end