Browse Source

Open json files with utf-8 encoding, truncate child_beatmaps table when conversion starts

Giuseppe Guerra 1 year ago
parent
commit
6391cb2934
2 changed files with 4 additions and 2 deletions
  1. 1
    0
      convert.py
  2. 3
    2
      utils/mirror.py

+ 1
- 0
convert.py View File

@@ -68,6 +68,7 @@ if __name__ == "__main__":
68 68
 		print("Couldn't read index.json")
69 69
 		sys.exit()
70 70
 	glob.db.execute("TRUNCATE TABLE beatmapsets")
71
+	glob.db.execute("TRUNCATE TABLE child_beatmaps")
71 72
 
72 73
 	# Spawn workers
73 74
 	workers = []

+ 3
- 2
utils/mirror.py View File

@@ -1,4 +1,5 @@
1 1
 import json
2
+import codecs
2 3
 
3 4
 from objects import glob
4 5
 
@@ -7,7 +8,7 @@ def get_data_folder():
7 8
 
8 9
 def get_beatmap(beatmap_id):
9 10
 	try:
10
-		with open("{}/b/{}.json".format(get_data_folder(), beatmap_id), "r") as f:
11
+		with codecs.open("{}/b/{}.json".format(get_data_folder(), beatmap_id), "r", "utf-8") as f:
11 12
 			data =  json.loads(f.read())
12 13
 	except (json.JSONDecodeError, ValueError, FileNotFoundError):
13 14
 		data = None
@@ -15,7 +16,7 @@ def get_beatmap(beatmap_id):
15 16
 
16 17
 def get_index():
17 18
 	try:
18
-		with open("{}/index.json".format(get_data_folder()), "r") as f:
19
+		with codecs.open("{}/index.json".format(get_data_folder()), "r", "utf-8") as f:
19 20
 			data =  json.loads(f.read())
20 21
 	except (json.JSONDecodeError, ValueError, FileNotFoundError):
21 22
 		data = None

Loading…
Cancel
Save