Last active
February 23, 2024 14:29
-
-
Save DuckOfDoom/07aaa75c71e7b402468d9983d58cea19 to your computer and use it in GitHub Desktop.
Python apk/obb installer. Chooses the most recent apk/obb by modification date, installs .apk and pushes obb to special folder
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!python | |
import os | |
import subprocess | |
package = "COM.YOUR.PACKAGE" | |
os.chdir(os.environ["HOME"] + "/Downloads") | |
def isApk(f): | |
return f.endswith(".apk"); | |
def isObb(f): | |
return f.endswith(".obb"); | |
def sortByTime(files): | |
return sorted(files, key=lambda x: os.path.getmtime(x), reverse=True) | |
apks = sortByTime(filter(lambda x: (isApk(x)), os.listdir('.'))) | |
obbs = sortByTime(filter(lambda x: (isObb(x)), os.listdir('.'))) | |
if len(apks) <= 0 or len(obbs) <= 0: | |
print "Did not find any pair of obb/apk files!" | |
exit() | |
apk = apks[0]; | |
obb = obbs[0]; | |
print("Will install most recent files:\nAPK: {apk}\nOBB: {obb}".format(apk=apk, obb=obb)) | |
# install new apk | |
subprocess.call("adb uninstall {p}".format(p=package)) | |
subprocess.call("adb install -r {apk}".format(apk=apk)) | |
obb_dir = "sdcard/Android/obb/" + package | |
# create dir for obb | |
subprocess.call("adb -d shell mkdir -p {d}".format(d=obb_dir)) | |
# push that baby | |
subprocess.call("adb push {obb} {obb_dir}".format(obb=obb, obb_dir=obb_dir)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment