mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-04-29 14:14:36 +02:00
chore(JsonPatchesFileGenerator): Match patch list format with ReVanced API 4
This commit is contained in:
parent
a040b78927
commit
e611321c9f
@ -19,37 +19,28 @@ Example:
|
||||
{
|
||||
"name": "Alternative thumbnails",
|
||||
"description": "Adds options to replace video thumbnails using the DeArrow API or image captures from the video.",
|
||||
"compatiblePackages":[
|
||||
{
|
||||
"name": "com.google.android.youtube",
|
||||
"versions": "COMPATIBLE_PACKAGE_YOUTUBE"
|
||||
}
|
||||
],
|
||||
"use":true,
|
||||
"compatiblePackages": {
|
||||
"com.google.android.youtube": "COMPATIBLE_PACKAGE_YOUTUBE"
|
||||
},
|
||||
"options": []
|
||||
},
|
||||
{
|
||||
"name": "Bitrate default value",
|
||||
"description": "Sets the audio quality to 'Always High' when you first install the app.",
|
||||
"compatiblePackages": [
|
||||
{
|
||||
"name": "com.google.android.apps.youtube.music",
|
||||
"versions": "COMPATIBLE_PACKAGE_MUSIC"
|
||||
}
|
||||
],
|
||||
"use":true,
|
||||
"compatiblePackages": {
|
||||
"com.google.android.apps.youtube.music": "COMPATIBLE_PACKAGE_MUSIC"
|
||||
},
|
||||
"options": []
|
||||
},
|
||||
{
|
||||
"name": "Hide ads",
|
||||
"description": "Adds options to hide ads.",
|
||||
"compatiblePackages": [
|
||||
{
|
||||
"name": "com.reddit.frontpage",
|
||||
"versions": "COMPATIBLE_PACKAGE_REDDIT"
|
||||
}
|
||||
],
|
||||
"use":true,
|
||||
"compatiblePackages": {
|
||||
"com.reddit.frontpage": "COMPATIBLE_PACKAGE_REDDIT"
|
||||
},
|
||||
"options": []
|
||||
}
|
||||
]
|
||||
|
@ -1,10 +1,12 @@
|
||||
package app.revanced.generator
|
||||
|
||||
import app.revanced.patcher.patch.Package
|
||||
import app.revanced.patcher.patch.Patch
|
||||
import com.google.gson.GsonBuilder
|
||||
import java.io.File
|
||||
|
||||
typealias PackageName = String
|
||||
typealias VersionName = String
|
||||
|
||||
internal class JsonPatchesFileGenerator : PatchesFileGenerator {
|
||||
override fun generate(patches: Set<Patch<*>>) {
|
||||
val patchesJson = File("../patches.json")
|
||||
@ -12,8 +14,8 @@ internal class JsonPatchesFileGenerator : PatchesFileGenerator {
|
||||
JsonPatch(
|
||||
it.name!!,
|
||||
it.description,
|
||||
it.compatiblePackages,
|
||||
it.use,
|
||||
it.compatiblePackages?.associate { (packageName, versions) -> packageName to versions },
|
||||
it.options.values.map { option ->
|
||||
JsonPatch.Option(
|
||||
option.key,
|
||||
@ -26,27 +28,16 @@ internal class JsonPatchesFileGenerator : PatchesFileGenerator {
|
||||
},
|
||||
)
|
||||
}.let {
|
||||
patchesJson.writeText(GsonBuilder().serializeNulls().create().toJson(it))
|
||||
patchesJson.writeText(GsonBuilder().setPrettyPrinting().create().toJson(it))
|
||||
}
|
||||
|
||||
patchesJson.writeText(
|
||||
patchesJson.readText()
|
||||
.replace(
|
||||
"\"first\":",
|
||||
"\"name\":"
|
||||
).replace(
|
||||
"\"second\":",
|
||||
"\"versions\":"
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
@Suppress("unused")
|
||||
private class JsonPatch(
|
||||
val name: String? = null,
|
||||
val description: String? = null,
|
||||
val compatiblePackages: Set<Package>? = null,
|
||||
val use: Boolean = true,
|
||||
val compatiblePackages: Map<PackageName, Set<VersionName>?>? = null,
|
||||
val options: List<Option>,
|
||||
) {
|
||||
class Option(
|
||||
|
Loading…
x
Reference in New Issue
Block a user