예제 #1
0
 def check_update(self):
     need_update = False
     for libname in get_libname(self.platform):
         if libname != 'liblibtorrent.so':
             self.libpath = filetools.join(self.dest_path, libname)
             self.sizepath = filetools.join(self.root,
                                            self.platform['system'],
                                            self.platform['version'],
                                            libname + '.size.txt')
             size = str(filetools.getsize(self.libpath))
             size_old = open(self.sizepath, "r").read()
             if size_old != size:
                 need_update = True
     return need_update
예제 #2
0
 def download(self):
     __settings__ = xbmcaddon.Addon(id='plugin.video.alfa')  ### Alfa
     filetools.mkdir(self.dest_path)
     for libname in get_libname(self.platform):
         p_version = self.platform['version']
         if PY3: p_version += '_PY3'
         dest = os.path.join(self.dest_path, libname)
         log("try to fetch %s/%s/%s" %
             (self.platform['system'], p_version, libname))
         url = "%s/%s/%s/%s.zip" % (__libbaseurl__, self.platform['system'],
                                    p_version, libname)
         url_size = "%s/%s/%s/%s.size.txt" % (
             __libbaseurl__, self.platform['system'], p_version, libname)
         if libname != 'liblibtorrent.so':
             try:
                 self.http = HTTP()
                 self.http.fetch(url,
                                 download=dest + ".zip",
                                 progress=False)  ### Alfa
                 log("%s -> %s" % (url, dest))
                 self.http.fetch(url_size,
                                 download=dest + '.size.txt',
                                 progress=False)  ### Alfa
                 log("%s -> %s" % (url_size, dest + '.size.txt'))
                 xbmc.executebuiltin(
                     'XBMC.Extract("%s.zip","%s")' % (dest, self.dest_path),
                     True)
                 filetools.remove(dest + ".zip")
             except:
                 text = 'Failed download %s!' % libname
                 xbmc.executebuiltin("XBMC.Notification(%s,%s,%s,%s)" %
                                     (__plugin__, text, 750, __icon__))
         else:
             filetools.copy(os.path.join(self.dest_path, 'libtorrent.so'),
                            dest,
                            silent=True)  ### Alfa
         dest_alfa = os.path.join(xbmc.translatePath(__settings__.getAddonInfo('Path')), \
                         'lib', libname)                                     ### Alfa
         filetools.copy(dest, dest_alfa, silent=True)  ### Alfa
         dest_alfa = os.path.join(xbmc.translatePath(__settings__.getAddonInfo('Profile')), \
                         'custom_code', 'lib', libname)                      ### Alfa
         filetools.copy(dest, dest_alfa, silent=True)  ### Alfa
     return True
예제 #3
0
    def android_workaround(self, new_dest_path):                                ### Alfa (entera)

        for libname in get_libname(self.platform):
            libpath = filetools.join(self.dest_path, libname)
            size = str(filetools.getsize(libpath))
            new_libpath = filetools.join(new_dest_path, libname)

            if filetools.exists(new_libpath):
                new_size = str(filetools.getsize(new_libpath))
                if size != new_size:
                    res = filetools.remove(new_libpath, su=True)
                    if res:
                        log('Deleted: (%s) %s -> (%s) %s' %(size, libpath, new_size, new_libpath))
                    
            if not filetools.exists(new_libpath):
                res = filetools.copy(libpath, new_libpath, ch_mod='777', su=True)   ### ALFA

            else:
                log('Module exists.  Not copied... %s' % new_libpath)           ### ALFA

        return new_dest_path
