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