Files
ff14-guide/tools/update_amaurot.py
T

52 lines
1.8 KiB
Python

# -*- coding: utf-8 -*-
import sys
def normalize_file(filepath):
with open(filepath, 'r', encoding='utf-8') as f:
content = f.read()
content = content.lstrip('\ufeff')
lines = [line.rstrip() for line in content.splitlines()]
norm_lines = []
prev_blank = False
for line in lines:
if line == '':
if not prev_blank:
norm_lines.append(line)
prev_blank = True
else:
norm_lines.append(line)
prev_blank = False
result = '\r\n'.join(norm_lines) + '\r\n'
with open(filepath, 'wb') as f:
f.write(b'\xef\xbb\xbf' + result.encode('utf-8'))
normalize_file('dungeons/amaurot.html')
with open('dungeons/index.html', 'r', encoding='utf-8') as f:
text = f.read()
target = """ <tr>
<td><strong>終末幻想 アーモロート</strong></td>
<td>Lv80 (IL410〜)</td>
<td><strong>対応</strong></td>
<td>古代都市の滅亡。流星群落下、ビル崩壊、メガセリオンの終末の流星。</td>
<td>準備中</td>
</tr>"""
replacement = """ <tr>
<td><strong>終末幻想 アーモロート</strong></td>
<td>Lv80 (IL410〜)</td>
<td><strong>対応</strong></td>
<td>古代都市の滅亡。流星群落下、ビル崩壊、メガセリオンの終末の流星。</td>
<td><a href="amaurot.html">攻略を見る ➜</a></td>
</tr>"""
if target in text:
text = text.replace(target, replacement)
with open('dungeons/index.html', 'w', encoding='utf-8') as f:
f.write(text)
normalize_file('dungeons/index.html')
print("SUCCESS: Updated dungeons/index.html with Amaurot link.")
else:
print("ERROR: Target string not found in dungeons/index.html")