From 9c178077f4706699942395f6088ad0fb2b4499a7 Mon Sep 17 00:00:00 2001 From: j-hc Date: Fri, 2 Jun 2023 12:56:46 +0300 Subject: [PATCH] update apkmirror parsing --- build.sh | 30 ++++++++++++++++-------------- config.toml | 4 ---- utils.sh | 21 ++++++++++++--------- 3 files changed, 28 insertions(+), 27 deletions(-) diff --git a/build.sh b/build.sh index c99d4a2..210df1e 100755 --- a/build.sh +++ b/build.sh @@ -37,7 +37,7 @@ DEF_PATCHES_SRC=$(toml_get "$main_config_t" patches-source) || DEF_PATCHES_SRC=" DEF_INTEGRATIONS_SRC=$(toml_get "$main_config_t" integrations-source) || DEF_INTEGRATIONS_SRC="revanced/revanced-integrations" DEF_RV_BRAND=$(toml_get "$main_config_t" rv-brand) || DEF_RV_BRAND="ReVanced" # -- Main config -- -mkdir -p $TEMP_DIR +mkdir -p $TEMP_DIR $BUILD_DIR if ((COMPRESSION_LEVEL > 9)) || ((COMPRESSION_LEVEL < 0)); then abort "compression-level must be within 0-9"; fi if [ "$BUILD_MINDETACH_MODULE" = true ]; then : >$PKGS_LIST; fi @@ -48,20 +48,20 @@ jq --version >/dev/null || abort "\`jq\` is not installed. install it with 'apt java --version >/dev/null || abort "\`openjdk 17\` is not installed. install it with 'apt install openjdk-17-jre-headless' or equivalent" zip --version >/dev/null || abort "\`zip\` is not installed. install it with 'apt install zip' or equivalent" # -- - get_prebuilts + set_prebuilts() { - app_args[cli]=$(find "$1" -name "revanced-cli*.jar" -type f -print -quit 2>/dev/null) && [ "${app_args[cli]}" ] || return 1 - app_args[integ]=$(find "$1" -name "revanced-integrations-*.apk" -type f -print -quit) && [ "${app_args[integ]}" ] || return 1 - app_args[ptjar]=$(find "$1" -name "revanced-patches-*.jar" -type f -print -quit) && [ "${app_args[ptjar]}" ] || return 1 - app_args[ptjs]=$(find "$1" -name "patches-*.json" -type f -print -quit) && [ "${app_args[ptjs]}" ] || return 1 + app_args[cli]=$(find "$1" -name "revanced-cli-*.jar" -type f -print -quit 2>/dev/null) && [ "${app_args[cli]}" ] || return 1 + app_args[integ]=$(find "$1" -name "revanced-integrations-*.apk" -type f -print -quit 2>/dev/null) && [ "${app_args[integ]}" ] || return 1 + app_args[ptjar]=$(find "$1" -name "revanced-patches-*.jar" -type f -print -quit 2>/dev/null) && [ "${app_args[ptjar]}" ] || return 1 + app_args[ptjs]=$(find "$1" -name "patches-*.json" -type f -print -quit 2>/dev/null) && [ "${app_args[ptjs]}" ] || return 1 } build_rv_w() { if [ "$LOGGING_F" = true ]; then logf=logs/"${table_name,,}.log" : >"$logf" - build_rv 2>&1 "$(declare -p app_args)" | tee "$logf" + build_rv 2>&1 "$(declare -p app_args)" | tee "$logf" else build_rv "$(declare -p app_args)" fi @@ -81,9 +81,12 @@ for table_name in $(toml_get_table_names); do prebuilts_dir=${patches_src%/*} prebuilts_dir=${TEMP_DIR}/${prebuilts_dir//[^[:alnum:]]/}-rv if ! set_prebuilts "$prebuilts_dir"; then - mkdir -p "$BUILD_DIR" "$prebuilts_dir" - get_rv_prebuilts "$integrations_src" "$patches_src" "$prebuilts_dir" - set_prebuilts "$prebuilts_dir" + mkdir -p "$prebuilts_dir" + read -r rv_cli_jar rv_integrations_apk rv_patches_jar rv_patches_json <<<"$(get_rv_prebuilts "$integrations_src" "$patches_src" "$prebuilts_dir")" + app_args[cli]=$rv_cli_jar + app_args[integ]=$rv_integrations_apk + app_args[ptjar]=$rv_patches_jar + app_args[ptjs]=$rv_patches_json fi app_args[rv_brand]=$(toml_get "$t" rv-brand) || app_args[rv_brand]="$DEF_RV_BRAND" @@ -151,10 +154,9 @@ if [ "$BUILD_MINDETACH_MODULE" = true ]; then fi if youtube_t=$(toml_get_table "YouTube"); then youtube_mode=$(toml_get "$youtube_t" "build-mode") || youtube_mode="apk"; else youtube_mode="module"; fi -if music_arm_t=$(toml_get_table "Music-arm"); then music_arm_mode=$(toml_get "$music_arm_t" "build-mode") || music_arm_mode="apk"; else music_arm_mode="module"; fi -if music_arm64_t=$(toml_get_table "Music-arm64"); then music_arm64_mode=$(toml_get "$music_arm64_t" "build-mode") || music_arm64_mode="apk"; else music_arm64_mode="module"; fi -if [ "$youtube_mode" != module ] || [ "$music_arm_mode" != module ] || [ "$music_arm64_mode" != module ]; then - log "\nInstall [Vanced Microg](https://github.com/TeamVanced/VancedMicroG/releases) to be able to use non-root YouTube or Music" +if music_t=$(toml_get_table "Music"); then music_mode=$(toml_get "$music_t" "build-mode") || music_mode="apk"; else music_mode="module"; fi +if [ "$youtube_mode" != module ] || [ "$music_mode" != module ]; then + log "\nInstall [Vanced Microg](https://github.com/TeamVanced/VancedMicroG/releases) for non-root YouTube or YT Music" fi log "\n[revanced-magisk-module](https://github.com/j-hc/revanced-magisk-module)" log "\n---\nChangelog:" diff --git a/config.toml b/config.toml index aa75a19..fd82a35 100755 --- a/config.toml +++ b/config.toml @@ -20,8 +20,6 @@ patches-source = "inotia00/revanced-patches" integrations-source = "inotia00/revanced-integrations" rv-brand = "ReVanced Extended" build-mode = "both" -excluded-patches = "" -included-patches = "" apkmirror-dlurl = "https://www.apkmirror.com/apk/google-inc/youtube/" [Music] @@ -37,7 +35,6 @@ patches-source = "inotia00/revanced-patches" integrations-source = "inotia00/revanced-integrations" rv-brand = "ReVanced Extended" build-mode = "both" -excluded-patches = "" apkmirror-dlurl = "https://www.apkmirror.com/apk/google-inc/youtube-music/" arch = "both" @@ -58,7 +55,6 @@ apkmirror-dlurl = "https://www.apkmirror.com/apk/tiktok-pte-ltd/tik-tok-includin apkmirror-dlurl = "https://www.apkmirror.com/apk/redditinc/reddit/" [Messenger] -enabled = false apkmirror-dlurl = "https://www.apkmirror.com/apk/facebook-2/messenger/" arch = "arm64-v8a" diff --git a/utils.sh b/utils.sh index 74062fc..201b40d 100755 --- a/utils.sh +++ b/utils.sh @@ -8,7 +8,7 @@ PKGS_LIST="${TEMP_DIR}/module-pkgs" if [ "${GITHUB_TOKEN:-}" ]; then GH_HEADER="Authorization: token ${GITHUB_TOKEN}"; else GH_HEADER=; fi NEXT_VER_CODE=${NEXT_VER_CODE:-$(date +'%Y%m%d')} -REBUILD=false +REBUILD=${REBUILD:-false} OS=$(uname -o) SERVICE_SH=$(cat $MODULE_SCRIPTS_DIR/service.sh) @@ -45,7 +45,7 @@ abort() { get_rv_prebuilts() { local integrations_src=$1 patches_src=$2 prebuilts_dir=$3 - pr "Getting prebuilts ($prebuilts_dir)" + pr "Getting prebuilts ($prebuilts_dir)" >&2 local rv_cli_url rv_integrations_url rv_patches rv_patches_changelog rv_patches_dl rv_patches_url rv_patches_json rv_cli_url=$(gh_req "https://api.github.com/repos/j-hc/revanced-cli/releases/latest" - | json_get 'browser_download_url') || return 1 @@ -71,10 +71,12 @@ get_rv_prebuilts() { echo "Patches: $(cut -d/ -f4 <<<"$rv_patches_url")/$(cut -d/ -f9 <<<"$rv_patches_url") " >>"$prebuilts_dir/changelog.md" echo -e "\n${rv_patches_changelog//# [/### [}\n---" >>"$prebuilts_dir/changelog.md" - dl_if_dne "$rv_cli_jar" "$rv_cli_url" - dl_if_dne "$rv_integrations_apk" "$rv_integrations_url" - dl_if_dne "$rv_patches_jar" "$rv_patches_url" - dl_if_dne "$rv_patches_json" "$(grep 'json' <<<"$rv_patches_dl")" + dl_if_dne "$rv_cli_jar" "$rv_cli_url" >&2 + dl_if_dne "$rv_integrations_apk" "$rv_integrations_url" >&2 + dl_if_dne "$rv_patches_jar" "$rv_patches_url" >&2 + dl_if_dne "$rv_patches_json" "$(grep 'json' <<<"$rv_patches_dl")" >&2 + + echo "$rv_cli_jar" "$rv_integrations_apk" "$rv_patches_jar" "$rv_patches_json" } get_prebuilts() { @@ -170,8 +172,8 @@ dl_apkmirror() { [ "$arch" = universal ] && apparch=(universal noarch 'arm64-v8a + armeabi-v7a') || apparch=("$arch") url="${url}/${url##*/}-${version//./-}-release/" resp=$(req "$url" -) || return 1 - for ((n = 2; n < 40; n++)); do - node=$($HTMLQ "div.table-row:nth-child($n)" -r "span:nth-child(n+3)" <<<"$resp") + for ((n = 1; n < 40; n++)); do + node=$($HTMLQ "div.table-row.headerFont:nth-last-child($n)" -r "span:nth-child(n+3)" <<<"$resp") if [ -z "$node" ]; then break; fi app_table=$($HTMLQ --text --ignore-whitespace <<<"$node") if [ "$(sed -n 3p <<<"$app_table")" = "$apkorbundle" ] && { [ "$apkorbundle" = BUNDLE ] || @@ -307,6 +309,7 @@ build_rv() { fi pr "Choosing version '${version}' for ${table}" local version_f=${version// /} + version_f=${version_f#v} local stock_apk="${TEMP_DIR}/${pkg_name}-${version_f}-${arch_f}.apk" if [ ! -f "$stock_apk" ]; then for dl_p in apkmirror uptodown apkmonk; do @@ -450,7 +453,7 @@ build_rv() { "https://raw.githubusercontent.com/${GITHUB_REPOSITORY:-}/update/${upj}" \ "$base_template" - local module_output="${app_name_l}-${rv_brand_f}-magisk-v${version}-${arch_f}.zip" + local module_output="${app_name_l}-${rv_brand_f}-magisk-v${version_f}-${arch_f}.zip" if [ ! -f "$module_output" ] || [ "$REBUILD" = true ]; then pr "Packing module ${table}" cp -f "$patched_apk" "${base_template}/base.apk"