improve opds support

This commit is contained in:
Danila Kamaev 2026-05-05 17:28:55 +04:00
parent da6e2ddca9
commit 9b55641d2d
2 changed files with 10 additions and 4 deletions

View file

@ -7186,12 +7186,11 @@ class HttpCli(object):
dirs = []
files = []
ptn_hr = RE_HR
use_abs_url = (
not is_opds
use_abs_url = is_opds or (
vpath
and not is_ls
and not is_js
and not self.trailing_slash
and vpath
)
for fn in ls_names:
base = ""
@ -7527,17 +7526,20 @@ class HttpCli(object):
]
j2a["opds_osd"] = "%s%s?opds&osd" % (self.args.SRS, quotep(vpath))
j2a["opds_id"] = uuid.uuid5(uuid.NAMESPACE_URL, vpath + "/").urn
j2a["opds_title"] = (vpath.rsplit("/", 1)[-1] + '/') if vpath else self.args.bname
for item in dirs:
href = item["href"]
href += ("&" if "?" in href else "?") + "opds"
item["href"] = href
item["opds_id"] = uuid.uuid5(uuid.NAMESPACE_URL, "%s/%s" % (vpath, item["name"])).urn
item["iso8601"] = "%sZ" % (item["dt"].replace(" ", "T"),)
for item in files:
href = item["href"]
href += ("&" if "?" in href else "?") + "dl"
item["href"] = href
item["opds_id"] = uuid.uuid5(uuid.NAMESPACE_URL, "%s/%s" % (vpath, item["name"])).urn
item["iso8601"] = "%sZ" % (item["dt"].replace(" ", "T"),)
if "rmagic" in self.vn.flags:

View file

@ -1,10 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
<id>{{ opds_id }}</id>
<title>{{ opds_title | e }}</title>
<link rel="search"
href="{{ opds_osd | e }}"
type="application/opensearchdescription+xml"/>
{%- for d in dirs %}
<entry>
<id>{{ d.opds_id }}</id>
<title>{{ d.name | e }}</title>
<link rel="subsection"
href="{{ d.href | e }}"
@ -14,6 +17,7 @@
{%- endfor %}
{%- for f in files %}
<entry>
<id>{{ f.opds_id }}</id>
<title>{{ f.name | e }}</title>
<updated>{{ f.iso8601 }}</updated>
<link rel="http://opds-spec.org/acquisition"