VTS 초보

This commit is contained in:
암냥 2025-03-02 23:23:45 +09:00
commit 4140406c88
4 changed files with 56 additions and 51 deletions

View file

@ -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")

View file

@ -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()

View file

@ -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)

View file

@ -1,3 +1,14 @@
import library.lib as 라이브러리
#import library.lib as 라이브러리
라이브러리.학사일정_얻기()
#라이브러리.얻기("20250307")
#라이브러리.스토리_얻기("20250307")
#라이브러리.얻기("20250306")
#라이브러리.스토리_얻기("20250306")
import library.vts as vts
vts.download()
print(vts.detect_vts_day())
print(vts.VTS임(20250307))
print(vts.VTS임(20250306))