Add start page

This commit is contained in:
metalune 2021-01-22 04:17:02 +01:00
parent da472ed5f9
commit 109da9e9a4
10 changed files with 189 additions and 14 deletions

45
main.py
View file

@ -109,12 +109,53 @@ async def main():
@app.route("/<string:domain>/")
async def domain_main(domain):
async def instance(domain):
return redirect("/" + domain + "/videos/trending")
@app.route("/<string:domain>/videos/local")
async def instance_videos_local(domain):
return await render_template(
"domain_index.html",
"instance/local.html",
domain=domain,
instance_name=get_instance_name(domain),
commit=commit,
videos = peertube.get_videos_local(domain),
)
@app.route("/<string:domain>/videos/trending")
async def instance_videos_trending(domain):
return await render_template(
"instance/trending.html",
domain=domain,
instance_name=get_instance_name(domain),
commit=commit,
videos = peertube.get_videos_trending(domain),
)
@app.route("/<string:domain>/videos/most-liked")
async def instance_videos_most_liked(domain):
return await render_template(
"instance/most-liked.html",
domain=domain,
instance_name=get_instance_name(domain),
commit=commit,
videos = peertube.get_videos_most_liked(domain),
)
@app.route("/<string:domain>/videos/recently-added")
async def instance_videos_recently_added(domain):
return await render_template(
"instance/recently-added.html",
domain=domain,
instance_name=get_instance_name(domain),
commit=commit,
videos = peertube.get_videos_recently_added(domain),
)

View file

@ -28,6 +28,22 @@ def get_comments(domain, id):
url = "https://" + domain + "/api/v1/videos/" + id + "/comment-threads"
return json.loads(requests.get(url).text)
def get_videos_trending(domain):
url = "https://" + domain + "/api/v1/videos?sort=-trending"
return json.loads(requests.get(url).text)
def get_videos_most_liked(domain):
url = "https://" + domain + "/api/v1/videos?sort=-likes"
return json.loads(requests.get(url).text)
def get_videos_recently_added(domain):
url = "https://" + domain + "/api/v1/videos?sort=-publishedAt"
return json.loads(requests.get(url).text)
def get_videos_local(domain):
url = "https://" + domain + "/api/v1/videos?sort=-publishedAt&filter=local"
return json.loads(requests.get(url).text)
# --- Accounts ---
def account_video_channels(domain, name):

View file

@ -1,7 +1,5 @@
{% extends "base.html" %}
{% block title %}{{ domain }}{% endblock %}
{% block content %}
<table>
<tr>

View file

@ -15,7 +15,16 @@
</form>
<br>
<br>
<a href="/{{ domain }}/videos/local">Local</a>
<b> | </b>
<a href="/{{ domain }}/videos/trending">Trending</a>
<b> | </b>
<a href="/{{ domain }}/videos/most-liked">Most Liked</a>
<b> | </b>
<a href="/{{ domain }}/videos/recently-added">Recently Added</a>
<br>
<br>
{% block content %}{% endblock %}
<footer>

View file

@ -1,7 +0,0 @@
{% extends "base.html" %}
{% block title %}{{ domain }}{% endblock %}
{% block content %}
<b>{{ instance_name }}</b>
{% endblock %}

View file

@ -0,0 +1,30 @@
{% extends "base.html" %}
{% block full_title %}{{ instance_name }} - Local{% endblock %}
{% block content %}
<table>
{% for video in videos.data %}
<tr>
<td>
<img src="https://{{ domain }}/{{ video.thumbnailPath }}" height="150"/>
</td>
<td>
<a href="/{{ domain }}/videos/watch/{{ video.uuid }}">{{ video.name }}</a>
<br>
{{ video.views }} Views
<br>
<a href="/{{ domain }}/accounts/{{ video.channel.name }}@{{ video.channel.host }}">
<b>{{ video.channel.displayName }}</b>
</a>
<br>
<a href="/{{ domain }}/accounts/{{ video.account.name }}@{{ video.account.host }}">
{{ video.account.name }}@{{ video.account.host }}
</a>
</td>
</tr>
{% endfor %}
</table>
{% endblock %}

View file

@ -0,0 +1,30 @@
{% extends "base.html" %}
{% block full_title %}{{ instance_name }} - Most Liked{% endblock %}
{% block content %}
<table>
{% for video in videos.data %}
<tr>
<td>
<img src="https://{{ domain }}/{{ video.thumbnailPath }}" height="150"/>
</td>
<td>
<a href="/{{ domain }}/videos/watch/{{ video.uuid }}">{{ video.name }}</a>
<br>
{{ video.views }} Views
<br>
<a href="/{{ domain }}/accounts/{{ video.channel.name }}@{{ video.channel.host }}">
<b>{{ video.channel.displayName }}</b>
</a>
<br>
<a href="/{{ domain }}/accounts/{{ video.account.name }}@{{ video.account.host }}">
{{ video.account.name }}@{{ video.account.host }}
</a>
</td>
</tr>
{% endfor %}
</table>
{% endblock %}

View file

@ -0,0 +1,30 @@
{% extends "base.html" %}
{% block full_title %}{{ instance_name }} - Recently Added{% endblock %}
{% block content %}
<table>
{% for video in videos.data %}
<tr>
<td>
<img src="https://{{ domain }}/{{ video.thumbnailPath }}" height="150"/>
</td>
<td>
<a href="/{{ domain }}/videos/watch/{{ video.uuid }}">{{ video.name }}</a>
<br>
{{ video.views }} Views
<br>
<a href="/{{ domain }}/accounts/{{ video.channel.name }}@{{ video.channel.host }}">
<b>{{ video.channel.displayName }}</b>
</a>
<br>
<a href="/{{ domain }}/accounts/{{ video.account.name }}@{{ video.account.host }}">
{{ video.account.name }}@{{ video.account.host }}
</a>
</td>
</tr>
{% endfor %}
</table>
{% endblock %}

View file

@ -0,0 +1,30 @@
{% extends "base.html" %}
{% block full_title %}{{ instance_name }} - Trending{% endblock %}
{% block content %}
<table>
{% for video in videos.data %}
<tr>
<td>
<img src="https://{{ domain }}/{{ video.thumbnailPath }}" height="150"/>
</td>
<td>
<a href="/{{ domain }}/videos/watch/{{ video.uuid }}">{{ video.name }}</a>
<br>
{{ video.views }} Views
<br>
<a href="/{{ domain }}/accounts/{{ video.channel.name }}@{{ video.channel.host }}">
<b>{{ video.channel.displayName }}</b>
</a>
<br>
<a href="/{{ domain }}/accounts/{{ video.account.name }}@{{ video.account.host }}">
{{ video.account.name }}@{{ video.account.host }}
</a>
</td>
</tr>
{% endfor %}
</table>
{% endblock %}

View file

@ -1,7 +1,5 @@
{% extends "base.html" %}
{% block title %}{{ domain }}{% endblock %}
{% block content %}
<table>
<tr>