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 50 additions and 59 deletions
-1
View File
@@ -15,7 +15,6 @@ WORKDIR /app
COPY . .
COPY --from=sass /build/blueprints/ ./blueprints/
RUN apt install libmagic1
RUN pip install --no-cache-dir -r requirements.txt
ENV FLASK_ENV=production
+3 -3
View File
@@ -1,5 +1,4 @@
import os
import magic
from pathlib import Path
from htmlmin import minify
from datetime import datetime, timedelta
@@ -54,8 +53,7 @@ def static(filename: str):
@bp.route("/asset/mb/<mbid>")
def mb_cover(mbid):
r = make_response(image := get_image_front(mbid, "250"))
r.headers['Content-Type'] = magic.from_buffer(image[:2048], mime=True)
r = make_response(get_image_front(mbid, "250"))
r.headers['Cache-Control'] = 'public, max-age=86400'
r.headers['Expires'] = (datetime.now() + timedelta(days=1)) \
.strftime('%a, %d %b %Y %H:%M:%S GMT')
@@ -63,6 +61,8 @@ def mb_cover(mbid):
@bp.route("/")
def index():
print(recent)
return render_tmpl(
'index.html',
lb=listens,
+4 -2
View File
@@ -20,8 +20,7 @@ def get_cover_url(appid: int) -> str:
def inject_cover_url(json: dict) -> dict:
if 'games' in json.keys():
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]['v_cover'] = f"https://shared.fastly.steamstatic.com/store_item_assets//steam/apps/{g['appid']}/library_600x900.jpg"
json['games'][i]['img_icon_url'] = get_cover_url(g['appid'])
return json
def steam_request(interface: str, method: str, v: int = 1, **kwargs) -> requests.Response:
@@ -60,4 +59,7 @@ scheduler.add_job(
)
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())
@@ -51,13 +51,16 @@ h3 {
.steam {
.block {
display: flex;
align-items: stretch;
img {
height: 7rem;
height: 6rem;
flex: 0 0 auto;
margin-right: .5rem;
}
p {
flex: 1;
margin: .5rem 0;
}
}
+39 -46
View File
@@ -1,52 +1,45 @@
<div class="block steam">
<h2><a href="https://steamcommunity.com/id/risdeveau">Steam</a></h2>
{% if recent.games %}
<h3>Recently played:</h3>
{% for g in recent.games %}
<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>
<h3>Recently played:</h3>
{% for g in recent.games %}
<a href="https://store.steampowered.com/app/{{ g.appid }}" class="block">
<img src="{{ g.img_icon_url }}"/>
<div>
<strong>{{ g.name }}</strong>
<div>
<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>
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 %}
{% endif %}
{% if owned.games %}
<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 %}
{% endif %}
<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 %}
</div>
-2
View File
@@ -8,8 +8,6 @@ about host = About host
contacts = Contacts
donate = Donate
description = Small personal site
[index]
altfronts = Altfronts
-2
View File
@@ -8,8 +8,6 @@ about host = О хосте
contacts = Контакты
donate = Донат
description = Небольшой личный сайт
[index]
altfronts = Альтфронты
-1
View File
@@ -4,4 +4,3 @@ htmlmin2
requests
APScheduler
musicbrainzngs
python-magic
-1
View File
@@ -7,7 +7,6 @@ pkgs.mkShell {
buildInputs = with pypkgs; [
python
python-magic
virtualenv
pkgs.nodePackages.sass
];