5 Commits
Author SHA1 Message Date
Sweetbread 1f7558e76c fixup! Rework my page and add info from listenbrainz
Docker Build and Push / build-and-push (push) Failing after 19s
2026-02-04 15:02:22 +03:00
Sweetbread 8c1ffdcdfe Add OG meta 2026-02-04 14:44:11 +03:00
Sweetbread b78e4185d1 Add Steam info 2026-02-04 14:44:11 +03:00
Sweetbread bf05be13ea Delete otoring >: 2026-02-04 14:43:10 +03:00
Sweetbread b030991905 Rework my page and add info from listenbrainz 2026-02-04 14:43:10 +03:00
9 changed files with 59 additions and 50 deletions
+1
View File
@@ -15,6 +15,7 @@ WORKDIR /app
COPY . . COPY . .
COPY --from=sass /build/blueprints/ ./blueprints/ COPY --from=sass /build/blueprints/ ./blueprints/
RUN apt install libmagic1
RUN pip install --no-cache-dir -r requirements.txt RUN pip install --no-cache-dir -r requirements.txt
ENV FLASK_ENV=production ENV FLASK_ENV=production
+3 -3
View File
@@ -1,4 +1,5 @@
import os import os
import magic
from pathlib import Path from pathlib import Path
from htmlmin import minify from htmlmin import minify
from datetime import datetime, timedelta from datetime import datetime, timedelta
@@ -53,7 +54,8 @@ def static(filename: str):
@bp.route("/asset/mb/<mbid>") @bp.route("/asset/mb/<mbid>")
def mb_cover(mbid): def mb_cover(mbid):
r = make_response(get_image_front(mbid, "250")) r = make_response(image := get_image_front(mbid, "250"))
r.headers['Content-Type'] = magic.from_buffer(image[:2048], mime=True)
r.headers['Cache-Control'] = 'public, max-age=86400' r.headers['Cache-Control'] = 'public, max-age=86400'
r.headers['Expires'] = (datetime.now() + timedelta(days=1)) \ r.headers['Expires'] = (datetime.now() + timedelta(days=1)) \
.strftime('%a, %d %b %Y %H:%M:%S GMT') .strftime('%a, %d %b %Y %H:%M:%S GMT')
@@ -61,8 +63,6 @@ def mb_cover(mbid):
@bp.route("/") @bp.route("/")
def index(): def index():
print(recent)
return render_tmpl( return render_tmpl(
'index.html', 'index.html',
lb=listens, lb=listens,
+2 -4
View File
@@ -20,7 +20,8 @@ def get_cover_url(appid: int) -> str:
def inject_cover_url(json: dict) -> dict: def inject_cover_url(json: dict) -> dict:
if 'games' in json.keys(): if 'games' in json.keys():
for i, g in enumerate(json['games']): for i, g in enumerate(json['games']):
json['games'][i]['img_icon_url'] = get_cover_url(g['appid']) json['games'][i]['h_cover'] = f"https://shared.fastly.steamstatic.com/store_item_assets//steam/apps/{g['appid']}/header.jpg"
json['games'][i]['v_cover'] = f"https://shared.fastly.steamstatic.com/store_item_assets//steam/apps/{g['appid']}/library_600x900.jpg"
return json return json
def steam_request(interface: str, method: str, v: int = 1, **kwargs) -> requests.Response: def steam_request(interface: str, method: str, v: int = 1, **kwargs) -> requests.Response:
@@ -59,7 +60,4 @@ scheduler.add_job(
) )
scheduler.start() scheduler.start()
api_request(recent, "IPlayerService", "GetRecentlyPlayedGames", steamid=76561198826355942)
api_request(owned, "IPlayerService", "GetOwnedGames", steamid=76561198826355942, include_appinfo=1, include_played_free_games=1)
atexit.register(lambda: scheduler.shutdown()) atexit.register(lambda: scheduler.shutdown())
@@ -51,16 +51,13 @@ h3 {
.steam { .steam {
.block { .block {
display: flex; display: flex;
align-items: stretch;
img { img {
height: 6rem; height: 7rem;
flex: 0 0 auto;
margin-right: .5rem; margin-right: .5rem;
} }
p { p {
flex: 1;
margin: .5rem 0; margin: .5rem 0;
} }
} }
+46 -39
View File
@@ -1,45 +1,52 @@
<div class="block steam"> <div class="block steam">
<h2><a href="https://steamcommunity.com/id/risdeveau">Steam</a></h2> <h2><a href="https://steamcommunity.com/id/risdeveau">Steam</a></h2>
<h3>Recently played:</h3> {% if recent.games %}
{% for g in recent.games %} <h3>Recently played:</h3>
<a href="https://store.steampowered.com/app/{{ g.appid }}" class="block"> {% for g in recent.games %}
<img src="{{ g.img_icon_url }}"/> <a href="https://store.steampowered.com/app/{{ g.appid }}" class="block">
<picture>
<source media="(max-width: 45rem)" srcset="{{ g.v_cover }}">
<img src="{{ g.h_cover }}">
</picture>
<div> <div>
<strong>{{ g.name }}</strong> <strong>{{ g.name }}</strong>
<p>Played last 2 weeks: {{ tmsmp(g.playtime_2weeks) }}
<p>
Total played:
{{ tmsmp(g.playtime_linux_forever) }} (<abbr title="On Linux">L</abbr>) +
{{ tmsmp(g.playtime_windows_forever) }} (<abbr title="On Windows">W</abbr>) =
{{ tmsmp(g.playtime_forever) }} (<abbr title="Total">T</abbr>)
</p>
</div>
</a>
{% endfor %}
<h3>Top played games:</h3>
{% set owned_games = owned.games | sort(attribute="playtime_forever", reverse=true) %}
{% for g in owned_games[:5] %}
<a href="https://store.steampowered.com/app/{{ g.appid }}" class="block">
<img src="{{ g.img_icon_url }}"/>
<div>
<strong>{{ g.name }}</strong>
{% if g.playtime_2weeks %}
<p>Played last 2 weeks: {{ tmsmp(g.playtime_2weeks) }} <p>Played last 2 weeks: {{ tmsmp(g.playtime_2weeks) }}
{% endif %} <p>
<p> Total played:
Total played: {{ tmsmp(g.playtime_linux_forever) }} (<abbr title="On Linux">L</abbr>) +
{{ tmsmp(g.playtime_linux_forever) }} (<abbr title="On Linux">L</abbr>) + {{ tmsmp(g.playtime_windows_forever) }} (<abbr title="On Windows">W</abbr>) =
{{ tmsmp(g.playtime_windows_forever) }} (<abbr title="On Windows">W</abbr>) = {{ tmsmp(g.playtime_forever) }} (<abbr title="Total">T</abbr>)
{{ tmsmp(g.playtime_forever) }} (<abbr title="Total">T</abbr>) </p>
</p> </div>
{% if g.rtime_last_played != 0 %} </a>
<p>Last played: {{ rtmsmp(g.rtime_last_played) }}</p> {% endfor %}
{% endif %} {% endif %}
</div>
</a> {% if owned.games %}
{% endfor %} <h3>Top played games:</h3>
{% set owned_games = owned.games | sort(attribute="playtime_forever", reverse=true) %}
{% for g in owned_games[:5] %}
<a href="https://store.steampowered.com/app/{{ g.appid }}" class="block">
<picture>
<source media="(max-width: 45rem)" srcset="{{ g.v_cover }}">
<img src="{{ g.h_cover }}">
</picture>
<div>
<strong>{{ g.name }}</strong>
<p>
Total played:
{{ tmsmp(g.playtime_linux_forever) }} (<abbr title="On Linux">L</abbr>) +
{{ tmsmp(g.playtime_windows_forever) }} (<abbr title="On Windows">W</abbr>) =
{{ tmsmp(g.playtime_forever) }} (<abbr title="Total">T</abbr>)
</p>
{% if g.rtime_last_played != 0 %}
<p>Last played: {{ rtmsmp(g.rtime_last_played) }}</p>
{% endif %}
</div>
</a>
{% endfor %}
{% endif %}
</div> </div>
+2
View File
@@ -8,6 +8,8 @@ about host = About host
contacts = Contacts contacts = Contacts
donate = Donate donate = Donate
description = Small personal site
[index] [index]
altfronts = Altfronts altfronts = Altfronts
+2
View File
@@ -8,6 +8,8 @@ about host = О хосте
contacts = Контакты contacts = Контакты
donate = Донат donate = Донат
description = Небольшой личный сайт
[index] [index]
altfronts = Альтфронты altfronts = Альтфронты
+1
View File
@@ -4,3 +4,4 @@ htmlmin2
requests requests
APScheduler APScheduler
musicbrainzngs musicbrainzngs
python-magic
+1
View File
@@ -7,6 +7,7 @@ pkgs.mkShell {
buildInputs = with pypkgs; [ buildInputs = with pypkgs; [
python python
python-magic
virtualenv virtualenv
pkgs.nodePackages.sass pkgs.nodePackages.sass
]; ];