Skip to content

Commit f9a804e

Browse files
authored
May, 4 Updates (#37)
1 parent db274da commit f9a804e

File tree

6 files changed

+23
-18
lines changed

6 files changed

+23
-18
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ __pycache__
55
spectators.py*
66
.env
77
banner.png
8+
static.html

assets/templates/static_page.jinja2

+13-14
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
{% macro notification_channel() %}
2+
<!-- https://github.com/badges/shields/issues/10109 -->
3+
<a href="https://t.me/sammy_ofer_notification_channel" style="border: none; text-decoration: none;">
4+
<img src="https://img.shields.io/endpoint?color=neon&style=plastic&url=https%3A%2F%2Ftg.sumanjay.workers.dev%2Fsammy_ofer_notification_channel&label=Sammy%20Ofer%20Notification%20Channel" alt="Sammy Ofer Notification Channel">
5+
</a>
6+
{% endmacro -%}
17
<!DOCTYPE html>
28
<html lang="en">
39
<head>
@@ -12,15 +18,15 @@
1218
<link href="assets/templates/style.css" rel="stylesheet" type="text/css">
1319
<script>
1420
const currentDate = new Date();
15-
const day = currentDate.getDate();
16-
const month = ("0" + (currentDate.getMonth() + 1)).slice(-2);
17-
const year = currentDate.getFullYear();
21+
const day = currentDate.toLocaleString('en-US', { day: '2-digit' });
22+
const month = currentDate.toLocaleString('en-US', { month: '2-digit' });
23+
const year = currentDate.toLocaleString('en-US', { year: "numeric" });
1824
const todayDate = `${year}-${month}-${day}`;
1925
</script>
2026
</head>
2127
<body>
22-
{% for key, value in games.items() %}
23-
{% set scraped_date_time, league, home_team, home_team_en, home_team_url, game_hour, guest_team, guest_team_en, guest_team_url, game_time_delta, road_block_time, specs_word, specs_number, poll, notes, custom_sepcs_number, custom_road_block_time = value %}
28+
{% for key, value in games.items() -%}
29+
{% set scraped_date_time, league, home_team, home_team_en, home_team_url, game_hour, guest_team, guest_team_en, guest_team_url, game_time_delta, road_block_time, specs_word, specs_number, poll, notes, custom_sepcs_number, custom_road_block_time = value -%}
2430
<div id="container-{{loop.index}}" class="container">
2531
<div class="metadata">
2632
<div class="metadata-item">משחק ⚽ היום בשעה: {{ game_hour }}</div>
@@ -40,11 +46,8 @@
4046
<div class="metadata-item">📣: {{ notes }}</div>
4147
{% endif %}
4248
<div class="metadata-item"><img src="assets/images/qrcode.png" alt="QR Code" style="max-width: 100px; margin-top: 1rem;"></div>
43-
<!-- https://github.com/badges/shields/issues/10109 -->
4449
<div>
45-
<a href="https://t.me/sammy_ofer_notification_channel" style="border: none; text-decoration: none;">
46-
<img src="https://img.shields.io/endpoint?color=neon&style=plastic&url=https%3A%2F%2Ftg.sumanjay.workers.dev%2Fsammy_ofer_notification_channel&label=Sammy%20Ofer%20Notification%20Channel" alt="Sammy Ofer Notification Channel">
47-
</a>
50+
{{ notification_channel() | indent(8) }}
4851
</div>
4952
</div>
5053
</div>
@@ -55,15 +58,11 @@
5558
}
5659
</script>
5760
{% endfor %}
58-
5961
<div id="default-container" class="container" style="display: none;">
6062
<div class="metadata">
6163
<div class="metadata-item">המשחק ⚽ הבא: {{ games['game_1'][0] | babel_format_full_heb }}</div>
6264
<div class="metadata-item"><img src="assets/images/qrcode.png" alt="QR Code" style="max-width: 100px; margin-top: 1rem;"></div>
63-
<!-- https://github.com/badges/shields/issues/10109 -->
64-
<a href="https://t.me/sammy_ofer_notification_channel" style="border: none; text-decoration: none;">
65-
<img src="https://img.shields.io/endpoint?color=neon&style=plastic&url=https%3A%2F%2Ftg.sumanjay.workers.dev%2Fsammy_ofer_notification_channel&label=Sammy%20Ofer%20Notification%20Channel" alt="Sammy Ofer Notification Channel">
66-
</a>
65+
{{ notification_channel() | indent(6) }}
6766
</div>
6867
</div>
6968

cron.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,9 @@ async def send(msg, token=TELEGRAM_TOKEN, chat_id=TELEGRAM_CHANNEL_ID):
132132
if __name__ == "__main__":
133133
web = web_scrape.WebScrape()
134134
scrape = web.scrape()
135-
scraped_games = web.decoratored_games(scrape)
135+
scraped_games = web.decoratored_games(
136+
scrape
137+
) # also fetches teams logos and generates static page
136138
generated_data = check_games_today(scraped_games)
137139
detected_games_today = list(generated_data)
138140
message = create_message(detected_games_today)

logger.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
logging.basicConfig(
44
level=logging.INFO,
5-
format="{'time':'%(asctime)s', 'level': '%(levelname)s', 'message': '%(message)s'}",
6-
handlers=[logging.StreamHandler()]
5+
format="[%(asctime)s] [%(levelname)-8s] %(message)s (%(filename)s:%(lineno)s)",
6+
handlers=[logging.StreamHandler()],
77
)
88

99
logger = logging.getLogger(__name__)

static_html_page.py

+4
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ def gen_static_page(obj):
3838
f.write(content)
3939
logger.info(f"Generated {STATIC_HTML_FILENAME} from template")
4040

41+
if os.getenv("SKIP_COMMIT"):
42+
logger.info("SKIP_COMMIT is set, skipping git commit")
43+
return
44+
4145
git_commit()
4246

4347

web_scrape.py

-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
import re
1313

1414
import numpy as np
15-
import PIL
1615
from PIL import Image
1716

1817
from static_html_page import gen_static_page

0 commit comments

Comments
 (0)