diff --git a/src/tools/sync_db.py b/src/tools/sync_db.py index f310c87..1271db5 100644 --- a/src/tools/sync_db.py +++ b/src/tools/sync_db.py @@ -210,29 +210,30 @@ def generate_union_table(mysql_conn): if w['release_date'] and w['studio_name']: # 对name进行去空格,去特殊字符处理 key_str = parse_union_key(w['release_date'], w['studio_name'], w['whisper_code']) + if w['release_date'] == '2012-08-31' and w['studio_name'] == 'HEYZO': + print(f"whisper data: {w}") + print(f'key_str: {key_str}') + if key_str in dict_stash_data: + set_idx = dict_stash_data[key_str] + for idx in set_idx: + print(f"stash data: {stash_data[idx]}") + if key_str in dict_stash_data: set_idx = dict_stash_data[key_str] - if len(set_idx) == 1: - idx = set_idx.pop() - s = stash_data[idx] - stash_data[idx]['matched'] = True - matched = True - else: - # 多重匹配时,把code相同且未匹配过的优先匹配 + for idx in set_idx: + if (stash_data[idx]['code'] and w['whisper_code']) and stash_data[idx]['code'].lower() == w['whisper_code'].lower() and not stash_data[idx].get('matched', False): + s = stash_data[idx] + stash_data[idx]['matched'] = True + matched = True + break + if not matched: + # 否则匹配第一个未匹配过的 for idx in set_idx: - if (stash_data[idx]['code'] and w['whisper_code']) and stash_data[idx]['code'].lower() == w['whisper_code'].lower() and not stash_data[idx].get('matched', False): + if not stash_data[idx].get('matched', False): s = stash_data[idx] stash_data[idx]['matched'] = True matched = True break - if not matched: - # 否则匹配第一个未匹配过的 - for idx in set_idx: - if not stash_data[idx].get('matched', False): - s = stash_data[idx] - stash_data[idx]['matched'] = True - matched = True - break if matched and s: result.append({ 'whisper_id': w['Id'],