Skip to content

Commit

Permalink
Merge branch
Browse files Browse the repository at this point in the history
  • Loading branch information
soymadip committed Jul 17, 2023
2 parents 43b65b8 + 771808e commit b40d855
Show file tree
Hide file tree
Showing 23 changed files with 929 additions and 429 deletions.
1 change: 1 addition & 0 deletions .github/workflows/build-apk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
34 changes: 34 additions & 0 deletions .github/workflows/build-artifact.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ on:
secrets:
ENVS:
required: false
REDDIT_CLIENT_ID:
required: false
inputs:
FILES_TO_EXPECT:
type: string
Expand Down Expand Up @@ -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 }}
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ venv
/revanced-cache/
changelog.md
.idea
*patches.json
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ repos:


- repo: https://github.com/psf/black
rev: 23.3.0
rev: 23.7.0
hooks:
- id: black

Expand All @@ -42,7 +42,7 @@ repos:
args: [ --config=setup.cfg ]

- repo: https://github.com/PyCQA/docformatter
rev: v1.7.2
rev: v1.7.5
hooks:
- id: docformatter
args: [ --in-place ]
Expand All @@ -54,7 +54,7 @@ repos:
args: [ "--config=setup.cfg" ]

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.3.0
rev: v1.4.1
hooks:
- id: mypy
args:
Expand Down
161 changes: 160 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ My slightly Customized python script that i use to build Revanced and Revanced-E

