Update main.py
Browse files
main.py
CHANGED
@@ -54,18 +54,18 @@ def duckduckgo_search(query: str):
|
|
54 |
|
55 |
# ========== OPDS Feed Generators ==========
|
56 |
|
57 |
-
def generate_root_feed(
|
58 |
ns = "http://www.w3.org/2005/Atom"
|
59 |
ET.register_namespace("", ns)
|
60 |
feed = ET.Element("feed", xmlns=ns)
|
61 |
ET.SubElement(feed, "title").text = "DuckDuckGo OPDS Catalog"
|
62 |
ET.SubElement(feed, "updated").text = datetime.utcnow().strftime("%Y-%m-%dT%H:%M:%SZ")
|
63 |
|
64 |
-
#
|
65 |
feed.append(ET.Element("link", {
|
66 |
"rel": "search",
|
67 |
"type": "application/atom+xml",
|
68 |
-
"href":
|
69 |
"templated": "true"
|
70 |
}))
|
71 |
|
@@ -95,9 +95,7 @@ def generate_search_feed(query: str, results):
|
|
95 |
|
96 |
@app.get("/opds", include_in_schema=False)
|
97 |
def opds_root() -> Response:
|
98 |
-
|
99 |
-
base_url = "http://localhost:8000"
|
100 |
-
xml_data = generate_root_feed(base_url)
|
101 |
return Response(content=xml_data, media_type="application/atom+xml")
|
102 |
|
103 |
@app.get("/opds/search")
|
|
|
54 |
|
55 |
# ========== OPDS Feed Generators ==========
|
56 |
|
57 |
+
def generate_root_feed():
|
58 |
ns = "http://www.w3.org/2005/Atom"
|
59 |
ET.register_namespace("", ns)
|
60 |
feed = ET.Element("feed", xmlns=ns)
|
61 |
ET.SubElement(feed, "title").text = "DuckDuckGo OPDS Catalog"
|
62 |
ET.SubElement(feed, "updated").text = datetime.utcnow().strftime("%Y-%m-%dT%H:%M:%SZ")
|
63 |
|
64 |
+
# Relative search link (OpenSearch template)
|
65 |
feed.append(ET.Element("link", {
|
66 |
"rel": "search",
|
67 |
"type": "application/atom+xml",
|
68 |
+
"href": "/opds/search?q={searchTerms}",
|
69 |
"templated": "true"
|
70 |
}))
|
71 |
|
|
|
95 |
|
96 |
@app.get("/opds", include_in_schema=False)
|
97 |
def opds_root() -> Response:
|
98 |
+
xml_data = generate_root_feed()
|
|
|
|
|
99 |
return Response(content=xml_data, media_type="application/atom+xml")
|
100 |
|
101 |
@app.get("/opds/search")
|