chore: update mod_data.txt

This commit is contained in:
huanghongxun 2022-05-05 22:46:51 +08:00
parent 4a3d20576e
commit 71f13b24cb
2 changed files with 2275 additions and 616 deletions

View File

@ -19,6 +19,7 @@
import json import json
import codecs import codecs
import re import re
import sys
from urllib.parse import urlparse, parse_qs from urllib.parse import urlparse, parse_qs
S = ';' S = ';'
@ -26,18 +27,21 @@ S = ';'
MOD_SEPARATOR = ',' MOD_SEPARATOR = ','
CURSEFORGE_PATTERN1 = re.compile( CURSEFORGE_PATTERN1 = re.compile(
r'^/minecraft/(mc-mods|customization|mc-addons|customization/configuration)/(?P<modid>[\w-]+)(/(.*?))?$') r'^/minecraft/(mc-mods|customization|mc-addons|customization/configuration)/+(?P<modid>[\w-]+)(/(.*?))?$')
CURSEFORGE_PATTERN2 = re.compile( CURSEFORGE_PATTERN2 = re.compile(
r'^/projects/(?P<modid>[\w-]+)(/(.*?))?$') r'^/projects/(?P<modid>[\w-]+)(/(.*?))?$')
CURSEFORGE_PATTERN3 = re.compile( CURSEFORGE_PATTERN3 = re.compile(
r'^/mc-mods/minecraft/(?P<modid>[\w-]+)(/(.*?))?$') r'^/mc-mods/minecraft/(?P<modid>[\w-]+)(/(.*?))?$')
CURSEFORGE_PATTERN4 = re.compile(
r'^/legacy/mc-mods/minecraft/(\d+)-(?P<modid>[\w-]+)'
)
def parseCurseforge(url): def parseCurseforge(url):
res = urlparse(url) res = urlparse(url)
if res.scheme not in ['http', 'https']: if res.scheme not in ['http', 'https']:
return '' return ''
for pattern in [CURSEFORGE_PATTERN1, CURSEFORGE_PATTERN2, CURSEFORGE_PATTERN3]: for pattern in [CURSEFORGE_PATTERN1, CURSEFORGE_PATTERN2, CURSEFORGE_PATTERN3, CURSEFORGE_PATTERN4]:
match = pattern.match(res.path) match = pattern.match(res.path)
if match: if match:
return match.group('modid') return match.group('modid')
@ -55,7 +59,7 @@ def parseMcmod(url):
return '' return ''
MCBBS_HTML_PATTERN = re.compile(r'/thread-(?P<modid>\d+)-(\d+)-(\d+).html') MCBBS_HTML_PATTERN = re.compile(r'/+thread-(?P<modid>\d+)-(\d+)-(\d+).html')
MCBBS_PHP_PATTERN = re.compile(r'') MCBBS_PHP_PATTERN = re.compile(r'')
@ -78,8 +82,16 @@ def parseMcbbs(url):
return '' return ''
skip = [
'Minecraft',
'The Building Game'
]
if __name__ == '__main__': if __name__ == '__main__':
with codecs.open('data.json', mode='r', encoding='utf-8-sig') as jsonfile, codecs.open('data.csv', mode='w', encoding='utf-8') as outfile: json_name = sys.argv[1] or 'data.json'
with codecs.open(json_name, mode='r', encoding='utf-8-sig') as jsonfile, codecs.open('data.csv', mode='w', encoding='utf-8') as outfile:
data = json.load(jsonfile) data = json.load(jsonfile)
for mod in data: for mod in data:
@ -87,6 +99,9 @@ if __name__ == '__main__':
sub_name = mod['name']['sub'] sub_name = mod['name']['sub']
abbr = mod['name']['abbr'] abbr = mod['name']['abbr']
if sub_name in skip:
continue
if S in chinese_name: if S in chinese_name:
print('Error! ' + chinese_name) print('Error! ' + chinese_name)
exit(1) exit(1)

File diff suppressed because it is too large Load Diff