add Tsumi
This commit is contained in:
+17
-9
@@ -2,8 +2,8 @@ import json
|
||||
import os
|
||||
from pathlib import Path
|
||||
|
||||
def add_anymex_support(file_path):
|
||||
"""Add supportsAnymex: true to JSON files that have supportsDartotsu: true"""
|
||||
def add_supports(file_path):
|
||||
"""Add supportsAnymex and supportsTsumi to JSON files"""
|
||||
try:
|
||||
with open(file_path, 'r', encoding='utf-8') as f:
|
||||
data = json.load(f)
|
||||
@@ -13,18 +13,26 @@ def add_anymex_support(file_path):
|
||||
modified = False
|
||||
|
||||
# Check if it's a single source entry
|
||||
if 'supportsDartotsu' in data:
|
||||
if 'supportsDartotsu' in data or 'supportsSora' in data:
|
||||
if data.get('supportsDartotsu') == True and 'supportsAnymex' not in data:
|
||||
data['supportsAnymex'] = True
|
||||
modified = True
|
||||
if data.get('supportsSora') == True and 'supportsTsumi' not in data:
|
||||
data['supportsTsumi'] = True
|
||||
modified = True
|
||||
|
||||
# Check if it's index.json with multiple entries
|
||||
else:
|
||||
for key, value in data.items():
|
||||
if isinstance(value, dict) and 'supportsDartotsu' in value:
|
||||
if value.get('supportsDartotsu') == True and 'supportsAnymex' not in value:
|
||||
value['supportsAnymex'] = True
|
||||
modified = True
|
||||
if isinstance(value, dict):
|
||||
if 'supportsDartotsu' in value:
|
||||
if value.get('supportsDartotsu') == True and 'supportsAnymex' not in value:
|
||||
value['supportsAnymex'] = True
|
||||
modified = True
|
||||
if 'supportsSora' in value:
|
||||
if value.get('supportsSora') == True and 'supportsTsumi' not in value:
|
||||
value['supportsTsumi'] = True
|
||||
modified = True
|
||||
|
||||
if modified:
|
||||
with open(file_path, 'w', encoding='utf-8') as f:
|
||||
@@ -45,7 +53,7 @@ print("=" * 60)
|
||||
# Process index.json
|
||||
index_file = script_dir / "index.json"
|
||||
if index_file.exists():
|
||||
success, msg = add_anymex_support(index_file)
|
||||
success, msg = add_supports(index_file)
|
||||
print(f"index.json: {msg}")
|
||||
|
||||
# Process all subdirectory JSON files
|
||||
@@ -54,7 +62,7 @@ for json_file in script_dir.rglob("*.json"):
|
||||
if json_file.name == "index.json" and json_file.parent == script_dir:
|
||||
continue
|
||||
|
||||
success, msg = add_anymex_support(json_file)
|
||||
success, msg = add_supports(json_file)
|
||||
if success:
|
||||
print(f"✓ {json_file.relative_to(script_dir)}: {msg}")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user