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

60
main.py
View file

@ -1,24 +1,29 @@
from random import choice from os import makedirs
from os.path import join from os.path import join
from random import choice
from sys import argv
from urllib.request import urlretrieve
from PIL import Image, ImageDraw, ImageFont from PIL import Image, ImageDraw, ImageFont
zodiac_signs = [
"Belier",
"Cancer",
"Balance",
"Capricorne",
"Taureau",
"Lion",
"Scorpion",
"Verseau",
"Gemeaux",
"Vierge",
"Sagittaire",
"Poissons",
]
def generate_horoscope() -> dict[str, dict[str, str]]: def generate_horoscope() -> dict[str, dict[str, str]]:
zodiac_signs = [ """Generate horoscope predictions"""
"Belier",
"Cancer",
"Balance",
"Capricorne",
"Taureau",
"Lion",
"Scorpion",
"Verseau",
"Gemeaux",
"Vierge",
"Sagittaire",
"Poissons",
]
horoscope = {} horoscope = {}
for sign in zodiac_signs: for sign in zodiac_signs:
love = choice(["+++", "++", "+", "-", "- -"]) love = choice(["+++", "++", "+", "-", "- -"])
@ -27,7 +32,13 @@ def generate_horoscope() -> dict[str, dict[str, str]]:
return horoscope 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]]): def create_horoscope_image(horoscope: dict[str, dict[str, str]]):
"""Generate horoscope images"""
img_width, img_height = 1200, 425 img_width, img_height = 1200, 425
image = Image.new("RGBA", (img_width, img_height), color=(255, 255, 255, 0)) image = Image.new("RGBA", (img_width, img_height), color=(255, 255, 255, 0))
draw = ImageDraw.Draw(image) draw = ImageDraw.Draw(image)
@ -39,7 +50,7 @@ def create_horoscope_image(horoscope: dict[str, dict[str, str]]):
x, y = 10, 10 x, y = 10, 10
for sign, prediction in horoscope.items(): 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)) sign_image.thumbnail((100, 105))
image.paste(sign_image, (x + 20, y), sign_image) 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 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 __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 # Generate new horoscope
new_horoscope = generate_horoscope() new_horoscope = generate_horoscope()