mirror of
https://github.com/HMCL-dev/HMCL.git
synced 2025-09-09 03:46:18 -04:00
parent
abec1abcff
commit
8b94fe5b0b
@ -27,7 +27,7 @@ S = ';'
|
|||||||
MOD_SEPARATOR = ','
|
MOD_SEPARATOR = ','
|
||||||
|
|
||||||
CURSEFORGE_PATTERN1 = re.compile(
|
CURSEFORGE_PATTERN1 = re.compile(
|
||||||
r'^/minecraft/(mc-mods|modpacks|customization|mc-addons|customization/configuration)/+(?P<modid>[\w-]+)(/(.*?))?$')
|
r'^/(minecraft|Minecraft|minecraft-bedrock)/(mc-mods|modpacks|customization|mc-addons|texture-packs|customization/configuration|addons)/+(?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(
|
||||||
@ -58,30 +58,6 @@ def parseMcmod(url):
|
|||||||
return match.group('modid')
|
return match.group('modid')
|
||||||
return ''
|
return ''
|
||||||
|
|
||||||
|
|
||||||
MCBBS_HTML_PATTERN = re.compile(r'/+thread-(?P<modid>\d+)-(\d+)-(\d+).html')
|
|
||||||
MCBBS_PHP_PATTERN = re.compile(r'')
|
|
||||||
|
|
||||||
|
|
||||||
def parseMcbbs(url):
|
|
||||||
res = urlparse(url)
|
|
||||||
if res.scheme not in ['http', 'https']:
|
|
||||||
return ''
|
|
||||||
if res.netloc != 'www.mcbbs.net':
|
|
||||||
return ''
|
|
||||||
match = MCBBS_HTML_PATTERN.match(res.path)
|
|
||||||
if match:
|
|
||||||
return match.group('modid')
|
|
||||||
|
|
||||||
query = parse_qs(res.query)
|
|
||||||
|
|
||||||
if res.path == '/forum.php':
|
|
||||||
if 'mod' in query and 'tid' in query and query['mod'] == ['viewthread']:
|
|
||||||
return query['tid']
|
|
||||||
|
|
||||||
return ''
|
|
||||||
|
|
||||||
|
|
||||||
skip = [
|
skip = [
|
||||||
'Minecraft',
|
'Minecraft',
|
||||||
'The Building Game'
|
'The Building Game'
|
||||||
@ -111,7 +87,7 @@ if __name__ == '__main__':
|
|||||||
exit(1)
|
exit(1)
|
||||||
|
|
||||||
black_lists = [
|
black_lists = [
|
||||||
'Master Chef'
|
'Wood Converter'
|
||||||
]
|
]
|
||||||
|
|
||||||
curseforge_id = ''
|
curseforge_id = ''
|
||||||
@ -131,11 +107,6 @@ if __name__ == '__main__':
|
|||||||
if mcmod_id == '':
|
if mcmod_id == '':
|
||||||
print('Error mcmod ' + chinese_name)
|
print('Error mcmod ' + chinese_name)
|
||||||
exit(1)
|
exit(1)
|
||||||
if 'mcbbs' in links and links['mcbbs']:
|
|
||||||
mcbbs_id = parseMcbbs(links['mcbbs'][0]['url'])
|
|
||||||
if mcbbs_id == '':
|
|
||||||
print('Error mcbbs ' + chinese_name)
|
|
||||||
exit(1)
|
|
||||||
|
|
||||||
mod_id = []
|
mod_id = []
|
||||||
if 'modid' in mod and 'list' in mod['modid']:
|
if 'modid' in mod and 'list' in mod['modid']:
|
||||||
@ -148,6 +119,6 @@ if __name__ == '__main__':
|
|||||||
mod_ids = MOD_SEPARATOR.join([str(id) for id in mod_id])
|
mod_ids = MOD_SEPARATOR.join([str(id) for id in mod_id])
|
||||||
|
|
||||||
outfile.write(
|
outfile.write(
|
||||||
f'{curseforge_id}{S}{mcmod_id}{S}{mcbbs_id}{S}{mod_ids}{S}{chinese_name}{S}{sub_name}{S}{abbr}\n')
|
f'{curseforge_id}{S}{mcmod_id}{S}{mod_ids}{S}{chinese_name}{S}{sub_name}{S}{abbr}\n')
|
||||||
|
|
||||||
print('Success!')
|
print('Success!')
|
||||||
|
@ -198,10 +198,9 @@ public enum ModTranslations {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Mod {
|
public static final class Mod {
|
||||||
private final String curseforge;
|
private final String curseforge;
|
||||||
private final String mcmod;
|
private final String mcmod;
|
||||||
private final String mcbbs;
|
|
||||||
private final List<String> modIds;
|
private final List<String> modIds;
|
||||||
private final String name;
|
private final String name;
|
||||||
private final String subname;
|
private final String subname;
|
||||||
@ -209,23 +208,21 @@ public enum ModTranslations {
|
|||||||
|
|
||||||
public Mod(String line) {
|
public Mod(String line) {
|
||||||
String[] items = line.split(";", -1);
|
String[] items = line.split(";", -1);
|
||||||
if (items.length != 7) {
|
if (items.length != 6) {
|
||||||
throw new IllegalArgumentException("Illegal mod data line, 7 items expected " + line);
|
throw new IllegalArgumentException("Illegal mod data line, 6 items expected " + line);
|
||||||
}
|
}
|
||||||
|
|
||||||
curseforge = items[0];
|
curseforge = items[0];
|
||||||
mcmod = items[1];
|
mcmod = items[1];
|
||||||
mcbbs = items[2];
|
modIds = Collections.unmodifiableList(Arrays.asList(items[2].split(",")));
|
||||||
modIds = Collections.unmodifiableList(Arrays.asList(items[3].split(",")));
|
name = items[3];
|
||||||
name = items[4];
|
subname = items[4];
|
||||||
subname = items[5];
|
abbr = items[5];
|
||||||
abbr = items[6];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Mod(String curseforge, String mcmod, String mcbbs, List<String> modIds, String name, String subname, String abbr) {
|
public Mod(String curseforge, String mcmod, List<String> modIds, String name, String subname, String abbr) {
|
||||||
this.curseforge = curseforge;
|
this.curseforge = curseforge;
|
||||||
this.mcmod = mcmod;
|
this.mcmod = mcmod;
|
||||||
this.mcbbs = mcbbs;
|
|
||||||
this.modIds = modIds;
|
this.modIds = modIds;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.subname = subname;
|
this.subname = subname;
|
||||||
@ -252,10 +249,6 @@ public enum ModTranslations {
|
|||||||
return mcmod;
|
return mcmod;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getMcbbs() {
|
|
||||||
return mcbbs;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<String> getModIds() {
|
public List<String> getModIds() {
|
||||||
return modIds;
|
return modIds;
|
||||||
}
|
}
|
||||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user