Inject reddit id

This commit is contained in:
Nikhil Badyal
2023-07-13 16:50:48 +05:30
parent a62cf4266e
commit 0be39e7b42
7 changed files with 106 additions and 0 deletions
+1
View File
@@ -53,6 +53,7 @@ jobs:
DEBUG_ENABLED: ${{ inputs.DEBUG_ENABLED }} DEBUG_ENABLED: ${{ inputs.DEBUG_ENABLED }}
secrets: secrets:
ENVS: ${{ secrets.ENVS }} ENVS: ${{ secrets.ENVS }}
REDDIT_CLIENT_ID: ${{ secrets.REDDIT_CLIENT_ID }}
upload-to-github: upload-to-github:
name: GitHub Upload name: GitHub Upload
+34
View File
@@ -13,6 +13,8 @@ on:
secrets: secrets:
ENVS: ENVS:
required: false required: false
REDDIT_CLIENT_ID:
required: false
inputs: inputs:
FILES_TO_EXPECT: FILES_TO_EXPECT:
type: string type: string
@@ -42,6 +44,38 @@ jobs:
run: | run: |
echo "${{ secrets.ENVS }}" >> .env echo "${{ secrets.ENVS }}" >> .env
- name: Inject Reddit Client ID
env:
REDDIT_CLIENT_ID: ${{ secrets.REDDIT_CLIENT_ID }}
if: env.REDDIT_CLIENT_ID != null
run: |
client_id="${REDDIT_CLIENT_ID}"
path="apks/options.json"
json_data=$(cat "${path}")
new_object='{
"patchName": "Change OAuth client id",
"options": [
{
"key": "client-id",
"value": "'${client_id}'"
}
]
}'
# Check if an object with the patchName "Change OAuth client id" already exists
existing_object_index=$(echo "${json_data}" | jq 'map(.patchName) | index("Change OAuth client id")')
echo "${existing_object_index}"
if [[ ${existing_object_index} != "null" ]]; then
echo "Patch entry already exists. Overriding client ID in it."
updated_json=$(echo "${json_data}" | jq ".[${existing_object_index}].options[0].value = \"${client_id}\"")
else
echo "Patch entry doesn't exists. Adding new entry."
updated_json=$(echo "${json_data}" | jq ". += [${new_object}]")
fi
echo "${updated_json}" > "${path}"
- name: Setup tmate session - name: Setup tmate session
uses: mxschmitt/action-tmate@v3 uses: mxschmitt/action-tmate@v3
if: ${{ github.event_name == 'workflow_dispatch' && inputs.DEBUG_ENABLED }} if: ${{ github.event_name == 'workflow_dispatch' && inputs.DEBUG_ENABLED }}
+2
View File
@@ -286,5 +286,7 @@ By default, script build the version as recommended by Revanced team.
16. Make your Action has write access. If not click [here](https://github. 16. Make your Action has write access. If not click [here](https://github.
com/nikhilbadyal/docker-py-revanced/settings/actions). In the bottom give read and write access to Actions. com/nikhilbadyal/docker-py-revanced/settings/actions). In the bottom give read and write access to Actions.
<img src="https://i.imgur.com/STSv2D3.png" width="400"> <img src="https://i.imgur.com/STSv2D3.png" width="400">
17. If you want to patch reddit apps using your own Client ID. You can provide your Client ID
as secret `REDDIT_CLIENT_ID` in `GitHub secrets`.
Thanks to [@aliharslan0](https://github.com/aliharslan0/pyrevanced) for his work. Thanks to [@aliharslan0](https://github.com/aliharslan0/pyrevanced) for his work.
+38
View File
@@ -0,0 +1,38 @@
[
{
"patchName": "Change OAuth client id",
"options": [
{
"key": "client-id",
"value": null
}
]
},
{
"patchName": "Custom double tap length",
"options": [
{
"key": "DoubleTapLengthArrays",
"value": "3, 5, 10, 15, 20, 30, 60, 120, 180"
}
]
},
{
"patchName": "Reddit settings",
"options": [
{
"key": "RedditSettings",
"value": true
}
]
},
{
"patchName": "Custom Video Speed",
"options": [
{
"key": "CustomSpeedArrays",
"value": "0.25, 0.5, 0.75, 0.9, 1.0, 1.12, 1.25, 1.5, 1.75, 2.0, 2.5, 3.0, 4.0, 5.0"
}
]
}
]
+27
View File
@@ -0,0 +1,27 @@
#!/bin/bash
client_id="test"
path="apks/options.json"
json_data=$(cat "${path}")
new_object='{
"patchName": "Change OAuth client id",
"options": [
{
"key": "client-id",
"value": "'${client_id}'"
}
]
}'
# Check if an object with the patchName "Change OAuth client id" already exists
existing_object_index=$(echo "${json_data}" | jq 'map(.patchName) | index("Change OAuth client id")')
echo "${existing_object_index}"
if [[ ${existing_object_index} != "null" ]]; then
echo "Exist"
updated_json=$(echo "${json_data}" | jq ".[${existing_object_index}].options[0].value = \"${client_id}\"")
else
echo "Does not exist"
updated_json=$(echo "${json_data}" | jq ". += [${new_object}]")
fi
echo "${updated_json}" > "${path}"
+1
View File
@@ -40,6 +40,7 @@ class RevancedConfig(object):
self.normal_cli_jar = "revanced-cli.jar" self.normal_cli_jar = "revanced-cli.jar"
self.normal_patches_jar = "revanced-patches.jar" self.normal_patches_jar = "revanced-patches.jar"
self.normal_integrations_apk = "revanced-integrations.apk" self.normal_integrations_apk = "revanced-integrations.apk"
self.normal_options_json = "options.json"
self.cli_jar = ( self.cli_jar = (
f"inotia00-{self.normal_cli_jar}" f"inotia00-{self.normal_cli_jar}"
if self.build_extended if self.build_extended
+3
View File
@@ -85,6 +85,7 @@ class Parser(object):
cli = self.config.normal_cli_jar cli = self.config.normal_cli_jar
patches = self.config.normal_patches_jar patches = self.config.normal_patches_jar
integrations = self.config.normal_integrations_apk integrations = self.config.normal_integrations_apk
options = self.config.normal_options_json
if self.config.build_extended and app in self.config.extended_apps: if self.config.build_extended and app in self.config.extended_apps:
cli = self.config.cli_jar cli = self.config.cli_jar
patches = self.config.patches_jar patches = self.config.patches_jar
@@ -102,6 +103,8 @@ class Parser(object):
f"Re-{app}-{version}{output_prefix}output.apk", f"Re-{app}-{version}{output_prefix}output.apk",
"--keystore", "--keystore",
self.config.keystore_name, self.config.keystore_name,
"--options",
options,
] ]
if is_experimental: if is_experimental:
logger.debug("Using experimental features") logger.debug("Using experimental features")