Files
ff14-guide/tools/update_links.py
T

63 lines
3.1 KiB
Python

# -*- 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
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')
with open(path, 'wb') as f:
f.write(b'\xef\xbb\xbf' + text.encode('utf-8'))
def update_top_index():
path = 'index.html'
with open(path, 'rb') as f:
c = f.read().decode('utf-8', errors='ignore')
c = c.replace('\r\n', '\n')
# ダンジョン・討滅戦・レイドのピックアップを増強
target = '<td><a href="raids/labyrinth_of_ancients.html">開く ➜</a></td>\n </tr>'
new_rows = '''<td><a href="raids/labyrinth_of_ancients.html">開く ➜</a></td>
</tr>
<tr>
<td><strong>クリスタルタワー:シルクスの塔</strong></td>
<td><strong>【アラルレ最頻出・メイン必須】</strong> スキュラ(氷解凍・水たまり)、ガーディアン(跳躍台)、アモン(氷隠れ)、ザンデ(レビテト浮遊)。</td>
<td><a href="raids/syrcus_tower.html">開く ➜</a></td>
</tr>
<tr>
<td><strong>クリスタルタワー:闇の世界</strong></td>
<td><strong>【全滅多発難関レイド】</strong> アンラ・マンユ(死の視線・宣告解除)、ケルベロス(小人化胃袋突入・鎖繋ぎ)、暗闇の雲(雲踏み阻止)。</td>
<td><a href="raids/world_of_darkness.html">開く ➜</a></td>
</tr>
<tr>
<td><strong>アルカディア:ライトヘビー級2〜4層</strong></td>
<td><strong>【黄金最新8人レイド】</strong> LH2層ハニー・B・ラブリー(ハートスタック)、LH3層ブルートボンバー(ラリアット・爆弾)、LH4層ウィケッドサンダー(ウィッチハント・床破壊)。</td>
<td><a href="raids/index.html">開く ➜</a></td>
</tr>
<tr>
<td><strong>黄金主要討滅戦(ヴァリガルマンダ / ゾラージャ / エターナル・クイーン)</strong></td>
<td><strong>【Lv93・Lv99・Lv100ラスボス】</strong> 3属性天候変化、空間格子切断、仮想浮遊・重力反転、ドーン・エイジ完全攻略。</td>
<td><a href="trials/index.html">開く ➜</a></td>
</tr>'''
if 'raids/syrcus_tower.html' not in c:
if target in c:
c = c.replace(target, new_rows)
clean_and_save(path, c)
print("Updated top index.html successfully")
if __name__ == '__main__':
update_top_index()