Compare commits
5
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1f7558e76c | ||
|
|
8c1ffdcdfe | ||
|
|
b78e4185d1 | ||
|
|
bf05be13ea | ||
|
|
b030991905 |
@@ -15,6 +15,7 @@ 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
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import os
|
||||
import magic
|
||||
from pathlib import Path
|
||||
from htmlmin import minify
|
||||
from datetime import datetime, timedelta
|
||||
@@ -53,7 +54,8 @@ def static(filename: str):
|
||||
|
||||
@bp.route("/asset/mb/<mbid>")
|
||||
def mb_cover(mbid):
|
||||
r = make_response(get_image_front(mbid, "250"))
|
||||
r = make_response(image := 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['Expires'] = (datetime.now() + timedelta(days=1)) \
|
||||
.strftime('%a, %d %b %Y %H:%M:%S GMT')
|
||||
@@ -61,8 +63,6 @@ def mb_cover(mbid):
|
||||
|
||||
@bp.route("/")
|
||||
def index():
|
||||
print(recent)
|
||||
|
||||
return render_tmpl(
|
||||
'index.html',
|
||||
lb=listens,
|
||||
|
||||
@@ -20,7 +20,8 @@ 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]['img_icon_url'] = get_cover_url(g['appid'])
|
||||
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"
|
||||
return json
|
||||
|
||||
def steam_request(interface: str, method: str, v: int = 1, **kwargs) -> requests.Response:
|
||||
@@ -59,7 +60,4 @@ 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,16 +51,13 @@ h3 {
|
||||
.steam {
|
||||
.block {
|
||||
display: flex;
|
||||
align-items: stretch;
|
||||
|
||||
img {
|
||||
height: 6rem;
|
||||
flex: 0 0 auto;
|
||||
height: 7rem;
|
||||
margin-right: .5rem;
|
||||
}
|
||||
|
||||
p {
|
||||
flex: 1;
|
||||
margin: .5rem 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,45 +1,52 @@
|
||||
<div class="block steam">
|
||||
<h2><a href="https://steamcommunity.com/id/risdeveau">Steam</a></h2>
|
||||
|
||||
<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 }}"/>
|
||||
{% 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>
|
||||
|
||||
<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 %}
|
||||
<div>
|
||||
<strong>{{ g.name }}</strong>
|
||||
<p>Played last 2 weeks: {{ tmsmp(g.playtime_2weeks) }}
|
||||
{% 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 %}
|
||||
<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 %}
|
||||
</div>
|
||||
|
||||
@@ -8,6 +8,8 @@ about host = About host
|
||||
contacts = Contacts
|
||||
donate = Donate
|
||||
|
||||
description = Small personal site
|
||||
|
||||
|
||||
[index]
|
||||
altfronts = Altfronts
|
||||
|
||||
@@ -8,6 +8,8 @@ about host = О хосте
|
||||
contacts = Контакты
|
||||
donate = Донат
|
||||
|
||||
description = Небольшой личный сайт
|
||||
|
||||
|
||||
[index]
|
||||
altfronts = Альтфронты
|
||||
|
||||
@@ -4,3 +4,4 @@ htmlmin2
|
||||
requests
|
||||
APScheduler
|
||||
musicbrainzngs
|
||||
python-magic
|
||||
|
||||
Reference in New Issue
Block a user