From 4140406c8835256e60c604f78da2b4b07e84bcb6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=95=94=EB=83=A5?= Date: Sun, 2 Mar 2025 23:23:45 +0900 Subject: [PATCH] =?UTF-8?q?VTS=20=EC=B4=88=EB=B3=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/library/lib.py | 15 ++++++++-- app/library/vts.py | 72 +++++++++++++++++----------------------------- app/run.py | 5 ++++ app/temp.py | 15 ++++++++-- 4 files changed, 56 insertions(+), 51 deletions(-) diff --git a/app/library/lib.py b/app/library/lib.py index 59dcc22..b682ebf 100644 --- a/app/library/lib.py +++ b/app/library/lib.py @@ -42,7 +42,6 @@ def 급식_칼로리_얻기(MLSV_YMD:str): ) return 답장.json()['mealServiceDietInfo'][1]['row'][0]['CAL_INFO'] - def 얻기(MLSV_YMD:str): print("집가고싶다발동") 급식 = 급식_정보_얻기(MLSV_YMD) @@ -59,8 +58,11 @@ def 얻기(MLSV_YMD:str): 제목요소.text((75, 930 - i * 60), line, font=급식_폰트, anchor="ls", fill=(255, 255, 255)) 세부요소 = ImageDraw.Draw(사진) - 세부요소.text((767, 80), f"{MLSV_YMD[:4]}년 {MLSV_YMD[4:6]}월 {MLSV_YMD[6:8]}일", font=세부_폰트, fill=(255, 255, 255)) - 세부요소.text((825, 200), f"{급식_칼로리_얻기(MLSV_YMD)}", font=세부_폰트, fill=(137, 202, 255)) + 세부요소.text((945, 110), f"{MLSV_YMD[:4]}년 {MLSV_YMD[4:6]}월 {MLSV_YMD[6:8]}일", font=세부_폰트, anchor="rs", fill=(255, 255, 255)) + #세부요소.text((755, 80), f"2025년 01월 01일", font=세부_폰트, fill=(255, 255, 255)) + 세부요소.text((945, 220), f"{급식_칼로리_얻기(MLSV_YMD)}", font=세부_폰트, anchor="rs", fill=(137, 202, 255)) + if vts.VTS임(MLSV_YMD): + 세부요소.text((830, 225), "with V.T.S.", font=세부_폰트, fill=(205, 173, 148)) 사진.save(f'{ROOT}/temp/{MLSV_YMD}.png') @@ -114,7 +116,10 @@ def 스토리_얻기(MLSV_YMD:str): print("이건 왜?") # 1:1 to 9:16 temp/{MLSV_YMD}.png + 사진 = None + 사진 = Image.open(f"{ROOT}/temp/{MLSV_YMD}.png") + 가로, 세로 = 사진.size 비율 = 9 / 16 가로_비율 = 가로 / 세로 @@ -150,6 +155,10 @@ def 디스코드(MLSV_YMD:str): } ] + if vts.VTS임(MLSV_YMD): + data["content"] = f"{MLSV_YMD} | with V.T.S." + + print("🏓 | Sending Payload") result = requests.post(WEBHOOK_URL, json = data) print("🏓 | Payload Sent") diff --git a/app/library/vts.py b/app/library/vts.py index b97cc1d..132f482 100644 --- a/app/library/vts.py +++ b/app/library/vts.py @@ -1,57 +1,37 @@ import requests, datetime from bs4 import BeautifulSoup -import openpyxl, os +import openpyxl, os, json -def get_board(): - url = "http://isangjeong.icems.kr/boardCnts/list.do?searchType=S&page=1&boardID=33523&prntBoardID=0&prntBoardSeq=0&prntLev=0&m=0601&s=isangjeong" +with open('./config.json') as json_file: + json_data = json.load(json_file) + KEY = json_data['KEY'] + ROOT = json_data['ROOT'] + font = f"{ROOT}/library/Pretendard-Bold.ttf" + WEBHOOK_URL = json_data['WEBHOOK_URL'] - response = requests.get(url) +path = f'{ROOT}temp/downloaded_file.xlsx' - soup = BeautifulSoup(response.text, "html.parser") - - element = soup.select_one("html body div:nth-of-type(2) div:nth-of-type(3) div div:nth-of-type(2) section:nth-of-type(2) div:nth-of-type(2) div:nth-of-type(2) div:nth-of-type(2) div form table tbody tr:nth-of-type(1) td:nth-of-type(2) a") - onclick_value = element.get("onclick") - - values = str(onclick_value[18:-1].replace("'", "")).replace(" ", "").split(",") -# for i in values: -# print(i) - - return f"http://isangjeong.icems.kr/boardCnts/updateCnt.do?boardID={values[0]}&viewBoardID={values[1]}&boardSeq={values[2]}&lev={values[3]}" - -path = f'{os.getenv('ROOT')}temp/downloaded_file.xlsx' - -def download(url:str): - response = requests.get(url) - soup = BeautifulSoup(response.text, "html.parser") - element = soup.select_one("html > body > div:nth-of-type(2) > div:nth-of-type(3) > div > div:nth-of-type(2) > section:nth-of-type(2) > div:nth-of-type(2) > div:nth-of-type(2) > div:nth-of-type(2) > div > form > table > tbody > tr:nth-of-type(2) > td > p > a:nth-of-type(1)") - herf_value = element.get("href") - - response = requests.get("http://isangjeong.icems.kr"+herf_value) +def download(): + response = requests.get("https://f.imnya.ng/.today.isangjeong/vts.xlsx") with open(path, "wb") as file: file.write(response.content) -def get_vts(): - #download(get_board()) - ws = openpyxl.load_workbook(path).active - - vts_list = [] - - for row in ws.iter_rows(min_row=5, max_row=5, min_col=7, max_col=14): +def detect_vts_day(): + # 엑셀 파일 로드 + ws = openpyxl.load_workbook(path, data_only=True).active + + # 노란색 색상 코드 + yellow_color = "FFFFFF00" + + # 색상이 있는 셀 확인 + vts_days = [] + for row in ws.iter_rows(min_row=5, max_row=5): for cell in row: - if cell.fill.start_color.index == 'FFFFFF00': - value = str(cell.value).split('(')[0].strip()\ - .replace(" ", "")\ - .replace("월", "")\ - .replace("일", "") - vts_list.append(f"{datetime.datetime.today().year}{value}") - return vts_list + if cell.fill and cell.fill.start_color.index == yellow_color: + vts_days.append(cell.value.split(" ")[1].replace("일", "").replace("(", "").replace(")", "")[:-1]) -def get_vts_true_or_false(): - vts_list = get_vts() - today = datetime.datetime.today().strftime("%Y%m%d") - if today in vts_list: - return True - else: - return False - return False + return vts_days + +def VTS임(MSLV_YMD:str): + return str(MSLV_YMD)[-2:] in detect_vts_day() diff --git a/app/run.py b/app/run.py index 721cd38..a8e9ea5 100644 --- a/app/run.py +++ b/app/run.py @@ -3,6 +3,7 @@ from instagrapi import Client import json, os from datetime import datetime, timedelta import library.lib as lib +import library.vts as vts # Start timing the script start_time = datetime.now() @@ -24,6 +25,10 @@ cl.set_proxy("socks5h://localhost:9999") print("🍪 | Account information was successfully retrieved.") +print("📅 | Getting VTS Table") +vts.download() +print("📅 | VTS Table Downloaded") + print("📅 | Getting MLSV_YMD Timestamp") print("📅 | Date:", MLSV_YMD) diff --git a/app/temp.py b/app/temp.py index f5168c5..0e47ea0 100644 --- a/app/temp.py +++ b/app/temp.py @@ -1,3 +1,14 @@ -import library.lib as 라이브러리 +#import library.lib as 라이브러리 -라이브러리.학사일정_얻기() \ No newline at end of file +#라이브러리.얻기("20250307") +#라이브러리.스토리_얻기("20250307") +#라이브러리.얻기("20250306") +#라이브러리.스토리_얻기("20250306") + +import library.vts as vts +vts.download() + +print(vts.detect_vts_day()) + +print(vts.VTS임(20250307)) +print(vts.VTS임(20250306)) \ No newline at end of file