jellyfin-web/scripts/remove.py

35 lines
784 B
Python
Raw Normal View History

2020-01-19 18:38:53 -07:00
import sys
import os
import json
# load text file containing unused keys
# remove the keys from all string files
cwd = os.getcwd()
langdir = cwd + '/../src/strings'
langlst = os.listdir(langdir)
keys = []
2020-08-03 12:26:57 -07:00
with open('unused.txt', 'r') as f:
2020-01-19 18:38:53 -07:00
for line in f:
keys.append(line.strip('\n'))
for lang in langlst:
with open(langdir + '/' + lang, 'r') as f:
inde = 2
if '\n \"' in f.read():
inde = 4
f.close()
with open(langdir + '/' + lang, 'r+') as f:
langjson = json.load(f)
for key in keys:
langjson.pop(key, None)
f.seek(0)
f.write(json.dumps(langjson, indent=inde, sort_keys=False, ensure_ascii=False))
f.write('\n')
f.truncate()
f.close()
print('DONE')