From 283b628053b079c8b8d9da925159df8680a52fb4 Mon Sep 17 00:00:00 2001 From: miteruzo Date: Mon, 14 Oct 2024 19:12:37 +0900 Subject: [PATCH] =?UTF-8?q?=E8=AA=B2=E9=A1=8C=20#5=20=E3=81=AB=E5=AF=BE?= =?UTF-8?q?=E3=81=99=E3=82=8B=E5=AF=BE=E5=BF=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- update_db.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/update_db.py b/update_db.py index 3d551a0..439d3f3 100644 --- a/update_db.py +++ b/update_db.py @@ -9,6 +9,7 @@ import os import random import string import time +import unicodedata from dataclasses import dataclass from datetime import date, datetime, timedelta from typing import Any, Type, TypedDict, cast @@ -158,7 +159,7 @@ def update_tables ( for vt in video_tags: tag = tag_dao.find (vt.tag_id) if (tag is not None - and (tag.name.upper () not in map (str.upper, tag_names)) + and (normalise (tag.name) not in map (normalise, tag_names)) and (tag.id_ is not None)): tag_ids.append (tag.id_) video_tag_dao.untag_all (video.id_, tag_ids, now) @@ -1067,5 +1068,11 @@ class UserDto: id_: int | None = None +def normalise ( + s: str +) -> str: + return unicodedata.normalize ('NFKC', s).lower () + + if __name__ == '__main__': main ()