Kodi Community Forum
trying to get my apk installer to work with kodi 18 - Printable Version

+- Kodi Community Forum (https://forum.kodi.tv)
+-- Forum: Development (https://forum.kodi.tv/forumdisplay.php?fid=32)
+--- Forum: Add-ons (https://forum.kodi.tv/forumdisplay.php?fid=26)
+--- Thread: trying to get my apk installer to work with kodi 18 (/showthread.php?tid=350931)



trying to get my apk installer to work with kodi 18 - daveftw84 - 2020-01-13

it worked with kodi 17 and below but kodi 18 fails to prompt the install. i found some code on here that says is suppose to work for 18 but im getting indent errors when trying to implant it into my addon.
its driving me nuts and i was wondering if anyone can look at if for me?
python:
import xbmc, xbmcgui
import urllib2,urllib
import os,sys,re
import time
import shutil
import base64,zipfile
import platform, subprocess
import xbmc, xbmcaddon, xbmcgui, xbmcplugin, os, subprocess
dialog = xbmcgui.Dialog()


def iiNT3LiiCheckURL(url):
    try:
        req = urllib2.Request(url)
        req.add_header('User-Agent', 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3')
        response = urllib2.urlopen(req)
        link=response.read()
        response.close()
        return link
    except:
        return False


def iiNT3LiiBrothers(url):
    Jose = url
    Mathews = base64.b64decode(Jose)
    iiNT3LiiG3NCii = base64.b64decode(Mathews)
    Robb = base64.b64decode(iiNT3LiiG3NCii)
    return Robb



def launch_command(command_launch):
    try:
        xbmc.log('[%s] %s' % ('LAUNCHING SUBPROCESS:', command_launch), 2)
        external_command = subprocess.call(command_launch, shell = True, executable = '/system/bin/sh')
    except Exception, e:
        try:
            xbmc.log('[%s] %s' % ('ERROR LAUNCHING COMMAND !!!', e.message, external_command), 2)
            xbmc.log('[%s] %s' % ('LAUNCHING OS:', command_launch), 2)
            external_command = os.system(command_launch)
        except:
            xbmc.log('[%s]' % ('ERROR LAUNCHING COMMAND !!!', external_command), 2)


if xbmc.getCondVisibility('system.platform.android'):
    iiNT3LiiAPK = subprocess.Popen(['exec ''/system/bin/pm list packages -3'''], executable='/system/bin/sh', shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT).communicate()[0].rstrip('\n').splitlines()
    for i in range(len(iiNT3LiiAPK)):
        iiNT3LiiAPK[i] = iiNT3LiiAPK[i].partition(':')[2]


    if 'com.retroarch' not in iiNT3LiiAPK:
        path = xbmc.translatePath(os.path.join('special://home/addons','packages'))
        lib = os.path.join(path, 'Retro.apk')
        try: os.remove(lib)
        except: pass
        url = iiNT3LiiBrothers('WVVoU01HTklUVFpNZVRrelpETmpkVnBJU25aalIwcDJaVU0xYW1JeU1IWmplVGt3VGpOa00xcFhVVEJOV0ZKb1QwaHdiVmxYZDNaVmJWWXdZMjA1UW1OdFRtOU5hVFZvWTBkekwxcEhkemxOVVQwOQ==') # base64 encoded 3 times
        urllib.urlretrieve(url, lib)
        xbmcgui.Dialog().ok("[COLOR cyan]Standard-inc[/COLOR]","[COLOR cyan]Detected a Required App Not On The System![/COLOR]","[COLOR cyan]Please Install When Prompted To Install![/COLOR]","")
        path = xbmc.translatePath(os.path.join('special://home/addons','packages'))
        pathdownload = os.path.join(path, 'Retro.apk')
        command = 'pm install -rgd' + pathdownload
        launch_command(command)
        theZip = os.path.join(path,"retroStuff.zip")
        urllib.urlretrieve(iiNT3LiiBrothers("WVVoU01HTklUVFpNZVRrelpETmpkVnBJU25aalIwcDJaVU0xYW1JeU1IWmplVGx6WlZoQmVHVlhUbmRqUjNSdVRtNUdkbUZJUVhaVmJWWXdZMjA1UW1OdFRtOU1ibkJ3WTBRNWEySkVNSGc9"),theZip)
        match = re.compile('(/Android/data/[^/]*/files/[^/]*/)').findall(xbmc.translatePath("special://home"))
        if match:
            thePath = xbmc.translatePath("special://home").replace(match[0],"/")
        else:
            thePath = "/sdcard/"
        theUnzip = zipfile.ZipFile(theZip)
        for i in theUnzip.infolist():
            try:
                theUnzip.extract(i,thePath)
            except:
                pass
        xbmcgui.Dialog().ok("[COLOR cyan]Standard-inc[/COLOR]","","[COLOR cyan]Operation Completed![/COLOR]","")
        try: os.remove(lib)
        except: pass



RE: trying to get my apk installer to work with kodi 18 - ronie - 2020-01-13

i don't see any indent errors in the code you've posted above.
but without a log it's hard to tell what the problem is.


RE: trying to get my apk installer to work with kodi 18 - Lunatixz - 2020-01-13

What's up with the obfuscated urls?


RE: trying to get my apk installer to work with kodi 18 - daveftw84 - 2020-01-13

(2020-01-13, 03:29)Lunatixz Wrote: What's up with the obfuscated urls?

keep basic people from seeing them


RE: trying to get my apk installer to work with kodi 18 - Lunatixz - 2020-01-13

(2020-01-13, 03:54)daveftw84 Wrote:
(2020-01-13, 03:29)Lunatixz Wrote: What's up with the obfuscated urls?

keep basic people from seeing them

I understand obfuscation of api keys, however IMO obfuscating urls make anything you're up to sketchy... Regardless of what the URL actually is.


RE: trying to get my apk installer to work with kodi 18 - daveftw84 - 2020-01-13

(2020-01-13, 04:09)Lunatixz Wrote:
(2020-01-13, 03:54)daveftw84 Wrote:
(2020-01-13, 03:29)Lunatixz Wrote: What's up with the obfuscated urls?

keep basic people from seeing them 

I understand obfuscation of api keys, however IMO obfuscating urls make anything you're up to sketchy... Regardless of what the URL actually is. 
but most api keys are free ....


RE: trying to get my apk installer to work with kodi 18 - daveftw84 - 2020-01-13

(2020-01-13, 02:58)ronie Wrote: i don't see any indent errors in the code you've posted above.
but without a log it's hard to tell what the problem is.
i fixed the indent by re pasting the code back in the py.
its still not prompting the install

https://paste.kodi.tv/raw/opexoqurit


RE: trying to get my apk installer to work with kodi 18 - ronie - 2020-01-13

2020-01-13 10:53:04.191 T:11434 NOTICE: [LAUNCHING SUBPROCESS:] pm install -rgd/storage/emulated/0/Android/data/org.xbmc.kodi/files/.kodi/addons/packages/Retro.apk

my guess would be there needs to be a space between the command and the path


RE: trying to get my apk installer to work with kodi 18 - daveftw84 - 2020-01-13

(2020-01-13, 21:51)ronie Wrote: 2020-01-13 10:53:04.191 T:11434 NOTICE: [LAUNCHING SUBPROCESS:] pm install -rgd/storage/emulated/0/Android/data/org.xbmc.kodi/files/.kodi/addons/packages/Retro.apk

my guess would be there needs to be a space between the command and the path
i saw that and edit the command to have a space 'pm install -rgd '
log reflected it and still did nothing


RE: trying to get my apk installer to work with kodi 18 - ronie - 2020-01-13

i don't think subprocess.call() will raise an exception if the returncode is non-zero ?

perhaps give it a shot with subprocess.check_output() which can capture and return any errors:
https://docs.python.org/2/library/subprocess.html#subprocess.check_output


RE: trying to get my apk installer to work with kodi 18 - daveftw84 - 2020-01-13

here is what i have so far 
python:
import xbmc, xbmcgui
import urllib2,urllib
import os,sys,re
import time
import shutil
import base64,zipfile
import platform, subprocess
import xbmc, xbmcaddon, xbmcgui, xbmcplugin, os, subprocess
dialog = xbmcgui.Dialog()


def iiNT3LiiCheckURL(url):
    try:
        req = urllib2.Request(url)
        req.add_header('User-Agent', 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3')
        response = urllib2.urlopen(req)
        link=response.read()
        response.close()
        return link
    except:
        return False


def iiNT3LiiBrothers(url):
    Jose = url
    Mathews = base64.b64decode(Jose)
    iiNT3LiiG3NCii = base64.b64decode(Mathews)
    Robb = base64.b64decode(iiNT3LiiG3NCii)
    return Robb



def launch_command(command_launch):
    try:
        xbmc.log('[%s] %s' % ('LAUNCHING SUBPROCESS:', command_launch), 2)
        external_command = subprocess.call(command_launch, shell = True, executable = '/system/bin/sh')
    except Exception, e:
        try:
            xbmc.log('[%s] %s' % ('ERROR LAUNCHING COMMAND !!!', e.message, external_command), 2)
            xbmc.log('[%s] %s' % ('LAUNCHING OS:', command_launch), 2)
            external_command = os.system(command_launch)
        except:
            xbmc.log('[%s]' % ('ERROR LAUNCHING COMMAND !!!', external_command), 2)


if xbmc.getCondVisibility('system.platform.android'):
    iiNT3LiiAPK = subprocess.Popen(['exec ''/system/bin/pm list packages -3'''], executable='/system/bin/sh', shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT).communicate()[0].rstrip('\n').splitlines()
    for i in range(len(iiNT3LiiAPK)):
        iiNT3LiiAPK[i] = iiNT3LiiAPK[i].partition(':')[2]


    if 'com.retroarch' not in iiNT3LiiAPK:
        path = xbmc.translatePath(os.path.join('special://home/addons','packages'))
        lib = os.path.join(path, 'Retro.apk')
        url = iiNT3LiiBrothers('WVVoU01HTkViM1pNTTJnMFpXazFkMlI1T1doalNFSjZUREZLYkdSSVNuWlJXRXBxWVVSSmRWbFlRbkk9')
        urllib.urlretrieve(url, lib)
        xbmcgui.Dialog().ok("[COLOR cyan]Standard-inc[/COLOR]","[COLOR cyan]Detected a Required App Not On The System![/COLOR]","[COLOR cyan]Please Install When Prompted To Install![/COLOR]","")
        command = 'pm install -r -g -d ' + lib
        launch_command(command)
        xbmc.executebuiltin('StartAndroidActivity("","android.intent.action.VIEW","application/vnd.android.package-archive","file:'+lib+'")')
        theZip = os.path.join(path,"retroStuff.zip")
        urllib.urlretrieve(iiNT3LiiBrothers("WVVoU01HTklUVFpNZVRrelpETmpkVnBJU25aalIwcDJaVU0xYW1JeU1IWmplVGx6WlZoQmVHVlhUbmRqUjNSdVRtNUdkbUZJUVhaVmJWWXdZMjA1UW1OdFRtOU1ibkJ3WTBRNWEySkVNSGc9"),theZip)
        match = re.compile('(/Android/data/[^/]*/files/[^/]*/)').findall(xbmc.translatePath("special://home"))
        if match:
            thePath = xbmc.translatePath("special://home").replace(match[0],"/")
        else:
            thePath = "/sdcard/"
        theUnzip = zipfile.ZipFile(theZip)
        for i in theUnzip.infolist():
            try:
                theUnzip.extract(i,thePath)
            except:
                pass
        xbmcgui.Dialog().ok("[COLOR cyan]Standard-inc[/COLOR]","","[COLOR cyan]Operation Completed![/COLOR]","")
        try: os.remove(lib)
        except: pass



RE: trying to get my apk installer to work with kodi 18 - daveftw84 - 2020-01-13

i removed anything that would delete the apk before process is done. 
i cleaned up the immerssion of the code
i update the url to a known working one
and i included the old launch code as a second since it works on rooted boxes still.
just worked on the rooted box, but not the non rooted shield


RE: trying to get my apk installer to work with kodi 18 - Lunatixz - 2020-01-14

(2020-01-13, 18:31)daveftw84 Wrote:
(2020-01-13, 04:09)Lunatixz Wrote:
(2020-01-13, 03:54)daveftw84 Wrote: keep basic people from seeing them 

I understand obfuscation of api keys, however IMO obfuscating urls make anything you're up to sketchy... Regardless of what the URL actually is. 
but most api keys are free ....

Never paid for a URL before...


RE: trying to get my apk installer to work with kodi 18 - daveftw84 - 2020-01-24

(2020-01-14, 02:57)Lunatixz Wrote:
(2020-01-13, 18:31)daveftw84 Wrote:
(2020-01-13, 04:09)Lunatixz Wrote: I understand obfuscation of api keys, however IMO obfuscating urls make anything you're up to sketchy... Regardless of what the URL actually is. 
but most api keys are free .... 

Never paid for a URL before... 
im guessing you never paid for hosting


RE: trying to get my apk installer to work with kodi 18 - Lunatixz - 2020-01-24

(2020-01-24, 22:11)daveftw84 Wrote:
(2020-01-14, 02:57)Lunatixz Wrote:
(2020-01-13, 18:31)daveftw84 Wrote: but most api keys are free .... 

Never paid for a URL before...  
im guessing you never paid for hosting 

There is a huge difference between securing a domain ie. Login/Password... and obscuring a URL which gives zero transparency to the user and/or a simple inquiry via code review.

Either way good luck with your project; which is not Kodi / forum friendly due to obfuscation and limited transparency. Login/Password would have been allowed.