diff --git a/main.py b/main.py index 36dcb5d..cab02b8 100644 --- a/main.py +++ b/main.py @@ -105,7 +105,25 @@ app = Quart(__name__) @app.route("/") async def main(): - return await render_template("index.html") + return await render_template( + "index.html", + commit=commit, + ) + +@app.route("/search", methods = ["POST"]) +async def simpleer_search_redirect(): + query = (await request.form)["query"] + return redirect("/search/" + query) + +@app.route("/search/") +async def simpleer_search(query): + return await render_template( + "simpleer_search_results.html", + commit=commit, + + results=peertube.sepia_search(query) + ) + @app.route("//") diff --git a/peertube.py b/peertube.py index 2fe5045..3256e28 100644 --- a/peertube.py +++ b/peertube.py @@ -2,6 +2,14 @@ from bs4 import BeautifulSoup import requests import json +# --- Sepiasearch --- +def sepia_search(query): + url = "https://search.joinpeertube.org/api/v1/search/videos?search=" + query + return json.loads(requests.get(url).text) + +# --- ---- + + def get_instance_name(domain): soup = BeautifulSoup(requests.get("https://" + domain).text, "lxml") title = soup.find('title') diff --git a/templates/index.html b/templates/index.html index e69de29..72c66a3 100644 --- a/templates/index.html +++ b/templates/index.html @@ -0,0 +1,16 @@ + + + + SimpleerTube - Search + + +
+ + + +
+ + + diff --git a/templates/simpleer_search_results.html b/templates/simpleer_search_results.html new file mode 100644 index 0000000..349c19c --- /dev/null +++ b/templates/simpleer_search_results.html @@ -0,0 +1,36 @@ + + + + SimpleerTube - Search Results + + +
+ + + +
+
+
+ {{ results.total }} Results + + {% for result in results.data %} + + + + + {% endfor %} +
+ + + + {{ result.name }} + +
+ {{ result.views }} Views +
+
+ + +