**`Note`** - If you are a root user and want magisk module (Extended). Get them [here](https://github.com/nikhilbadyal/revanced-magisk-module)

This is just a builder for revanced and not a revanced support. Please be understanding and refraining from asking
This is just a builder for revanced and not a revanced support. Please be understanding and refrain from asking
about revanced features/bugs. Discuss those on proper relevant forums(on Revanced GitHub , Discord)

## Pre-Built APKs
Expand Down Expand Up @@ -42,6 +42,165 @@ Revanced Extended.

- Remember to download the **_Microg_**. Otherwise, you will not be able to open YouTube.

<<<<<<< HEAD
=======
You can get pre-built apks [here](https://revanced_apkss.t.me/)

## Build Yourself

You can use any of the following methods to build.

- 🚀In GitHub (**_`Recommended`_**)

1. Click Star to support the project.<br>
<img src="https://i.imgur.com/FFyXaWY.png" width="400" style="left"><br>
2. Fork the project.<br>
<img src="https://i.imgur.com/R5HdByI.png" width="400" style="left"><br>
3. Add `ENVS` (**optional**) secret to the repo. Required only if you want to cook specific apps/versions.
<details>
<summary>🚶Detailed step by step guide</summary>

- Go to the repo settings and then to actions->secret<br>
<img src="https://i.imgur.com/Inj82KK.png" width="600" style="left"><br>
- Add Repository secret<br>
<img src="https://i.imgur.com/V2Wfx3J.png" width="600" style="left">

</details>

4. Go to actions tab. Select `Build & Release`.Click on `Run Workflow`.

<details>
<summary>🚶Detailed step by step guide</summary>

- Go to actions tab<br>
<img src="https://i.imgur.com/XSCvzav.png" width="600" style="left"><br>
- Check the status of build, It should look green.<br>
<img src="https://i.imgur.com/CsJt9W1.png" width="600" style="left">

</details>

5. If the building process is successful, you’ll get your APKs in the<br>
<img src="https://i.imgur.com/S5d7qAO.png" width="700" style="left">

- 🐳With Docker Compose
Windows/Mac users simply install Docker Desktop. If using Linux see below

1. Install Docker(Skip if already installed)
```bash
curl -fsSL https://get.docker.com -o get-docker.sh
sh get-docker.sh
```
2. Grant Permissions with(Skip if already there)
```bash
sudo chmod 777 /var/run/docker.sock
```
3. Install Docker compose(Skip if already installed or using **_`Docker Desktop`_**)
```bash
curl -L "https://github.com/docker/compose/releases/download/v2.10.2/docker-compose-$(uname -s)-$(uname -m)" \
-o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
```
4. Clone the repo
```bash
git clone https://github.com/nikhilbadyal/docker-py-revanced
```
5. cd to the cloned repo
```bash
cd docker-py-revanced
```
6. Update `.env` file if you want some customization(See notes)
7. Run script with
```shell
docker-compose up
```

- 🐳With Docker

1. Install Docker(Skip if already installed)
```bash
curl -fsSL https://get.docker.com -o get-docker.sh
sh get-docker.sh
```
2. Run script with
```shell
docker run -v "$(pwd)"/apks:/app/apks/ nikhilbadyal/docker-py-revanced
```
You can pass the below environment variables (See notes) with the `-e` flag or use the `--env-file`
[flag](https://docs.docker.com/engine/reference/commandline/run/#options).

- 🫠Without Docker

1. Install Java17 (zulu preferred)
2. Install Python
3. Create virtual environment
```
python3 -m venv venv
```
4. Activate virtual environment
```
source venv/bin/activate
```
5. Install Dependencies with
```
pip install -r requirements.txt
```
6. Run the script with
```
python python main.py
```

## Note

(Pay attention to 3,4)<br>
By default, script build the version as recommended by Revanced team.

1. Supported values for **REVANCED_APPS_NAME** are :

1. [youtube](https://www.apkmirror.com/apk/google-inc/youtube/)
2. [youtube_music](https://www.apkmirror.com/apk/google-inc/youtube-music/)
3. [twitter](https://www.apkmirror.com/apk/twitter-inc/twitter/)
4. [reddit](https://www.apkmirror.com/apk/redditinc/reddit/)
5. [tiktok](https://www.apkmirror.com/apk/tiktok-pte-ltd/tik-tok-including-musical-ly/)
6. [warnwetter](https://www.apkmirror.com/apk/deutscher-wetterdienst/warnwetter/)
7. [spotify](https://spotify.en.uptodown.com/android)
8. [nyx-music-player](https://nyx-music-player.en.uptodown.com/android)
9. [icon_pack_studio](https://www.apkmirror.com/apk/smart-launcher-team/icon-pack-studio/)
10. [ticktick](https://www.apkmirror.com/apk/appest-inc/ticktick-to-do-list-with-reminder-day-planner/)
11. [twitch](https://www.apkmirror.com/apk/twitch-interactive-inc/twitch/)
12. [hex-editor](https://m.apkpure.com/hex-editor/com.myprog.hexedit)
13. [windy](https://www.apkmirror.com/apk/windy-weather-world-inc/windy-wind-weather-forecast/)
14. [my-expenses](https://my-expenses.en.uptodown.com/android)
15. [backdrops](https://backdrops.en.uptodown.com/android)
16. [expensemanager](https://apksos.com/app/com.ithebk.expensemanager)
17. [tasker](https://www.apkmirror.com/apk/joaomgcd/tasker-crafty-apps-eu/)
18. [irplus](https://irplus.en.uptodown.com/android)
19. [vsco](https://www.apkmirror.com/apk/vsco/vsco-cam/)
20. [meme-generator-free](https://meme-generator-free.en.uptodown.com/android)
21. [nova_launcher](https://www.apkmirror.com/apk/teslacoil-software/nova-launcher/)
22. [netguard](https://www.apkmirror.com/apk/marcel-bokhorst/netguard-no-root-firewall/)
23. [instagram](https://www.apkmirror.com/apk/instagram/instagram-instagram/)
24. [inshorts](https://www.apkmirror.com/apk/inshorts-formerly-news-in-shorts/)
25. [facebook](https://www.apkmirror.com/apk/facebook-2/facebook/)
26. [grecorder](https://www.apkmirror.com/apk/google-inc/google-recorder/)
27. [trakt](https://www.apkmirror.com/apk/trakt/trakt/)
28. [candyvpn](https://www.apkmirror.com/apk/liondev-io/candylink-vpn/)
29. [sonyheadphone](https://www.apkmirror.com/apk/sony-corporation/sony-headphones-connect/)
30. [androidtwelvewidgets](https://m.apkpure.com/android-12-widgets-twelve/com.dci.dev.androidtwelvewidgets)
31. [yuka](https://yuka.en.uptodown.com/android)
32. [relay](https://www.apkmirror.com/apk/dbrady/relay-for-reddit-2/)
33. [boost](https://www.apkmirror.com/apk/ruben-mayayo/boost-for-reddit/)
34. [rif](https://www.apkmirror.com/apk/talklittle/reddit-is-fun/)
35. [sync](https://www.apkmirror.com/apk/red-apps-ltd/sync-for-reddit/)
36. [infinity](https://www.apkmirror.com/apk/red-apps-ltd/sync-for-reddit/)
37. [slide](https://www.apkmirror.com/apk/haptic-apps/slide-for-reddit/)
38. [bacon](https://www.apkmirror.com/apk/onelouder-apps/baconreader-for-reddit/)
39. [microg](https://github.com/inotia00/mMicroG/releases)

<br>Please verify the source of original APKs yourself with links provided. I'm not responsible for any damaged caused.
If you know any better/safe source to download clean. Please raise a PR.
2. Remember to download the **_Microg_**. Otherwise, you will not be able to open YouTube.
>>>>>>> 771808ec31632e80cdcc677f5bb0bfb0ee21802d
3. By default, it will build only `youtube`. To build other apps supported by revanced team.
Add the apps you want to build in `.env` file or in `ENVS` in
`GitHub secrets` in the format
Expand Down
38 changes: 38 additions & 0 deletions apks/options.json
Original file line number Diff line number Diff line change
@@ -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 changes: 27 additions & 0 deletions apks/populate_client_id.sh
Original file line number Diff line number Diff line change
@@ -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}"
32 changes: 24 additions & 8 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@
from loguru import logger

from src.config import RevancedConfig
from src.downloader import Downloader
from src.downloader.factory import DownloaderFactory
from src.downloader.utils import download_revanced
from src.parser import Parser
from src.patches import Patches
from src.utils import AppNotFound
from src.utils import AppNotFound, PatcherDownloadFailed


def main() -> None:
Expand All @@ -17,17 +18,24 @@ def main() -> None:
config = RevancedConfig(env)

patcher = Patches(config)
downloader = Downloader(patcher, config)
parser = Parser(patcher, config)
try:
download_revanced(config, patcher)
except PatcherDownloadFailed as e:
logger.error(f"Failed to download {e}")
sys.exit(1)

logger.info(f"Will Patch only {patcher.config.apps}")
for app in patcher.config.apps:
try:
logger.info("Trying to build %s" % app)
parser = Parser(patcher, config)
app_all_patches, version, is_experimental = patcher.get_app_configs(app)
version = downloader.download_apk_to_patch(version, app)
config.app_versions[app] = version
patcher.include_exclude_patch(app, parser, app_all_patches)
downloader = DownloaderFactory.create_downloader(
app=app, patcher=patcher, config=config
)
downloader.download(version, app)
config.app_versions[app] = version
logger.info(f"Downloaded {app}, version {version}")
parser.patch_app(app=app, version=version, is_experimental=is_experimental)
except AppNotFound as e:
Expand All @@ -36,7 +44,11 @@ def main() -> None:
logger.exception(f"Failed to build {app} because of {e}")
if len(config.alternative_youtube_patches) and "youtube" in config.apps:
for alternative_patch in config.alternative_youtube_patches:
_, version, is_experimental = patcher.get_app_configs("youtube")
parser = Parser(patcher, config)
app_all_patches, version, is_experimental = patcher.get_app_configs(
"youtube"
)
patcher.include_exclude_patch("youtube", parser, app_all_patches)
was_inverted = parser.invert_patch(alternative_patch)
if was_inverted:
logger.info(
Expand All @@ -54,7 +66,11 @@ def main() -> None:
)
if len(config.alternative_youtube_music_patches) and "youtube_music" in config.apps:
for alternative_patch in config.alternative_youtube_music_patches:
_, version, is_experimental = patcher.get_app_configs("youtube_music")
parser = Parser(patcher, config)
app_all_patches, version, is_experimental = patcher.get_app_configs(
"youtube_music"
)
patcher.include_exclude_patch("youtube_music", parser, app_all_patches)
was_inverted = parser.invert_patch(alternative_patch)
if was_inverted:
logger.info(
Expand Down
Loading

0 comments on commit b40d855

Please sign in to comment.