|
@@ -8,12 +8,12 @@ import sys
|
|
modTag = "mod"
|
|
modTag = "mod"
|
|
|
|
|
|
file_path_html = 'glife.html'
|
|
file_path_html = 'glife.html'
|
|
-file_path_mod = 'mod.html'
|
|
|
|
-file_path_mod_online = 'mod.php'
|
|
|
|
|
|
+file_path_mod = 'mods'
|
|
|
|
+file_path_mod_online = 'mods'
|
|
|
|
|
|
data = ''
|
|
data = ''
|
|
-modData = ''
|
|
|
|
-scripts = ''
|
|
|
|
|
|
+modData = {}
|
|
|
|
+scripts = {}
|
|
dataWithoutModStuff = ''
|
|
dataWithoutModStuff = ''
|
|
|
|
|
|
with open(file_path_html, 'r') as file:
|
|
with open(file_path_html, 'r') as file:
|
|
@@ -27,27 +27,44 @@ for match in re.finditer(regex,data,re.S):
|
|
tags = match.group(3).split()
|
|
tags = match.group(3).split()
|
|
|
|
|
|
if(modTag in tags):
|
|
if(modTag in tags):
|
|
- modData += match.group(0)+'\n'
|
|
|
|
|
|
+ modId = 'default'
|
|
|
|
+ for tag in tags:
|
|
|
|
+ if tag.startswith('mod_'):
|
|
|
|
+ modId = tag[4:]
|
|
|
|
+ if modId not in modData:
|
|
|
|
+ modData[modId] = ''
|
|
|
|
+ modData[modId] += match.group(0)+'\n'
|
|
dataWithoutModStuff = dataWithoutModStuff.replace(match.group(0),'')
|
|
dataWithoutModStuff = dataWithoutModStuff.replace(match.group(0),'')
|
|
|
|
|
|
i += 1
|
|
i += 1
|
|
if(i % 100 == 0):
|
|
if(i % 100 == 0):
|
|
print(i)
|
|
print(i)
|
|
|
|
|
|
-regex = r"""/\*\s*Start Mod:\s*"Mod"\s*\*/(.*?)/\*\s*End Mod:\s*"Mod"\s*\*/"""
|
|
|
|
|
|
+regex = r"""/\*\s*Start Mod:\s*"([^"]*)"\s*\*/(.*?)/\*\s*End Mod:\s*"Mod"\s*\*/"""
|
|
for match in re.finditer(regex,data,re.S):
|
|
for match in re.finditer(regex,data,re.S):
|
|
- scripts += match.group(1)
|
|
|
|
|
|
+ modId = match.group(1).strip()
|
|
|
|
+ if not modId:
|
|
|
|
+ modId = 'default'
|
|
|
|
+ if modId not in scripts:
|
|
|
|
+ scripts[modId] = ''
|
|
|
|
+ scripts[modId] += match.group(2)
|
|
dataWithoutModStuff = dataWithoutModStuff.replace(match.group(0),'')
|
|
dataWithoutModStuff = dataWithoutModStuff.replace(match.group(0),'')
|
|
|
|
|
|
-modData += "\n.-.-.-. STORYDATA / SCRIPT .-.-.-.\n"
|
|
|
|
-
|
|
|
|
-modData += scripts
|
|
|
|
-
|
|
|
|
-with open(file_path_mod, 'w') as file:
|
|
|
|
- file.write(modData)
|
|
|
|
-
|
|
|
|
-with open(file_path_mod_online, 'w') as file:
|
|
|
|
- file.write(f'<?php header("Access-Control-Allow-Origin: *"); header(\'Content-type: text/javascript\'); echo($_GET[\'callback\']);?>(`{modData}\n`);')
|
|
|
|
|
|
+for modId, scriptContent in scripts.items():
|
|
|
|
+ if modId not in modData:
|
|
|
|
+ modData[modId] = ''
|
|
|
|
+ modData[modId] += "\n.-.-.-. STORYDATA / SCRIPT .-.-.-.\n"
|
|
|
|
+ modData[modId] += scriptContent
|
|
|
|
+
|
|
|
|
+for modId, modContent in modData.items():
|
|
|
|
+ modPath = os.path.join(file_path_mod,modId+'.html')
|
|
|
|
+ with open(modPath, 'w') as file:
|
|
|
|
+ file.write(modContent)
|
|
|
|
+
|
|
|
|
+for modId, modContent in modData.items():
|
|
|
|
+ modPath = os.path.join(file_path_mod_online,modId+'.php')
|
|
|
|
+ with open(modPath, 'w') as file:
|
|
|
|
+ file.write(f'<?php header("Access-Control-Allow-Origin: *"); header(\'Content-type: text/javascript\'); echo($_GET[\'callback\']);?>(`{modContent}\n`);')
|
|
|
|
|
|
with open(file_path_html, 'w') as file:
|
|
with open(file_path_html, 'w') as file:
|
|
file.write(dataWithoutModStuff)
|
|
file.write(dataWithoutModStuff)
|