Skip to content

Instantly share code, notes, and snippets.

@ph1048
Created October 14, 2023 09:36
Show Gist options
  • Save ph1048/9e2c5a06055de753160c6429cd376a68 to your computer and use it in GitHub Desktop.
Save ph1048/9e2c5a06055de753160c6429cd376a68 to your computer and use it in GitHub Desktop.
install pkg
#!/usr/bin/python3
import requests
import sys
import os
import string
import random
PS4HOST = "192.168.1.234"
PKGBASEURL = "http://ps4pkg.lan/dl"
BASELOCALPATH = "/path/to/Downloads" #no trailing slash
LINKDIR = ".pspkglink"
def rndstr(N):
return ''.join(random.choice(string.ascii_uppercase + string.digits) for _ in range(N))
if len(sys.argv) <= 1:
print("Usage: pkgsend.py <path to pkg>")
exit()
try:
os.mkdir(os.path.join(BASELOCALPATH,LINKDIR))
except:
pass
#path = os.path.abspath(sys.argv[1])
#pfx = os.path.commonprefix([path, BASELOCALPATH])
#if pfx != BASELOCALPATH:
# print("Error: path " + path + " not in base path " + BASELOCALPATH)
# exit()
#rp = os.path.relpath(path, pfx)
rnd = rndstr(10) + ".pkg"
os.symlink(os.path.abspath(sys.argv[1]), os.path.join(BASELOCALPATH,LINKDIR,rnd))
pkurl = PKGBASEURL+"/"+LINKDIR+"/"+rnd
print("Sending pkg: " + pkurl)
url = 'http://'+PS4HOST+':12800/api/install'
data = {"type":"direct","packages":[pkurl]}
r = requests.post(url, json=data)
print(r.status_code)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment