Compare commits

4 Commits
Author SHA1 Message Date
Sweetbread 23bd539799 Add Steam info
Docker Build and Push / build-and-push (push) Successful in 55s
2026-02-04 00:34:16 +03:00
Sweetbread bc8947dfac fixup! Rework my page and add info from listenbrainz 2026-01-27 19:40:21 +03:00
Sweetbread fb9d6590cd Delete otoring >:
Docker Build and Push / build-and-push (push) Successful in 38s
2026-01-22 23:56:29 +03:00
Sweetbread 0ca97f2444 Rework my page and add info from listenbrainz 2026-01-22 23:55:58 +03:00
9 changed files with 16 additions and 25 deletions

No files matched your search

-1
View File
@@ -15,7 +15,6 @@ 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,5 +1,4 @@
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
@@ -54,8 +53,7 @@ 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(image := get_image_front(mbid, "250")) r = make_response(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')
@@ -63,6 +61,8 @@ 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,
+4 -2
View File
@@ -20,8 +20,7 @@ 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]['h_cover'] = f"https://shared.fastly.steamstatic.com/store_item_assets//steam/apps/{g['appid']}/header.jpg" json['games'][i]['img_icon_url'] = get_cover_url(g['appid'])
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:
@@ -60,4 +59,7 @@ 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,13 +51,16 @@ h3 {
.steam { .steam {
.block { .block {
display: flex; display: flex;
align-items: stretch;
img { img {
height: 7rem; height: 6rem;
flex: 0 0 auto;
margin-right: .5rem; margin-right: .5rem;
} }
p { p {
flex: 1;
margin: .5rem 0; margin: .5rem 0;
} }
} }
+5 -12
View File
@@ -1,14 +1,10 @@
<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>
{% if recent.games %}
<h3>Recently played:</h3> <h3>Recently played:</h3>
{% for g in recent.games %} {% for g in recent.games %}
<a href="https://store.steampowered.com/app/{{ g.appid }}" class="block"> <a href="https://store.steampowered.com/app/{{ g.appid }}" class="block">
<picture> <img src="{{ g.img_icon_url }}"/>
<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>
@@ -22,20 +18,18 @@
</div> </div>
</a> </a>
{% endfor %} {% endfor %}
{% endif %}
{% if owned.games %}
<h3>Top played games:</h3> <h3>Top played games:</h3>
{% set owned_games = owned.games | sort(attribute="playtime_forever", reverse=true) %} {% set owned_games = owned.games | sort(attribute="playtime_forever", reverse=true) %}
{% for g in owned_games[:5] %} {% for g in owned_games[:5] %}
<a href="https://store.steampowered.com/app/{{ g.appid }}" class="block"> <a href="https://store.steampowered.com/app/{{ g.appid }}" class="block">
<picture> <img src="{{ g.img_icon_url }}"/>
<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>
{% if 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>) +
@@ -48,5 +42,4 @@
</div> </div>
</a> </a>
{% endfor %} {% endfor %}
{% endif %}
</div> </div>
-2
View File
@@ -8,8 +8,6 @@ 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,8 +8,6 @@ about host = О хосте
contacts = Контакты contacts = Контакты
donate = Донат donate = Донат
description = Небольшой личный сайт
[index] [index]
altfronts = Альтфронты altfronts = Альтфронты
-1
View File
@@ -4,4 +4,3 @@ htmlmin2
requests requests
APScheduler APScheduler
musicbrainzngs musicbrainzngs
python-magic
-1
View File
@@ -7,7 +7,6 @@ pkgs.mkShell {
buildInputs = with pypkgs; [ buildInputs = with pypkgs; [
python python
python-magic
virtualenv virtualenv
pkgs.nodePackages.sass pkgs.nodePackages.sass
]; ];