mirror of
https://codeberg.org/SimpleWeb/SimpleerTube.git
synced 2024-12-01 10:56:38 +00:00
Fix get_instance_name
This commit is contained in:
parent
f6f392db5a
commit
49326ffb69
3
main.py
3
main.py
|
@ -52,8 +52,7 @@ async def domain_main(domain):
|
||||||
return await render_template(
|
return await render_template(
|
||||||
"domain_index.html",
|
"domain_index.html",
|
||||||
domain=domain,
|
domain=domain,
|
||||||
instance_name="placeholder",
|
instance_name=peertube.get_instance_name(domain),
|
||||||
#instance_name=peertube.get_instance_name(domain),
|
|
||||||
)
|
)
|
||||||
|
|
||||||
@app.route('/<string:domain>/search', methods=["POST"])
|
@app.route('/<string:domain>/search', methods=["POST"])
|
||||||
|
|
21
peertube.py
21
peertube.py
|
@ -3,8 +3,12 @@ import requests
|
||||||
import json
|
import json
|
||||||
|
|
||||||
def get_instance_name(domain):
|
def get_instance_name(domain):
|
||||||
soup = BeautifulSoup(requests.get("https://" + domain).text)
|
soup = BeautifulSoup(requests.get("https://" + domain).text, "lxml")
|
||||||
return soup.find('span', class_="instance-name").text
|
title = soup.find('title')
|
||||||
|
if title:
|
||||||
|
return title.text
|
||||||
|
else:
|
||||||
|
return "PeerTube Instance"
|
||||||
|
|
||||||
def video(domain, id):
|
def video(domain, id):
|
||||||
video_url = "https://" + domain + "/api/v1/videos/" + id
|
video_url = "https://" + domain + "/api/v1/videos/" + id
|
||||||
|
@ -20,9 +24,18 @@ def search(domain, term, start = 0, count = 10):
|
||||||
|
|
||||||
return amount, results
|
return amount, results
|
||||||
|
|
||||||
|
def comments(domain, id):
|
||||||
|
url = "https://" + domain + "/api/v1/videos/" + id + "/comment-threads"
|
||||||
|
comments_object = json.loads(requests.get(url).text)
|
||||||
|
return comments_object
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
vid = video("diode.zone", "5405dac8-05c1-4512-b842-67be43ce7442")
|
name = get_instance_name("videos.lukesmith.xyz")
|
||||||
print(json.dumps(vid, indent=2))
|
print(name)
|
||||||
|
#com = comments("videos.lukesmith.xyz", "591bf5dd-b02f-40f7-a2cc-b4929c52cb51")
|
||||||
|
#print(json.dumps(com, indent=2))
|
||||||
|
#vid = video("diode.zone", "c4f0d71b-bd8b-4641-87b0-6d9edd4fa9ce")
|
||||||
|
#print(json.dumps(vid, indent=2))
|
||||||
#_, results = search("diode.zone", "test")
|
#_, results = search("diode.zone", "test")
|
||||||
#print(json.dumps(results, indent=2))
|
#print(json.dumps(results, indent=2))
|
||||||
|
|
Loading…
Reference in a new issue