mirror of
https://github.com/kodjodevf/mangayomi-extensions.git
synced 2026-02-14 02:41:39 +00:00
fix generate multiple langage for JS source
This commit is contained in:
@@ -63,9 +63,10 @@ class Source {
|
||||
dateFormatLocale = json['dateFormatLocale'] ?? "";
|
||||
hasCloudflare = json['hasCloudflare'] ?? false;
|
||||
iconUrl = json['iconUrl'] ?? "";
|
||||
id = (json['id'] ?? sourceCodeLang == 0
|
||||
? 'mangayomi-"${json['lang'] ?? ""}"."${json['name'] ?? ""}"'
|
||||
: 'mangayomi-js-"${json['lang'] ?? ""}"."${json['name'] ?? ""}"')
|
||||
id = (json['id'] ??
|
||||
(sourceCodeLang == 0
|
||||
? 'mangayomi-"${json['lang'] ?? ""}"."${json['name'] ?? ""}"'
|
||||
: 'mangayomi-js-"${json['lang'] ?? ""}"."${json['name'] ?? ""}"'))
|
||||
.hashCode;
|
||||
isFullData = json['isFullData'] ?? false;
|
||||
isManga = json['isManga'] ?? false;
|
||||
|
||||
@@ -49,19 +49,26 @@ List<Source> _searchJsSources(Directory dir) {
|
||||
if (entity is Directory) {
|
||||
sourceList.addAll(_searchJsSources(entity));
|
||||
} else if (entity is File && entity.path.endsWith('.js')) {
|
||||
final RegExp regex = RegExp(
|
||||
r'const\s+mangayomiSources\s*=\s*(\[.*?\]);',
|
||||
final regex = RegExp(r'const\s+mangayomiSources\s*=\s*(\[.*?\]);',
|
||||
dotAll: true);
|
||||
final defaultSource = Source();
|
||||
Match? match = regex.firstMatch(entity.readAsStringSync());
|
||||
final match = regex.firstMatch(entity.readAsStringSync());
|
||||
if (match != null) {
|
||||
sourceList.addAll((jsonDecode(match.group(1)!) as List)
|
||||
.map((e) => Source.fromJson(e)
|
||||
..sourceCodeLanguage = 1
|
||||
..appMinVerReq = defaultSource.appMinVerReq
|
||||
..sourceCodeUrl =
|
||||
"https://raw.githubusercontent.com/kodjodevf/mangayomi-extensions/$branchName/javascript/${e["pkgPath"] ?? e["pkgName"]}")
|
||||
.toList());
|
||||
for (var sourceJson in jsonDecode(match.group(1)!) as List) {
|
||||
final langs = sourceJson["langs"] as List?;
|
||||
final source = Source.fromJson(sourceJson)
|
||||
..sourceCodeLanguage = 1
|
||||
..appMinVerReq = defaultSource.appMinVerReq
|
||||
..sourceCodeUrl =
|
||||
"https://raw.githubusercontent.com/kodjodevf/mangayomi-extensions/$branchName/javascript/${sourceJson["pkgPath"] ?? sourceJson["pkgName"]}";
|
||||
if (langs?.isNotEmpty ?? false) {
|
||||
for (var lang in langs!) {
|
||||
sourceList.add(Source.fromJson(source.toJson())..lang = lang);
|
||||
}
|
||||
} else {
|
||||
sourceList.add(source);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user