Skip to content

Commit 7ab1b7d

Browse files
authored
Wed, 7 Update (#63)
1 parent 109503d commit 7ab1b7d

File tree

8 files changed

+50
-8
lines changed

8 files changed

+50
-8
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@ uv pip install -r requirements.txt
6060
flask run --debug --port=5001
6161
```
6262

63+
Manually run cron job
64+
```
65+
python -c "from scheduler import run_job; run_job()"
66+
```
67+
6368
## TODO
6469
I'm out of ideas...
6570

assets/teams/Neot Peres.png

17.4 KB
Loading

assets/teams/Osher Cohen.png

89.7 KB
Loading

assets/templates/static_page.jinja2

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
{% for game in upcoming -%}
3838
<div id="container-{{loop.index}}" class="container">
3939
<div class="metadata">
40-
<div class="metadata-item">משחק ⚽ היום בשעה: {{ game.game_hour }}</div>
40+
<div class="metadata-item">אירוע 🏟️ היום בשעה: {{ game.game_hour }}</div>
4141
</div>
4242
<div class="team">
4343
<div class="team-logo" style="background-image: url('assets/teams/{{ game.home_team_en }}.png');"></div>
@@ -68,11 +68,11 @@
6868
{% endfor %}
6969
<div id="default-container" class="container" style="display: none;">
7070
<div class="metadata">
71-
<div class="metadata-item">המשחק ⚽ הבא:
71+
<div class="metadata-item">אירוע 🏟️ הבא:
7272
{% if upcoming and upcoming|length > 0 %}
7373
{{ upcoming[0].get('scraped_date_time') | babel_format_full_heb }}
7474
{% else %}
75-
אין משחקים קרבים
75+
אין אירועים קרובים
7676
{% endif %}
7777
</div>
7878
<div class="metadata-item"><img src="assets/images/qrcode.png" alt="QR Code" style="max-width: 100px; margin-top: 1rem;"></div>

html_templates/next.html

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,11 @@
109109
<p>
110110
<div id="result_action"></div>
111111
</p>
112-
<a href="/scheduler">תיזמונים</a>
112+
<li>
113+
<a href="/scheduler">תיזמונים</a> |
114+
<a href="https://yeshmishak.top/static.html">עמוד תצוגה</a> |
115+
<a href="https://yeshmishak.top/cal.html">יומן</a>
116+
</li>
113117
</div>
114118

115119
<script>

metadata.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,11 @@
6565
"url": "https://www.football.co.il/maccabi-tel-aviv",
6666
"logo": "https://static.football.co.il/wp-content/themes/kingclub-theme/images/teams/4536.png",
6767
},
68+
"מכבי תל-אביב": {
69+
"name": "Maccabi Tel Aviv",
70+
"url": "https://www.football.co.il/maccabi-tel-aviv",
71+
"logo": "https://static.football.co.il/wp-content/themes/kingclub-theme/images/teams/4536.png",
72+
},
6873
"עירוני טבריה": {
6974
"name": "Ironi Tveria",
7075
"url": "https://www.football.co.il/ironi-tveria/",
@@ -115,6 +120,16 @@
115120
"url": "https://www.football.co.il/maccabi-petah-tikva/",
116121
"logo": "https://static.football.co.il/wp-content/themes/kingclub-theme/images/teams/15006.png",
117122
},
123+
"אושר כהן": {
124+
"name": "Osher Cohen",
125+
"url": "https://youtube.com/user/OfficialOsherCohen",
126+
"logo": "",
127+
},
128+
"תושבי נאות פרס": {
129+
"name": "Neot Peres",
130+
"url": "https://www.facebook.com/groups/pereshaifa/",
131+
"logo": "",
132+
},
118133
}
119134

120135
EMOJI_HEARTS = [

send_notification.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def create_message(obj_data):
5656

5757
yield (
5858
f"""
59-
משחק ⚽ *היום* בשעה *{row.game_hour}*
59+
אירוע 🏟️ *היום* בשעה *{row.game_hour}*
6060
*{row.league}*: [{escape_markdown_v2(row.home_team)}]({row.home_team_url}) \\|\\| [{escape_markdown_v2(row.guest_team)}]({row.guest_team_url})
6161
צפי חסימת כבישים: *{row.custom_road_block_time}*
6262
צפי אוהדים משוער: *{row.specs_word}* {escape_markdown_v2(f"({row.specs_number:,})")} {row.specs_emoji}

web_scrape.py

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -253,11 +253,29 @@ def banner(self):
253253
)
254254

255255
banner_list = [guest_team_fname, versus_image_fname, home_team_fname]
256-
images = [Image.open(i) for i in banner_list]
257256

258-
# pick the image which is the smallest, and resize the others to match it (can be arbitrary image shape here)
257+
# Open images and convert all to RGB mode for consistency
258+
images = []
259+
for img_path in banner_list:
260+
img = Image.open(img_path)
261+
if img.mode != "RGB":
262+
white_bg = Image.new("RGB", img.size, (255, 255, 255))
263+
264+
if img.mode == "RGBA":
265+
white_bg.paste(img, (0, 0), img)
266+
img = white_bg
267+
else:
268+
img = img.convert("RGB")
269+
images.append(img)
270+
271+
# pick the image which is the smallest, and resize the others to match it
259272
min_shape = sorted([(np.sum(i.size), i.size) for i in images])[0][1]
260-
hstack = np.hstack([i.resize(min_shape) for i in images])
273+
274+
# Resize all images to the same shape before stacking
275+
resized_images = [np.array(img.resize(min_shape)) for img in images]
276+
277+
# Stack the images horizontally
278+
hstack = np.hstack(resized_images)
261279

262280
images_combine = Image.fromarray(hstack)
263281
final_size = (770, 300) # best found to fit telegram photo on mobile

0 commit comments

Comments
 (0)