release 1.0.0
All checks were successful
Upload release / build (push) Successful in 5s

This commit is contained in:
Mylloon 2024-09-29 00:38:21 +02:00
parent 750b69843f
commit 97b9ea356d
Signed by: Anri
GPG key ID: A82D63DFF8D1317F
2 changed files with 46 additions and 23 deletions

View file

@ -16,8 +16,8 @@ CLS
IF ERRORLEVEL 1 (
ECHO Installation of Python not found, installation...
:: Install Python 3.11 from MS Store
ECHO Y | winget install -he 9NRWMJP3717K
:: Install Python 3.12 from MS Store
ECHO Y | winget install -he 9NCVDN91XZQP
ECHO Download and installation of dependencies...
@ -34,14 +34,11 @@ IF ERRORLEVEL 1 (
!py! -m !pipR! >NUL
)
:: Download images under %TEMP%\images
REM TODO
:: Write the program
CALL :getLine "::python_beg" "::python_end" > "!tmpFile!"
:: Run the program
PowerShell -Command "Start-Process cmd -Argument '/c START /B python !tmpFile!' -WindowStyle hidden"
!py! "!tmpFile!" online
EXIT /B
:getLine <beg str> <end str>

38
main.py
View file

@ -1,10 +1,12 @@
from random import choice
from os import makedirs
from os.path import join
from random import choice
from sys import argv
from urllib.request import urlretrieve
from PIL import Image, ImageDraw, ImageFont
def generate_horoscope() -> dict[str, dict[str, str]]:
zodiac_signs = [
zodiac_signs = [
"Belier",
"Cancer",
"Balance",
@ -17,8 +19,11 @@ def generate_horoscope() -> dict[str, dict[str, str]]:
"Vierge",
"Sagittaire",
"Poissons",
]
]
def generate_horoscope() -> dict[str, dict[str, str]]:
"""Generate horoscope predictions"""
horoscope = {}
for sign in zodiac_signs:
love = choice(["+++", "++", "+", "-", "- -"])
@ -27,7 +32,13 @@ def generate_horoscope() -> dict[str, dict[str, str]]:
return horoscope
def get_path(image: str):
"""Return the path of the image"""
return join("images", f"{image.lower()}.png")
def create_horoscope_image(horoscope: dict[str, dict[str, str]]):
"""Generate horoscope images"""
img_width, img_height = 1200, 425
image = Image.new("RGBA", (img_width, img_height), color=(255, 255, 255, 0))
draw = ImageDraw.Draw(image)
@ -39,7 +50,7 @@ def create_horoscope_image(horoscope: dict[str, dict[str, str]]):
x, y = 10, 10
for sign, prediction in horoscope.items():
sign_image = Image.open(join("images", f"{sign.lower()}.png")).convert("RGBA")
sign_image = Image.open(get_path(sign)).convert("RGBA")
sign_image.thumbnail((100, 105))
image.paste(sign_image, (x + 20, y), sign_image)
@ -80,7 +91,22 @@ def create_horoscope_image(horoscope: dict[str, dict[str, str]]):
return image
def download_images():
"""Download images from source"""
url = "https://git.mylloon.fr/Anri/Horoscope/raw/branch/main/images/"
makedirs("images", exist_ok=True)
for el in zodiac_signs + ["love", "work"]:
urlretrieve(url + el.lower() + ".png", get_path(el))
if __name__ == "__main__":
if len(argv) > 2 or (len(argv) == 2 and argv[1] != "online"):
exit(1)
if len(argv) == 2:
download_images()
# Generate new horoscope
new_horoscope = generate_horoscope()