75 lines
2.5 KiB
Python
75 lines
2.5 KiB
Python
import argparse
|
|
from instagrapi import Client
|
|
import json, os
|
|
from datetime import datetime, timedelta
|
|
import library.lib as lib
|
|
|
|
# Start timing the script
|
|
start_time = datetime.now()
|
|
|
|
# Argument parser for command-line options
|
|
parser = argparse.ArgumentParser(description="Upload meal information to Instagram and Discord.")
|
|
parser.add_argument('--today', action='store_true', help="Use today's date instead of tomorrow's date for the MLSV_YMD timestamp.")
|
|
args = parser.parse_args()
|
|
|
|
# Set MLSV_YMD date based on the --today option
|
|
if args.today:
|
|
MLSV_YMD = datetime.now().strftime('%Y%m%d')
|
|
else:
|
|
MLSV_YMD = (datetime.now() + timedelta(days=1)).strftime('%Y%m%d')
|
|
|
|
print("🍪 | Retrieving saved account information.")
|
|
cl = Client(json.load(open('./temp/auth/cookies.json')))
|
|
cl.set_proxy("socks5h://localhost:9999")
|
|
|
|
print("🍪 | Account information was successfully retrieved.")
|
|
|
|
print("📅 | Getting MLSV_YMD Timestamp")
|
|
print("📅 | Date:", MLSV_YMD)
|
|
|
|
print("🍲 | Getting Meal Info Image")
|
|
lib.얻기(MLSV_YMD)
|
|
|
|
lib.스토리_얻기(MLSV_YMD)
|
|
print("📸 | Uploading Story")
|
|
cl.photo_upload_to_story(
|
|
path=f"temp/{MLSV_YMD}-story.png",
|
|
caption=f"#인천상정중학교 #상정중학교 #급식 \n{MLSV_YMD}일자 급식",
|
|
extra_data={'is_paid_partnership': False}
|
|
)
|
|
print("📸 | Story Uploaded")
|
|
|
|
lib.얻기(MLSV_YMD)
|
|
print("🖼️ | Uploading Post")
|
|
cl.photo_upload(
|
|
f"temp/{MLSV_YMD}.png",
|
|
caption=f"#인천상정중학교 #상정중학교 #급식 \n{MLSV_YMD}일자 급식",
|
|
extra_data={'is_paid_partnership': False}
|
|
)
|
|
print("🖼️ | Post Uploaded")
|
|
|
|
print("🗨️ | Uploading at Discord")
|
|
lib.디스코드(MLSV_YMD)
|
|
print("🗨️ | Uploaded at Discord")
|
|
|
|
print(f"📆 | Today Date : {MLSV_YMD}")
|
|
# Check if today is the last day of the month
|
|
오늘 = datetime.today()
|
|
내일 = 오늘 + timedelta(days=1)
|
|
|
|
if 내일.month != 오늘.month:
|
|
print("📅 | Today is the last day of the month.")
|
|
print("📆 | Uploading School Event Post")
|
|
학사일정_경로 = lib.학사일정_얻기()
|
|
cl.photo_upload(
|
|
학사일정_경로,
|
|
caption=f"#인천상정중학교 #상정중학교 #학사일정 \n{내일.strftime("%Y")}년 {내일.strftime("%m")}월 학사일정",
|
|
extra_data={'is_paid_partnership': False}
|
|
)
|
|
print("📆 | School Event Post Uploaded")
|
|
else:
|
|
print("📅 | Today is not the last day of the month.")
|
|
|
|
print("🎉 | All tasks completed.")
|
|
# Calculate running time
|
|
print("🕒 | Running Time:", datetime.now() - start_time)
|