예제 #4
0
    def download(self, dest_path='', platform=''):
        if dest_path: self.dest_path = dest_path
        if platform: self.platform = platform
        ver1, ver2, ver3 = platform['version'].split(
            '.')  ### Alfa: resto método
        try:
            ver1 = int(ver1)
            ver2 = int(ver2)
        except:
            ver1 = 2
            ver2 = 0
        if ver1 > 1 or (ver1 == 1 and ver2 >= 2):
            global __libbaseurl__
            __libbaseurl__ = ['https://github.com/alfa-addon/alfa-repo/raw/master/downloads/libtorrent', \
                              'https://gitlab.com/addon-alfa/alfa-repo/-/raw/master/downloads/libtorrent']
        else:
            __libbaseurl__ = [
                "https://github.com/DiMartinoXBMC/script.module.libtorrent/raw/master/python_libtorrent"
            ]

        __settings__ = xbmcaddon.Addon(id='plugin.video.alfa')  ### Alfa
        filetools.mkdir(self.dest_path)
        for libname in get_libname(self.platform):
            p_version = self.platform['version']
            if PY3: p_version += '_PY3'
            dest = filetools.join(self.dest_path, libname)
            log("try to fetch %s/%s/%s" %
                (self.platform['system'], p_version, libname))

            for url_lib in __libbaseurl__:  ### Alfa
                url = "%s/%s/%s/%s.zip" % (url_lib, self.platform['system'],
                                           p_version, libname)
                url_size = "%s/%s/%s/%s.size.txt" % (
                    url_lib, self.platform['system'], p_version, libname)
                if libname != 'liblibtorrent.so':
                    try:
                        self.http = HTTP()
                        response = self.http.fetch(url,
                                                   download=dest + ".zip",
                                                   progress=False)  ### Alfa
                        log("%s -> %s" % (url, dest))
                        if response.code != 200: continue  ### Alfa
                        response = self.http.fetch(url_size,
                                                   download=dest + '.size.txt',
                                                   progress=False)  ### Alfa
                        log("%s -> %s" % (url_size, dest + '.size.txt'))
                        if response.code != 200: continue  ### Alfa

                        try:
                            unzipper = ziptools.ziptools()
                            unzipper.extract("%s.zip" % dest, self.dest_path)
                        except:
                            xbmc.executebuiltin('Extract("%s.zip","%s")' %
                                                (dest, self.dest_path))
                            time.sleep(1)
                        if filetools.exists(dest):
                            filetools.remove(dest + ".zip")
                    except:
                        import traceback
                        text = 'Failed download %s!' % libname
                        log(text)
                        log(traceback.format_exc(1))
                        #xbmc.executebuiltin("Notification(%s,%s,%s,%s)" % (__plugin__,text,750,__icon__))
                        continue
                else:
                    filetools.copy(filetools.join(self.dest_path,
                                                  'libtorrent.so'),
                                   dest,
                                   silent=True)  ### Alfa

                #dest_alfa = filetools.join(filetools.translatePath(__settings__.getAddonInfo('Path')), \
                #                'lib', libname)                                 ### Alfa
                #filetools.copy(dest, dest_alfa, silent=True)                    ### Alfa
                dest_alfa = filetools.join(filetools.translatePath(__settings__.getAddonInfo('Profile')), \
                                'bin', libname)                                 ### Alfa
                filetools.remove(dest_alfa, silent=True)
                filetools.copy(dest, dest_alfa, silent=True)  ### Alfa
                break
            else:
                return False

        return True
예제 #5
0
파일: functions.py 프로젝트: xvacat/addon
 def check_exist(self):
     for libname in get_libname(self.platform):
         if not xbmcvfs.exists(os.path.join(self.dest_path, libname)):
             return False
     return True
예제 #6
0
파일: functions.py 프로젝트: xvacat/addon
    def android_workaround(self, new_dest_path):  ### Alfa (entera)
        import subprocess

        for libname in get_libname(self.platform):
            libpath = os.path.join(self.dest_path, libname)
            size = str(os.path.getsize(libpath))
            new_libpath = os.path.join(new_dest_path, libname)

            if xbmcvfs.exists(new_libpath):
                new_size = str(os.path.getsize(new_libpath))
                if size != new_size:
                    xbmcvfs.delete(new_libpath)
                    if xbmcvfs.exists(new_libpath):
                        try:
                            command = ['su', '-c', 'rm', '%s' % new_libpath]
                            p = subprocess.Popen(command,
                                                 stdout=subprocess.PIPE,
                                                 stderr=subprocess.PIPE)
                            output_cmd, error_cmd = p.communicate()
                            log('Comando ROOT: %s' % str(command))
                        except:
                            log('Sin PERMISOS ROOT: %s' % str(command))

                    if not xbmcvfs.exists(new_libpath):
                        log('Deleted: (%s) %s -> (%s) %s' %
                            (size, libpath, new_size, new_libpath))

            if not xbmcvfs.exists(new_libpath):
                xbmcvfs.copy(libpath, new_libpath, silent=True)  ### ALFA
                log('Copying... %s -> %s' % (libpath, new_libpath))

                if not xbmcvfs.exists(new_libpath):
                    try:
                        command = [
                            'su', '-c', 'cp',
                            '%s' % libpath,
                            '%s' % new_libpath
                        ]
                        p = subprocess.Popen(command,
                                             stdout=subprocess.PIPE,
                                             stderr=subprocess.PIPE)
                        output_cmd, error_cmd = p.communicate()
                        log('Comando ROOT: %s' % str(command))

                        command = [
                            'su', '-c', 'chmod', '775',
                            '%s' % new_libpath
                        ]
                        p = subprocess.Popen(command,
                                             stdout=subprocess.PIPE,
                                             stderr=subprocess.PIPE)
                        output_cmd, error_cmd = p.communicate()
                        log('Comando ROOT: %s' % str(command))
                    except:
                        log('Sin PERMISOS ROOT: %s' % str(command))

                    if not xbmcvfs.exists(new_libpath):
                        log('ROOT Copy Failed!')

                else:
                    command = ['chmod', '775', '%s' % new_libpath]
                    p = subprocess.Popen(command,
                                         stdout=subprocess.PIPE,
                                         stderr=subprocess.PIPE)
                    output_cmd, error_cmd = p.communicate()
                    log('Comando: %s' % str(command))
            else:
                log('Module exists.  Not copied... %s' % new_libpath)  ### ALFA

        return new_dest_path
예제 #7
0
파일: functions.py 프로젝트: xvacat/addon
 def update(self):
     if self.check_update():
         for libname in get_libname(self.platform):
             self.libpath = os.path.join(self.dest_path, libname)
             xbmcvfs.delete(self.libpath)
         self.download()
예제 #8
0
 def update(self):
     if self.check_update():
         for libname in get_libname(self.platform):
             self.libpath = os.path.join(self.dest_path, libname)
             filetools.remove(self.libpath)
         self.download()