diff --git a/.github/workflows/build-apk.yml b/.github/workflows/build-apk.yml index 34c5eab..54b47b7 100644 --- a/.github/workflows/build-apk.yml +++ b/.github/workflows/build-apk.yml @@ -53,6 +53,7 @@ jobs: DEBUG_ENABLED: ${{ inputs.DEBUG_ENABLED }} secrets: ENVS: ${{ secrets.ENVS }} + REDDIT_CLIENT_ID: ${{ secrets.REDDIT_CLIENT_ID }} upload-to-github: name: GitHub Upload diff --git a/.github/workflows/build-artifact.yml b/.github/workflows/build-artifact.yml index e68b545..eb522f7 100644 --- a/.github/workflows/build-artifact.yml +++ b/.github/workflows/build-artifact.yml @@ -13,6 +13,8 @@ on: secrets: ENVS: required: false + REDDIT_CLIENT_ID: + required: false inputs: FILES_TO_EXPECT: type: string @@ -42,6 +44,38 @@ jobs: run: | 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 uses: mxschmitt/action-tmate@v3 if: ${{ github.event_name == 'workflow_dispatch' && inputs.DEBUG_ENABLED }} diff --git a/README.md b/README.md index 898513c..b651570 100644 --- a/README.md +++ b/README.md @@ -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. com/nikhilbadyal/docker-py-revanced/settings/actions). In the bottom give read and write access to Actions. +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. diff --git a/apks/options.json b/apks/options.json new file mode 100644 index 0000000..bc352b2 --- /dev/null +++ b/apks/options.json @@ -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" + } + ] + } +] diff --git a/apks/populate_client_id.sh b/apks/populate_client_id.sh new file mode 100644 index 0000000..a940d3e --- /dev/null +++ b/apks/populate_client_id.sh @@ -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}" diff --git a/src/config.py b/src/config.py index 3788aaa..ebbd98e 100644 --- a/src/config.py +++ b/src/config.py @@ -40,6 +40,7 @@ class RevancedConfig(object): self.normal_cli_jar = "revanced-cli.jar" self.normal_patches_jar = "revanced-patches.jar" self.normal_integrations_apk = "revanced-integrations.apk" + self.normal_options_json = "options.json" self.cli_jar = ( f"inotia00-{self.normal_cli_jar}" if self.build_extended diff --git a/src/parser.py b/src/parser.py index 86dc6eb..a1bee8e 100644 --- a/src/parser.py +++ b/src/parser.py @@ -85,6 +85,7 @@ class Parser(object): cli = self.config.normal_cli_jar patches = self.config.normal_patches_jar integrations = self.config.normal_integrations_apk + options = self.config.normal_options_json if self.config.build_extended and app in self.config.extended_apps: cli = self.config.cli_jar patches = self.config.patches_jar @@ -102,6 +103,8 @@ class Parser(object): f"Re-{app}-{version}{output_prefix}output.apk", "--keystore", self.config.keystore_name, + "--options", + options, ] if is_experimental: logger.debug("Using experimental features")