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",
|
"name": "Alternative thumbnails",
|
||||||
"description": "Adds options to replace video thumbnails using the DeArrow API or image captures from the video.",
|
"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,
|
"use":true,
|
||||||
|
"compatiblePackages": {
|
||||||
|
"com.google.android.youtube": "COMPATIBLE_PACKAGE_YOUTUBE"
|
||||||
|
},
|
||||||
"options": []
|
"options": []
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "Bitrate default value",
|
"name": "Bitrate default value",
|
||||||
"description": "Sets the audio quality to 'Always High' when you first install the app.",
|
"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,
|
"use":true,
|
||||||
|
"compatiblePackages": {
|
||||||
|
"com.google.android.apps.youtube.music": "COMPATIBLE_PACKAGE_MUSIC"
|
||||||
|
},
|
||||||
"options": []
|
"options": []
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "Hide ads",
|
"name": "Hide ads",
|
||||||
"description": "Adds options to hide ads.",
|
"description": "Adds options to hide ads.",
|
||||||
"compatiblePackages": [
|
|
||||||
{
|
|
||||||
"name": "com.reddit.frontpage",
|
|
||||||
"versions": "COMPATIBLE_PACKAGE_REDDIT"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"use":true,
|
"use":true,
|
||||||
|
"compatiblePackages": {
|
||||||
|
"com.reddit.frontpage": "COMPATIBLE_PACKAGE_REDDIT"
|
||||||
|
},
|
||||||
"options": []
|
"options": []
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
@ -1,10 +1,12 @@
|
|||||||
package app.revanced.generator
|
package app.revanced.generator
|
||||||
|
|
||||||
import app.revanced.patcher.patch.Package
|
|
||||||
import app.revanced.patcher.patch.Patch
|
import app.revanced.patcher.patch.Patch
|
||||||
import com.google.gson.GsonBuilder
|
import com.google.gson.GsonBuilder
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
||||||
|
typealias PackageName = String
|
||||||
|
typealias VersionName = String
|
||||||
|
|
||||||
internal class JsonPatchesFileGenerator : PatchesFileGenerator {
|
internal class JsonPatchesFileGenerator : PatchesFileGenerator {
|
||||||
override fun generate(patches: Set<Patch<*>>) {
|
override fun generate(patches: Set<Patch<*>>) {
|
||||||
val patchesJson = File("../patches.json")
|
val patchesJson = File("../patches.json")
|
||||||
@ -12,8 +14,8 @@ internal class JsonPatchesFileGenerator : PatchesFileGenerator {
|
|||||||
JsonPatch(
|
JsonPatch(
|
||||||
it.name!!,
|
it.name!!,
|
||||||
it.description,
|
it.description,
|
||||||
it.compatiblePackages,
|
|
||||||
it.use,
|
it.use,
|
||||||
|
it.compatiblePackages?.associate { (packageName, versions) -> packageName to versions },
|
||||||
it.options.values.map { option ->
|
it.options.values.map { option ->
|
||||||
JsonPatch.Option(
|
JsonPatch.Option(
|
||||||
option.key,
|
option.key,
|
||||||
@ -26,27 +28,16 @@ internal class JsonPatchesFileGenerator : PatchesFileGenerator {
|
|||||||
},
|
},
|
||||||
)
|
)
|
||||||
}.let {
|
}.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")
|
@Suppress("unused")
|
||||||
private class JsonPatch(
|
private class JsonPatch(
|
||||||
val name: String? = null,
|
val name: String? = null,
|
||||||
val description: String? = null,
|
val description: String? = null,
|
||||||
val compatiblePackages: Set<Package>? = null,
|
|
||||||
val use: Boolean = true,
|
val use: Boolean = true,
|
||||||
|
val compatiblePackages: Map<PackageName, Set<VersionName>?>? = null,
|
||||||
val options: List<Option>,
|
val options: List<Option>,
|
||||||
) {
|
) {
|
||||||
class Option(
|
class Option(
|
||||||
|
@ -53,9 +53,9 @@ internal class ReadMeFileGenerator : PatchesFileGenerator {
|
|||||||
} else {
|
} else {
|
||||||
versions
|
versions
|
||||||
?.toString()
|
?.toString()
|
||||||
?.replace("[", "[\n \"")
|
?.replace("[", "[\n \"")
|
||||||
?.replace("]", "\"\n ]")
|
?.replace("]", "\"\n ]")
|
||||||
?.replace(", ", "\",\n \"")
|
?.replace(", ", "\",\n \"")
|
||||||
?: "\"ALL\""
|
?: "\"ALL\""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user