Compare commits

...

8 Commits

Author SHA1 Message Date
metalune 7dc316c39e Pick a resolution by default 2021-07-18 11:13:45 +02:00
metalune 3794cf09a2 Update input bar to max-width: 100% 2021-07-18 01:12:12 +02:00
metalune a29f3e9ba9 Make video take at most all of the screen 2021-07-18 00:59:20 +02:00
metalune 4c1572f5fa Center everything 2021-07-18 00:52:53 +02:00
metalune f528cdb46c Remove 'commit' in the footer 2021-07-18 00:14:56 +02:00
metalune 3afb09d5f6 Update commit link 2021-07-18 00:12:26 +02:00
metalune 4e6dd1df7a Use Grid for displaying results 2021-07-18 00:10:24 +02:00
metalune f5a5ac3f2b Update style 2021-07-17 20:27:08 +02:00
16 changed files with 298 additions and 225 deletions

40
main.py
View File

@ -7,13 +7,6 @@ import html2text
h2t = html2text.HTML2Text()
h2t.ignore_links = True
commit = "not found"
with open(".git/refs/heads/main") as file:
for line in file:
commit = line
# we only expect one line
break
# Wrapper, only containing information that's important for us, and in some cases provides simplified ways to get information
class VideoWrapper:
def __init__(self, a, quality):
@ -42,13 +35,29 @@ class VideoWrapper:
if len(self.files) == 0:
self.files = ((a["streamingPlaylists"])[0])["files"]
self.default_res = None
for entry in self.files:
resolution = (entry["resolution"])["id"]
self.resolutions.append(entry["resolution"])
# chose the default quality
if resolution != 0 and quality == None:
if self.default_res == None:
self.default_res = resolution
self.video = entry["fileUrl"]
elif abs(720 - resolution) < abs(720 - self.default_res):
self.default_res = resolution
self.video = entry["fileUrl"]
if str(resolution) == str(quality):
self.video = entry["fileUrl"]
if quality == None:
self.quality = self.default_res
else:
self.quality = quality
self.no_quality_selected = not self.video
@ -112,7 +121,6 @@ app = Quart(__name__)
async def main():
return await render_template(
"index.html",
commit=commit,
)
@app.route("/search", methods = ["POST"])
@ -126,7 +134,6 @@ async def simpleer_search(query, page):
results = peertube.sepia_search(query, (page - 1) * 10)
return await render_template(
"simpleer_search_results.html",
commit=commit,
results = results,
@ -151,7 +158,6 @@ async def instance_videos_local(domain, page):
"instance/local.html",
domain=domain,
instance_name=get_instance_name(domain),
commit=commit,
videos = vids,
@ -169,7 +175,6 @@ async def instance_videos_trending(domain, page):
"instance/trending.html",
domain=domain,
instance_name=get_instance_name(domain),
commit=commit,
videos = vids,
@ -188,7 +193,6 @@ async def instance_videos_most_liked(domain, page):
"instance/most-liked.html",
domain=domain,
instance_name=get_instance_name(domain),
commit=commit,
videos = vids,
@ -207,7 +211,6 @@ async def instance_videos_recently_added(domain, page):
"instance/recently-added.html",
domain=domain,
instance_name=get_instance_name(domain),
commit=commit,
videos = vids,
@ -234,7 +237,6 @@ async def search(domain, term, page):
"search_results.html",
domain=domain,
instance_name=get_instance_name(domain),
commit=commit,
results=results,
search_term=term,
@ -250,9 +252,8 @@ async def video(domain, id):
data = peertube.video(domain, id)
quality = request.args.get("quality")
embed = request.args.get("embed")
if quality == None:
quality = "best"
vid = VideoWrapper(data, quality)
quality = int(vid.quality)
# only make a request for the comments if commentsEnabled
comments = ""
@ -272,7 +273,6 @@ async def video(domain, id):
return await render_template(
"video.html",
domain=domain,
commit=commit,
instance_name=get_instance_name(domain),
video=vid,
@ -300,7 +300,6 @@ async def account__video_channels(domain, name, page):
return await render_template(
"accounts/video_channels.html",
domain=domain,
commit=commit,
instance_name=get_instance_name(domain),
name = name,
@ -320,7 +319,6 @@ async def account__videos(domain, name, page):
return await render_template(
"accounts/videos.html",
domain=domain,
commit=commit,
instance_name=get_instance_name(domain),
name = name,
@ -338,7 +336,6 @@ async def account__about(domain, name):
return await render_template(
"accounts/about.html",
domain=domain,
commit=commit,
instance_name=get_instance_name(domain),
name = name,
@ -359,7 +356,6 @@ async def video_channels__videos(domain, name, page):
return await render_template(
"video_channels/videos.html",
domain=domain,
commit=commit,
instance_name=get_instance_name(domain),
name = name,
@ -377,7 +373,6 @@ async def video_channels__video_playlists(domain, name, page):
return await render_template(
"video_channels/video_playlists.html",
domain=domain,
commit=commit,
instance_name=get_instance_name(domain),
name = name,
@ -394,7 +389,6 @@ async def video_channels__about(domain, name):
return await render_template(
"video_channels/about.html",
domain=domain,
commit=commit,
instance_name=get_instance_name(domain),
name = name,

View File

@ -1,13 +1,83 @@
body {
background-color: lightyellow;
max-width: 800px;
max-width: 1200px;
margin: 10px auto;
padding-left: 5px;
padding-right: 5px;
}
/* search results related */
#wrap {
display: flex;
flex-wrap: wrap;
justify-content: space-evenly;
}
.result-wrapper {
width: 300px;
margin: 10px;
}
.result-info {
display: block;
}
/* end of search results related */
.tag {
background-color: lightgrey;
background-color: lightgray;
padding: 3px 7px;
display: inline;
}
button {
font-size: 1rem;
padding: 4px 10px;
border: 2px solid #888888;
}
input {
font-size: 1rem;
padding: 4px;
border: 2px solid #888888;
}
input:focus,
button:focus {
outline: 2px solid #5d94ff;
}
a:visited {
text-decoration: none;
}
a {
text-decoration: none;
}
@media screen and (prefers-color-scheme: dark) {
body {
background-color: #212529;
color: #f8f9fa;
}
a:visited {
color: #9759f6;
}
a {
color: #599bf6;
}
button,
input {
background-color: #131618;
border-color: #495057;
color: #f8f9fa;
}
.tag {
background-color: #495057;
color: #f8f9fa;
}
}

View File

@ -8,21 +8,22 @@
<br>
<br>
<table>
{% for channel in video_channels.data %}
<tr>
<td>
<hr>
<div id="wrap">
{% for channel in video_channels.data %}
<div class="result-wrapper">
<img src="https://{{ domain }}{{ channel.avatar.path }}" height="75"/>
</td>
<td>
<a href="/{{ domain }}/video-channels/{{ channel.name }}@{{ channel.host }}">
<b>{{ channel.displayName }}</b>
</a>
<br>
{{ channel.followersCount }} Followers
</td>
</tr>
{% endfor %}
</table>
<div class="result-info">
<a href="/{{ domain }}/video-channels/{{ channel.name }}@{{ channel.host }}">
<b>{{ channel.displayName }}</b>
</a>
<br>
{{ channel.followersCount }} Followers
</div>
</div>
{% endfor %}
</div>
<hr>
{% endblock %}

View File

@ -8,24 +8,23 @@
<br>
<br>
<table>
{% for video in videos.data %}
<tr>
<td>
<div id="wrap">
{% for video in videos.data %}
<div class="result-wrapper">
<a href="/{{ domain }}/videos/watch/{{ video.uuid }}">
<img src="https://{{ domain }}{{ video.thumbnailPath }}" height="150"/>
</a>
</td>
<td>
<a href="/{{ domain }}/videos/watch/{{ video.uuid }}">{{ video.name }}</a>
<br>
{{ video.views }} Views
<br>
<b>{{ video.channel.displayName }}</b>
</a>
</td>
</tr>
{% endfor %}
</table>
<div class="result-info">
<a href="/{{ domain }}/videos/watch/{{ video.uuid }}">{{ video.name }}</a>
<br>
{{ video.views }} Views
<br>
<b>{{ video.channel.displayName }}</b>
</a>
</div>
</div>
{% endfor %}
</div>
{% endblock %}

View File

@ -9,11 +9,11 @@
{% endblock %}
</head>
<!-- I know that inline CSS is not .. the best, but I'll move it to an external file for sure! definitely! -->
<body>
<center>
<h2>{{ instance_name }}</h2>
<form action="/{{ domain }}/search" method="POST">
<input size="45" type="text" name="query" id="query" placeholder="Search" value="{{ search_term }}"/>
<input size="45" style="max-width: 100%" type="text" name="query" id="query" placeholder="Search" value="{{ search_term }}"/>
<button type="submit">Search</button>
</form>
@ -61,8 +61,6 @@
{% endif %}
{% endif %}
{% endif %}
<footer>
<a href="https://git.sr.ht/~metalune/peertube/tree/{{ commit }}">Commit: {{ commit }}</a>
</footer>
</center>
</body>
</html>

View File

@ -11,14 +11,9 @@
<h5>A simple frontend for PeerTube</h5>
<form action="/search" method="POST">
<input size="45" type="text" name="query" id="query" placeholder="SepiaSearch"/>
<input size="45" style="max-width: 100%" type="text" name="query" id="query" placeholder="SepiaSearch"/>
<button type="submit">Search</button>
</form>
<br>
<br>
<footer>
<a href="https://codeberg.org/simple-web/peertube/src/commit/{{ commit }}">Commit: {{ commit }}</a>
</footer>
</center>
</body>
</html>

View File

@ -4,27 +4,28 @@
{% block content %}
<table>
<hr>
<div id="wrap">
{% for video in videos.data %}
<tr>
<td>
<div class="result-wrapper">
<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>
<div class="result-info">
<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>
</div>
</div>
{% endfor %}
</table>
</div>
<hr>
{% endblock %}

View File

@ -4,27 +4,28 @@
{% block content %}
<table>
<hr>
<div id="wrap">
{% for video in videos.data %}
<tr>
<td>
<div class="result-wrapper">
<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>
<div class="result-info">
<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>
</div>
</div>
{% endfor %}
</table>
</div>
<hr>
{% endblock %}

View File

@ -4,27 +4,29 @@
{% block content %}
<table>
<hr>
<div id="wrap">
{% for video in videos.data %}
<tr>
<td>
<div class="result-wrapper">
<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>
<div class="result-info">
<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>
</div>
</div>
{% endfor %}
</table>
</div>
<hr>
{% endblock %}

View File

@ -4,27 +4,28 @@
{% block content %}
<table>
<hr>
<div id="wrap">
{% for video in videos.data %}
<tr>
<td>
<div class="result-wrapper">
<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>
<div class="result-info">
<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>
</div>
</div>
{% endfor %}
</table>
</div>
<hr>
{% endblock %}

View File

@ -5,28 +5,30 @@
{% block content %}
<p>{{ results.total }} results</p>
<table>
{% for result in results.data %}
<tr>
<td>
<a href="/{{ domain }}/videos/watch/{{ result.uuid }}">
<img src="https://{{ domain }}{{ result.thumbnailPath }}" height="150"/>
</a>
</td>
<td>
<a href="/{{ domain }}/videos/watch/{{ result.uuid }}">{{ result.name }}</a>
<br>
{{ result.views }} Views
<br>
<a href="/{{ domain }}/accounts/{{ result.channel.name }}@{{ result.channel.host }}">
<b>{{ result.channel.displayName }}</b>
</a>
<br>
<a href="/{{ domain }}/accounts/{{ result.account.name }}@{{ result.account.host }}">
{{ result.account.name }}@{{ result.account.host }}
</a>
</td>
</tr>
{% endfor %}
</table>
<hr>
<div id="wrap">
{% for result in results.data %}
<div class="result-wrapper">
<a href="/{{ domain }}/videos/watch/{{ result.uuid }}">
<img src="https://{{ domain }}{{ result.thumbnailPath }}" height="150"/>
</a>
<div class="result-info">
<a href="/{{ domain }}/videos/watch/{{ result.uuid }}">{{ result.name }}</a>
<br>
{{ result.views }} Views
<br>
<a href="/{{ domain }}/accounts/{{ result.channel.name }}@{{ result.channel.host }}">
<b>{{ result.channel.displayName }}</b>
</a>
<br>
<a href="/{{ domain }}/accounts/{{ result.account.name }}@{{ result.account.host }}">
{{ result.account.name }}@{{ result.account.host }}
</a>
</div>
</div>
{% endfor %}
</div>
<hr>
{% endblock %}

View File

@ -6,6 +6,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
</head>
<body>
<center>
<h2>SimpleerTube</h2>
<form action="/search" method="POST">
<input size="45" type="text" name="query" id="query" placeholder="Search" value="{{ query }}"/>
@ -30,24 +31,28 @@
<br>
{{ results.total }} Results
<table>
{% for result in results.data %}
<tr>
<td>
<img src="{{ result.thumbnailUrl }}" height="150"/>
</td>
<td>
<a href="/{{ result.channel.host }}/videos/watch/{{ result.uuid }}">
{{ result.name }}
</a>
<br>
{{ result.views }} Views
<br>
</td>
</tr>
{% endfor %}
</table>
<hr>
<div id="wrap">
{% for result in results.data %}
<div class="result-wrapper">
<a href="/{{ result.channel.host }}/videos/watch/{{ result.uuid }}">
<img src="{{ result.thumbnailUrl }}" height="150">
</a>
<div class="result-info">
<a href="/{{ result.channel.host }}/videos/watch/{{ result.uuid }}">{{ result.name }}</a>
<br>
{% if result.views == 1%}
1 View
{% else %}
{{ result.views }} Views
{% endif %}
</div>
</div>
{% endfor %}
</div>
<hr>
{% if pages_total > 1 %}
{% if page > 1 %}
@ -60,9 +65,6 @@
<a href="/search/{{ query }}/{{ page + 1}}">Next</a>
{% endif %}
{% endif %}
<footer>
<a href="https://codeberg.org/simple-web/peertube/src/commit/{{ commit }}">Commit: {{ commit }}</a>
</footer>
</center>
</body>
</html>

View File

@ -14,14 +14,14 @@ By:
<br>
{% if video.no_quality_selected and not embed %}
<img height="300" src="https://{{ video.channel.host }}{{ video.thumbnailPath }}">
<img height="300" style="max-width: 100%" src="https://{{ video.channel.host }}{{ video.thumbnailPath }}">
<p style="color: red">Please select a resolution:</p>
{% elif embed %}
<iframe src="https://{{ video.channel.host }}{{ video.embedPath }}" height="300" allowfullscreen="" frameborder="0"></iframe>
<br>
<b>Resolutions:</b>
{% else %}
<video height="300" controls>
<video height="300" style="max-width: 100%" controls>
<source src="{{ video.video }}">
</video>
<br>
@ -29,10 +29,18 @@ By:
{% endif %}
{% for resolution in video.resolutions %}
{% if resolution.label == "0p" %}
<a href="?quality={{ resolution.id }}">Audio Only</a>
{% if resolution.id == quality %}
{% if resolution.label == "0p" %}
[<a href="?quality={{ resolution.id }}">Audio Only</a>]
{% else %}
[<a href="?quality={{ resolution.id }}">{{ resolution.label }}</a>]
{% endif %}
{% else %}
<a href="?quality={{ resolution.id }}">{{ resolution.label }}</a>
{% if resolution.label == "0p" %}
<a href="?quality={{ resolution.id }}">Audio Only</a>
{% else %}
<a href="?quality={{ resolution.id }}">{{ resolution.label }}</a>
{% endif %}
{% endif %}
{% endfor %}
<a href="?embed=1">Embedded</a>

View File

@ -1,6 +1,7 @@
{% extends "base.html" %}
{% block head_content %}
<table>
<tr>
<td>

View File

@ -8,20 +8,20 @@
<br>
<br>
<table>
{% for playlist in video_playlists.data %}
<tr>
<td>
<hr>
<div id="wrap">
{% for playlist in video_playlists.data %}
<div class="result-wrapper">
<img src="https://{{ domain }}{{ playlist.thumbnailPath }}" height="150"/>
</td>
<td>
<b>{{ playlist.displayName }}</b>
<br>
{{ playlist.videosLength }} Videos
</td>
</tr>
{% endfor %}
</table>
<div class="result-info">
<b>{{ playlist.displayName }}</b>
<br>
{{ playlist.videosLength }} Videos
</div>
</div>
{% endfor %}
</div>
<hr>
{% endblock %}

View File

@ -8,25 +8,23 @@
<br>
<br>
<table>
{% for video in videos.data %}
<tr>
<td>
<hr>
<div id="wrap">
{% for video in videos.data %}
<div class="result-wrapper">
<a href="/{{ domain }}/videos/watch/{{ video.uuid }}">
<img src="https://{{ domain }}{{ video.thumbnailPath }}" height="150"/>
<img src="https://{{ domain }}{{ video.thumbnailPath }}" height="150"/>
</a>
</td>
<td>
<a href="/{{ domain }}/videos/watch/{{ video.uuid }}">{{ video.name }}</a>
<br>
{{ video.views }} Views
<br>
<b>{{ video.channel.displayName }}</b>
</a>
</td>
</tr>
{% endfor %}
</table>
<div class="result-info">
<a href="/{{ domain }}/videos/watch/{{ video.uuid }}">{{ video.name }}</a>
<br>
{{ video.views }} Views
</a>
</div>
</div>
{% endfor %}
</div>
<hr>
{% endblock %}