Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .gitattributes

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
name: Update Star Rail Resources
name: Update Files

on:
workflow_dispatch:
push:
branches: [main]
paths:
- "fonts/**"
- "LittlePaimon/**"

jobs:
update:
name: Update Star Rail Resources
name: Update Files
runs-on: ubuntu-latest
steps:
- name: Checkout repo
Expand All @@ -27,7 +32,7 @@ jobs:
run: |
python update_starrail_res.py

- name: Update Files
- name: Update files
run: |
python generate_res_list.py

Expand All @@ -36,5 +41,27 @@ jobs:
with:
author_name: github-actions[bot]
author_email: github-actions[bot]@users.noreply.github.com
message: ":wrench: 自动更新星铁资源"
message: ":wrench: 自动更新资源列表"
add: .

- uses: dev-drprasad/delete-tag-and-release@v1.1
with:
tag_name: Resources-V1.0
github_token: ${{ secrets.GITHUB_TOKEN }}

- name: Tag Repo
uses: richardsimko/update-tag@v1
with:
tag_name: Resources-V1.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Upload Resources
uses: softprops/action-gh-release@v2
if: ${{ success() }}
with:
tag_name: Resources-V1.0
append_body: true
files: |
resources.zip
star_rail.zip
38 changes: 0 additions & 38 deletions .github/workflows/update_file.yml

This file was deleted.

4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,6 @@ LittlePaimon/furniture
LittlePaimon/material
LittlePaimon/genshin_map/results
genshin_guide/guide/download.py
.idea
.idea
resources.zip
star_rail.zip
76 changes: 45 additions & 31 deletions generate_res_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,58 +3,72 @@
import zipfile
from pathlib import Path

font_path = Path(__file__).parent / 'fonts'
res_path = Path(__file__).parent / 'LittlePaimon'
img_path = Path(__file__).parent / 'genshin_img'
font_path = Path(__file__).parent / "fonts"
res_path = Path(__file__).parent / "LittlePaimon"
img_path = Path(__file__).parent / "genshin_img"

exclude_path = ['avatar', 'avatar_side', 'talent', 'weapon', 'splash', 'results', 'material', 'other', 'furniture']
unlock_list = ['general']
exclude_path = [
"avatar",
"avatar_side",
"talent",
"weapon",
"splash",
"results",
"material",
"other",
"furniture",
]
unlock_list = ["general"]

emoticons_temp = []

file_list = [{
'path': f'{file.parent.name}/{file.name}',
'hash': hashlib.md5(file.read_bytes()).hexdigest(),
'lock': True
} for file in font_path.iterdir()]
file_list = [
{
"path": f"{file.parent.name}/{file.name}",
"hash": hashlib.md5(file.read_bytes()).hexdigest(),
"lock": True,
}
for file in font_path.iterdir()
]

this_path = str(Path().absolute())

for file in res_path.rglob('*'):
for file in res_path.rglob("*"):
if not file.is_file():
continue
if file.parent.name not in exclude_path:
if file.parent.name.startswith('emoticons'):
if file.name.split('-')[0] in emoticons_temp:
if file.parent.name.startswith("emoticons"):
if file.name.split("-")[0] in emoticons_temp:
continue
else:
emoticons_temp.append(file.name.split('-')[0])
if file.parent.name.startswith('artifact') and file.name.startswith('UI'):
emoticons_temp.append(file.name.split("-")[0])
if file.parent.name.startswith("artifact") and file.name.startswith("UI"):
continue
file_list.append({
'path': str(file).replace(this_path, '').replace('\\', '/').lstrip('/'),
'hash': hashlib.md5(file.read_bytes()).hexdigest(),
'lock': False if file.parent.name in unlock_list else True
"path": str(file).replace(this_path, "").replace("\\", "/").lstrip("/"),
"hash": hashlib.md5(file.read_bytes()).hexdigest(),
"lock": False if file.parent.name in unlock_list else True,
})

with open('resources_list.json', 'w', encoding='utf-8') as f:
with open("resources_list.json", "w", encoding="utf-8") as f:
json.dump(file_list, f, ensure_ascii=False, indent=2)


img_list = {chara.name: [img.name for img in chara.iterdir()] for chara in img_path.iterdir()}
img_list = {
chara.name: [img.name for img in chara.iterdir()] for chara in img_path.iterdir()
}

with open('genshin_img_list.json', 'w', encoding='utf-8') as f:
with open("genshin_img_list.json", "w", encoding="utf-8") as f:
json.dump(img_list, f, ensure_ascii=False, indent=2)

# 暂时关闭zip打包,等待解决lfs超出大小问题后恢复
# resources_zip_path = Path() / 'resources.zip'
# resources_zip = zipfile.ZipFile(resources_zip_path, 'w', zipfile.ZIP_DEFLATED)
resources_zip_path = Path() / "resources.zip"
resources_zip = zipfile.ZipFile(resources_zip_path, "w", zipfile.ZIP_DEFLATED)

# for file in Path('fonts').iterdir():
# resources_zip.write(file)
# for file in Path('LittlePaimon').rglob('*'):
# exclude_path_ = exclude_path + ["character_portrait"]
# if file.name not in exclude_path_ and file.parent.name not in exclude_path_:
# resources_zip.write(file)
for file in Path("fonts").iterdir():
resources_zip.write(file)
for file in Path("LittlePaimon").rglob("*"):
exclude_path_ = exclude_path + ["character_portrait"]
if file.name not in exclude_path_ and file.parent.name not in exclude_path_:
resources_zip.write(file)

# resources_zip.close()
resources_zip.close()
3 changes: 0 additions & 3 deletions resources.zip

This file was deleted.

3 changes: 0 additions & 3 deletions star_rail.zip

This file was deleted.

10 changes: 5 additions & 5 deletions update_starrail_res.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import asyncio
import os
# import zipfile
import zipfile
from pathlib import Path

import httpx
Expand Down Expand Up @@ -88,8 +88,8 @@ async def limited_download(client, url, semaphore, pbar):

if __name__ == "__main__":
asyncio.run(download_res())
# path = this_path + "/star_rail.zip"
# with zipfile.ZipFile(path, "w") as zf:
# for file in star_rail_res_path.rglob("*"):
# zf.write(file, file.relative_to(star_rail_res_path))
path = this_path + "/star_rail.zip"
with zipfile.ZipFile(path, "w") as zf:
for file in star_rail_res_path.rglob("*"):
zf.write(file, file.relative_to(star_rail_res_path))
print("StarRailRes updated.")