Skip to content

Commit 9bc4d91

Browse files
committed
chore: update mod_data.txt
1 parent d287239 commit 9bc4d91

File tree

2 files changed

+2275
-616
lines changed

2 files changed

+2275
-616
lines changed

HMCL/parse_mcmod_data.py

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,25 +19,29 @@
1919
import json
2020
import codecs
2121
import re
22+
import sys
2223
from urllib.parse import urlparse, parse_qs
2324

2425
S = ';'
2526

2627
MOD_SEPARATOR = ','
2728

2829
CURSEFORGE_PATTERN1 = re.compile(
29-
r'^/minecraft/(mc-mods|customization|mc-addons|customization/configuration)/(?P<modid>[\w-]+)(/(.*?))?$')
30+
r'^/minecraft/(mc-mods|customization|mc-addons|customization/configuration)/+(?P<modid>[\w-]+)(/(.*?))?$')
3031
CURSEFORGE_PATTERN2 = re.compile(
3132
r'^/projects/(?P<modid>[\w-]+)(/(.*?))?$')
3233
CURSEFORGE_PATTERN3 = re.compile(
3334
r'^/mc-mods/minecraft/(?P<modid>[\w-]+)(/(.*?))?$')
35+
CURSEFORGE_PATTERN4 = re.compile(
36+
r'^/legacy/mc-mods/minecraft/(\d+)-(?P<modid>[\w-]+)'
37+
)
3438

3539

3640
def parseCurseforge(url):
3741
res = urlparse(url)
3842
if res.scheme not in ['http', 'https']:
3943
return ''
40-
for pattern in [CURSEFORGE_PATTERN1, CURSEFORGE_PATTERN2, CURSEFORGE_PATTERN3]:
44+
for pattern in [CURSEFORGE_PATTERN1, CURSEFORGE_PATTERN2, CURSEFORGE_PATTERN3, CURSEFORGE_PATTERN4]:
4145
match = pattern.match(res.path)
4246
if match:
4347
return match.group('modid')
@@ -55,7 +59,7 @@ def parseMcmod(url):
5559
return ''
5660

5761

58-
MCBBS_HTML_PATTERN = re.compile(r'/thread-(?P<modid>\d+)-(\d+)-(\d+).html')
62+
MCBBS_HTML_PATTERN = re.compile(r'/+thread-(?P<modid>\d+)-(\d+)-(\d+).html')
5963
MCBBS_PHP_PATTERN = re.compile(r'')
6064

6165

@@ -78,15 +82,26 @@ def parseMcbbs(url):
7882
return ''
7983

8084

85+
skip = [
86+
'Minecraft',
87+
'The Building Game'
88+
]
89+
90+
8191
if __name__ == '__main__':
82-
with codecs.open('data.json', mode='r', encoding='utf-8-sig') as jsonfile, codecs.open('data.csv', mode='w', encoding='utf-8') as outfile:
92+
json_name = sys.argv[1] or 'data.json'
93+
94+
with codecs.open(json_name, mode='r', encoding='utf-8-sig') as jsonfile, codecs.open('data.csv', mode='w', encoding='utf-8') as outfile:
8395
data = json.load(jsonfile)
8496

8597
for mod in data:
8698
chinese_name = mod['name']['main']
8799
sub_name = mod['name']['sub']
88100
abbr = mod['name']['abbr']
89101

102+
if sub_name in skip:
103+
continue
104+
90105
if S in chinese_name:
91106
print('Error! ' + chinese_name)
92107
exit(1)

0 commit comments

Comments
 (0)