Compare commits

4 Commits
Author SHA1 Message Date
Sweetbread 0f8bdbfc3b Add polling
Docker Build and Push / build-and-push (push) Successful in 19s
2026-02-05 15:44:58 +03:00
Sweetbread 9309c3aae5 Update docker image 2026-02-05 15:44:58 +03:00
Sweetbread b2f72044d3 Add OG meta 2026-02-05 15:44:58 +03:00
Sweetbread 0a7a04e81e Add Steam info 2026-02-05 15:44:58 +03:00
3 changed files with 39 additions and 41 deletions

No files matched your search

+25 -25
View File
@@ -2,7 +2,6 @@ import os
import magic
from pathlib import Path
from htmlmin import minify
from time import time
from datetime import datetime, timedelta
from musicbrainzngs import get_image_front
from flask import (
@@ -17,24 +16,19 @@ from flask import (
from .modules.api.lb import listens, listening
from .modules.api.steam import recent, owned
def tmsmp(sec: int) -> str:
if sec < 60:
return f"{sec} s"
elif sec < 60*60:
return f"{sec/60:.1f} m"
elif sec < 60*60*24:
return f"{sec/60/60:.1f} h"
def tmsmp(min: int) -> str:
if min < 60:
return f"{min} m"
elif min < 60*24:
return f"{min/60:.1f} h"
else:
return f"{sec/60/60/24:.1f} d"
return f"{min/60/24:.1f} d"
def utmsmp(unix: int) -> str:
def rtmsmp(unix: int) -> str:
return datetime \
.utcfromtimestamp(unix) \
.strftime('%Y-%m-%d %H:%M:%S')
def rtmsmp(unix: int) -> str:
return tmsmp(int(time() - unix))
bp = Blueprint(
"risdeveau",
__name__,
@@ -67,20 +61,26 @@ def mb_cover(mbid):
.strftime('%a, %d %b %Y %H:%M:%S GMT')
return r
args = {
"lb": listens,
"lb_now": listening,
"recent": recent,
"owned": owned,
"tmsmp": tmsmp,
"utmsmp": utmsmp,
"rtmsmp": rtmsmp
}
@bp.route("/")
def index():
return render_tmpl('index.html', **args)
return render_tmpl(
'index.html',
lb=listens,
lb_now=listening,
recent=recent.get('data', {}),
owned=owned.get('data', {}),
tmsmp=tmsmp,
rtmsmp=rtmsmp
)
@bp.route("/m/<module>")
def module(module):
return render_tmpl(f'{module}.htm', **args)
return render_tmpl(
f'{module}.htm',
lb=listens,
lb_now=listening,
recent=recent.get('data', {}),
owned=owned.get('data', {}),
tmsmp=tmsmp,
rtmsmp=rtmsmp
)
+2 -2
View File
@@ -3,7 +3,7 @@ from flask import Flask, jsonify
from apscheduler.schedulers.background import BackgroundScheduler
from apscheduler.triggers.interval import IntervalTrigger
import requests
from time import time
from datetime import datetime
import atexit
import re
from urllib.parse import urlparse, parse_qs
@@ -39,7 +39,7 @@ def api_request(cache, *args, **kwargs):
if response.status_code == 200:
cache.update({
'data': modify_game_list(response.json().get("response")),
'last_updated': time(),
'last_updated': datetime.now().isoformat(),
'status': 'success'
})
else:
+12 -14
View File
@@ -6,9 +6,9 @@
>
<h2><a href="https://steamcommunity.com/id/risdeveau">Steam</a></h2>
{% if recent.data.games %}
{% if recent.games %}
<h3>Recently played:</h3>
{% for g in recent.data.games %}
{% 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 }}">
@@ -17,22 +17,21 @@
<div>
<strong>{{ g.name }}</strong>
<p>Played last 2 weeks: {{ tmsmp(g.playtime_2weeks*60) }}
<p>Played last 2 weeks: {{ tmsmp(g.playtime_2weeks) }}
<p>
Total played:
{{ tmsmp(g.playtime_linux_forever*60) }} (<abbr title="On Linux">L</abbr>) +
{{ tmsmp(g.playtime_windows_forever*60) }} (<abbr title="On Windows">W</abbr>) =
{{ tmsmp(g.playtime_forever*60) }} (<abbr title="Total">T</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_forever) }} (<abbr title="Total">T</abbr>)
</p>
</div>
</a>
{% endfor %}
<p>Last updated: {{ rtmsmp(owned.last_updated) }} ago</p>
{% endif %}
{% if owned.data.games %}
{% if owned.games %}
<h3>Top played games:</h3>
{% set owned_games = owned.data.games | sort(attribute="playtime_forever", reverse=true) %}
{% 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>
@@ -44,16 +43,15 @@
<strong>{{ g.name }}</strong>
<p>
Total played:
{{ tmsmp(g.playtime_linux_forever*60) }} (<abbr title="On Linux">L</abbr>) +
{{ tmsmp(g.playtime_windows_forever*60) }} (<abbr title="On Windows">W</abbr>) =
{{ tmsmp(g.playtime_forever*60) }} (<abbr title="Total">T</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_forever) }} (<abbr title="Total">T</abbr>)
</p>
{% if g.rtime_last_played != 0 %}
<p>Last played: {{ utmsmp(g.rtime_last_played) }}</p>
<p>Last played: {{ rtmsmp(g.rtime_last_played) }}</p>
{% endif %}
</div>
</a>
{% endfor %}
<p>Last updated: {{ rtmsmp(owned.last_updated) }} ago</p>
{% endif %}
</div>