import os
import json
import datetime

os.chdir(os.path.dirname(os.path.abspath(__file__)))
version_timestamps = {
    ver: int(datetime.datetime.strptime(date, "%Y-%m-%d").timestamp() * 1000)
    for ver, date in (
        ("1.0.0", "2025-07-27"),
        ("1.1.0", "2025-09-13"),
        ("1.1.1", "2025-09-20"),
        ("1.2.0", "2025-10-06"),
    )
}
with open("songlist", "r+", encoding="utf-8") as f:
    data = json.load(f)
    for song in data.get("songs", []):
        if (ver := song.get("version")) in version_timestamps:
            song["date"] = version_timestamps[ver]
            print(f"成功修改时间戳： {song['id']} ({ver})")
    f.seek(0)
    json.dump(data, f, ensure_ascii=False, indent=2)
    f.truncate()
input()
