Add Steam info
This commit is contained in:
@@ -2,6 +2,7 @@ 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 (
|
||||
@@ -14,6 +15,30 @@ from flask import (
|
||||
)
|
||||
|
||||
from .modules.api.lb import listens, listening
|
||||
from .modules.api.steam import recent, owned
|
||||
|
||||
def tmsmp(sec: int) -> str:
|
||||
if sec == 0:
|
||||
return 0
|
||||
elif sec < 60:
|
||||
return f"{sec} s"
|
||||
elif sec < 60*60:
|
||||
minutes = round(sec / 60, 1)
|
||||
return f"{minutes:.0f} m" if minutes.is_integer() else f"{minutes:.1f} m"
|
||||
elif sec < 60*60*24:
|
||||
hours = round(sec / 3600, 1)
|
||||
return f"{hours:.0f} h" if hours.is_integer() else f"{hours:.1f} h"
|
||||
else:
|
||||
days = round(sec / 86400, 1)
|
||||
return f"{days:.0f} d" if days.is_integer() else f"{days:.1f} d"
|
||||
|
||||
def utmsmp(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",
|
||||
@@ -47,6 +72,16 @@ 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', lb=listens, lb_now=listening)
|
||||
return render_tmpl('index.html', **args)
|
||||
|
||||
Reference in New Issue
Block a user