Merge pull request #3 from mrwan200/git2

luv u ❤️
This commit is contained in:
M-307 2023-09-27 11:08:49 +07:00 committed by GitHub
commit a0e94de214
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 20 deletions

View File

@ -1,7 +1,7 @@
# GitHub repo
GITHUB_USERNAME="GITHUB_EXCEL_USERNAME"
GITHUB_REPOSITORY="GITHUB_EXCEL_REPO"
GITHUB_TOKEN="ghp_xxx"
GITHUB_PROJECT_ID="ghp_xxx"
# Folder
FOLDER="ExcelBinOutput"
@ -15,7 +15,7 @@ COSTUME="AvatarCostumeExcelConfigData.json"
# Avatar Skills Data
SKILLDEPOT="AvatarSkillDepotExcelConfigData.json" # Skill Depot
SKILLS="AvatarSkillExcelConfigData.json"# Skills
SKILLS="AvatarSkillExcelConfigData.json" # Skills
TALENTS="AvatarTalentExcelConfigData.json" # AKA. Constellations
# Equipment Data
@ -30,4 +30,8 @@ FIGHT_PROPS="ManualTextMapConfigData.json"
PROPS_MAP="ProudSkillExcelConfigData.json"
# Namecards
NAMECARDS="MaterialExcelConfigData.json"
NAMECARDS="MaterialExcelConfigData.json"
# Artifact main & sub
ARTIFACT_PROPS_MAIN="ReliquaryMainPropExcelConfigData.json"
ARTIFACT_PROPS_SUB="ReliquaryAffixExcelConfigData.json"

35
main.py
View File

@ -18,18 +18,18 @@ from utils import (
save_data
)
# API GitHub
GITHUB_SITE = "https://github.com/{PATH}"
GITHUB = "https://api.github.com/{PATH}"
RAW_GITHUB = "https://raw.githubusercontent.com/{PATH}"
# API GIT
GIT2="https://gitlab.com/api/v4/{PATH}"
RAW_GIT2 = "https://gitlab.com/{PATH}"
# Logging
logging.basicConfig(level=logging.DEBUG)
LOGGER = logging.getLogger(__name__)
# GITHUB
# GIT
USERNAME = os.getenv('GITHUB_USERNAME')
REPOSITORY = os.getenv('GITHUB_REPOSITORY')
PROJECT_ID = os.getenv('GITHUB_PROJECT_ID')
# Check is DEV_MODE
DEVMODE = sys.argv[1] == "dev" if len(sys.argv) > 1 else False
@ -80,17 +80,18 @@ async def create_lang(data: dict, filename: str = "", has_key_name_hash: bool =
async def main():
EXPORT_DATA = {}
LOGGER.debug(f"Fetching commits from GitHub [{USERNAME}/{REPOSITORY}]")
response = await request(GITHUB.format(PATH=f"repos/{USERNAME}/{REPOSITORY}/commits"))
LOGGER.debug(f"Fetching commits from Git. [{USERNAME}/{REPOSITORY}]")
response = await request(GIT2.format(PATH=f"/projects/{PROJECT_ID}/repository/commits"))
# print(response)
# Check SHA of last commit
LOGGER.debug(f"Checking last commit on GitHub...")
LOGGER.debug(f"Checking last commit on Git...")
if len(response) > 0:
last_commit = response[0]["sha"]
last_message = response[0]["commit"]["message"]
LOGGER.debug(f"Last commit on GitHub: {last_commit}")
last_commit = response[0]["id"]
last_message = response[0]["title"]
LOGGER.debug(f"Last commit on Git: {last_commit}")
else:
LOGGER.debug("No commits found on GitHub...")
LOGGER.debug("No commits found on Git...")
last_commit = ""
LOGGER.debug(f"Checking last commit on local...")
@ -99,7 +100,7 @@ async def main():
LOGGER.debug(f"Not updated... exiting...")
return
LOGGER.debug(f"New commit found on GitHub")
LOGGER.debug(f"New commit found on git")
if not SKIP_DOWNLOAD:
for key in ENVKEY:
@ -110,7 +111,7 @@ async def main():
continue
await download_json(
url=RAW_GITHUB.format(PATH=f"{USERNAME}/{REPOSITORY}/master/{os.getenv('FOLDER')}/{filename}"),
url=RAW_GIT2.format(PATH=f"{USERNAME}/{REPOSITORY}/-/raw/master/{os.getenv('FOLDER')}/{filename}"),
filename=filename,
path=os.path.join("raw", "data")
)
@ -118,10 +119,10 @@ async def main():
await asyncio.sleep(1)
if not SKIP_DOWNLOAD:
langPath = await request(GITHUB.format(PATH=f"repos/{USERNAME}/{REPOSITORY}/contents/{os.getenv('LANG_FOLDER')}"))
langPath = await request(GIT2.format(PATH=f"/projects/{PROJECT_ID}/repository/tree?recursive=true&path={os.getenv('LANG_FOLDER')}"))
for lang in langPath:
await download_json(
url=lang["download_url"],
url=RAW_GIT2.format(PATH=f"{USERNAME}/{REPOSITORY}/-/raw/master/{lang['path']}"),
filename=lang["name"],
path=os.path.join("raw", "langs")
)