-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsamsung-apk-downloader.sh
executable file
·99 lines (84 loc) · 3.17 KB
/
samsung-apk-downloader.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#!/usr/bin/env bash
#
# Copyright (C) 2024 PeterKnecht93
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# [
bold='\e[1m'
italic='\e[3m'
end='\e[0m'
red='\e[91m'
green='\e[92m'
blue='\e[94m'
yellow='\e[93m'
# ]
if [[ $# == 0 ]]; then
echo -ne "${green}Enter package name (Samsung apps only): ${end}"
read -r "PACKAGE"
echo -ne "${green}Enter your device model (${yellow}SM-XXXXX${green} format): ${end}"
read -r "MODEL"
echo -ne "${green}Enter your android version (SDK format - ${yellow}19 30 34${green} etc.): ${end}"
read -r "SDK"
echo ""
[[ -z $PACKAGE || -z $MODEL || -z $SDK ]] && echo -e "${red}Not all fields were filled out!${end}" && exit 1
elif [[ $# == 3 ]]; then
PACKAGE=$1
MODEL=$2
SDK=$3
else
echo -e "${italic}Usage: $0 <package> <model> <sdk> ${end} or"
echo -e "${italic}Usage: $0 ${end} for inputting details manually \n"
echo -e "${bold}package:${end} Package Name 'com.package.name'"
echo -e "${bold}model:${end} Model Number 'SM-XXXXX'"
echo -e "${bold}sdk:${end} SDK Level (19-34)"
exit 1
fi
URL_FORMAT="https://vas.samsungapps.com/stub/stubDownload.as?appId=${PACKAGE}&deviceId=${MODEL}\
&mcc=425&mnc=01&csc=ILO&sdkVer=${SDK}&pd=0&systemId=1608665720954&callerId=com.sec.android.app.samsungapps\
&abiType=64&extuk=0191d6627f38685f"
URL=$(curl -s "$URL_FORMAT")
MATCH=(
"$(echo "$URL" | grep -w "resultCode" | sed "s/<resultCode>//; s/<\/resultCode>//")"
"$(echo "$URL" | grep -w "resultMsg" | sed "s/<resultMsg>//; s/<\/resultMsg>//")"
"$(echo "$URL" | grep -Po '(?<=<downloadURI><!\[CDATA\[).*(?=\]\]></downloadURI>)')"
"$(echo "$URL" | sed -n 's/.*<versionCode>\([0-9]\+\)<\/versionCode>.*/\1/p')"
"$(echo "$URL" | grep -w "versionName" | sed "s/<versionName>//; s/<\/versionName>//")"
)
for match in "${MATCH[@]}"; do
if [[ -z $match ]]; then
error_msg=$(grep -oP 'resultMsg>\K.*?(?=<\/resultMsg>)' <<< "$URL")
if [[ -n $error_msg ]]; then
echo -e "${blue}Samsung Servers: ${red}$error_msg${end}"
else
echo -e "${red}No result!${end}"
fi
exit 1
fi
done
echo -e "${blue}The available versionCode is: ${yellow}${MATCH[3]}${end}"
echo -e "${blue}The available versionName is: ${yellow}${MATCH[4]}${end}"
echo ""
echo -ne "${blue}Do you want to download the APK? ${yellow}[Y/n]: ${end}"
read -r "input"
echo ""
case "$input" in
"Y" | "y" | "")
APK="${PACKAGE}-${MATCH[3]}.apk"
echo -e "${blue}Download started!...${end}"
wget -O "$APK" "${MATCH[2]}" &> /dev/null
echo -e "${blue}APK saved: ${yellow}\"$PWD/$APK\"${end}"
;;
esac
echo ""