feat: パッチ6.1以降改修対応「名門屋敷 ハウケタ御用邸」完全攻略ページの作成と一覧リンク更新

This commit is contained in:
armonica committed 2026-10-29 12:11:14 +09:00
1 parent 6ffabaf917
commit 7cf01cb572
3 files changed
+331 -31

No files matched your search

+32 -30
View File
@@ -1,44 +1,46 @@
# -*- coding: utf-8 -*-
import os
import re
def clean_and_save(path, content):
content = content.replace('\r\n', '\n').replace('\r', '\n')
lines = [line.rstrip() for line in content.split('\n')]
result_lines = []
prev_empty = False
for line in lines:
if line == '':
if not prev_empty:
result_lines.append(line)
prev_empty = True
def normalize_file(path):
with open(path, 'rb') as f:
raw = f.read()
text = raw.decode('utf-8', errors='ignore')
while text.startswith('\ufeff'):
text = text[1:]
text = text.replace('\r\n', '\n').replace('\r', '\n')
lines = [l.rstrip() for l in text.split('\n')]
clean_lines = []
prev_blank = False
for l in lines:
if l == '':
if not prev_blank:
clean_lines.append(l)
prev_blank = True
else:
result_lines.append(line)
prev_empty = False
while result_lines and result_lines[-1] == '':
result_lines.pop()
text = '\r\n'.join(result_lines) + '\r\n'
text = text.lstrip('\ufeff')
clean_lines.append(l)
prev_blank = False
while clean_lines and clean_lines[-1] == '':
clean_lines.pop()
final_text = '\r\n'.join(clean_lines) + '\r\n'
with open(path, 'wb') as f:
f.write(b'\xef\xbb\xbf' + text.encode('utf-8'))
f.write(b'\xef\xbb\xbf' + final_text.encode('utf-8'))
print(f"Normalized {path}")
def update_dungeon_entry(name_keyword, url):
def update_dungeon_entry_exact(name_exact, url):
path_idx = 'dungeons/index.html'
with open(path_idx, 'rb') as f:
c = f.read().decode('utf-8', errors='ignore')
if f'href="{url}"' not in c:
c = c.replace('\r\n', '\n')
c = re.sub(rf'({re.escape(name_keyword)}.*?<td>)準備中(</td>)', rf'\g<1><a href="{url}">攻略を見る ➜</a>\2', c, flags=re.DOTALL)
clean_and_save(path_idx, c)
print(f"Updated {name_keyword} in {path_idx}")
pattern = rf'(<td><strong>{re.escape(name_exact)}</strong></td>.*?<td>)準備中(</td>)'
c = re.sub(pattern, rf'\g<1><a href="{url}">攻略を見る ➜</a>\2', c, count=1, flags=re.DOTALL)
with open(path_idx, 'wb') as f:
f.write(c.encode('utf-8'))
normalize_file(path_idx)
print(f"Updated {name_exact} in {path_idx}")
else:
print(f"Already updated {name_keyword}")
print(f"Already updated {name_exact}")
if __name__ == '__main__':
# 1. yuweyawata.html を正規化保存
raw_content = open('dungeons/yuweyawata.html', 'rb').read().decode('utf-8', errors='ignore')
clean_and_save('dungeons/yuweyawata.html', raw_content)
print("Cleaned and saved dungeons/yuweyawata.html")
# 2. dungeons/index.html を更新
update_dungeon_entry('ユウェヤーワータ', 'yuweyawata.html')
normalize_file('dungeons/haukke_manor.html')
update_dungeon_entry_exact('名門屋敷 ハウケタ御用邸', 'haukke_manor.html')