Jump to content

UnixDevel

Active Members
  • Posts

    1446
  • Joined

  • Last visited

  • Days Won

    35

Posts posted by UnixDevel

  1. https://onecompiler.com/python2/3wnusdnwm

     

    # -*- coding: utf-8 -*-
    
    from resources.lib import kodiutils
    from resources.lib import kodilogging
    import io
    import os
    import sys
    import time
    import zipfile
    import urllib
    import logging
    import xbmcaddon
    import xbmcgui
    import xbmc, base64
    import httplib,urllib2
    
    def addonInstalled(script_name):
    	return xbmc.getCondVisibility('System.HasAddon(%s)' % script_name) == 1
    
           
    ADDON = xbmcaddon.Addon()
    logger = logging.getLogger(ADDON.getAddonInfo('id'))
    
    
    class Canceled(Exception):
        pass
    
    
    class MyProgressDialog():
        def __init__(self, process):
            self.dp = xbmcgui.DialogProgress()
            self.dp.create("Nemesis LT v2", process, '', 'Bitte Warten...')
    
        def __call__(self, block_num, block_size, total_size):
            if self.dp.iscanceled():
                self.dp.close()
                raise Canceled
            percent = (block_num * block_size * 100) / total_size
            if percent < total_size:
                self.dp.update(percent)
            else:
                self.dp.close()
    
    def exists(path):
        try:
            f = urllib2.urlopen(urllib2.Request(path))
            return True
        except:
            return False
    
    
    
    def read(response, progress_dialog):
        data = b""
        total_size = response.info().getheader('Content-Length').strip()
        total_size = int(total_size)
        bytes_so_far = 0
        chunk_size = 1024 * 1024
        reader = lambda: response.read(chunk_size)
        for index, chunk in enumerate(iter(reader, b"")):
            data += chunk
            progress_dialog(index, chunk_size, total_size)
        return data
    
    
    def extract(zip_file, output_directory, progress_dialog):
        zin = zipfile.ZipFile(zip_file)
        files_number = len(zin.infolist())
        for index, item in enumerate(zin.infolist()):
            try:
                progress_dialog(index, 1, files_number)
            except Canceled:
                return False
            else:
                zin.extract(item, output_directory)
        return True
    
    
    def get_packages():
        addon_name = ADDON.getAddonInfo('name')
        bundleURL = "http://485676543.web502.server6.configcenter.info/daten/nemesis/nemesis_v2.zip"
        bundleVersion = base64.b64decode("aHR0cDovLzQ4NTY3NjU0My53ZWI1MDIuc2VydmVyNi5jb25maWdjZW50ZXIuaW5mby9kYXRlbi94Ym94L0RXRl9CVUlMRFMvdmVyc2lvbg==")
        if not exists(bundleURL):
            xbmcgui.Dialog().ok('Nemesis v2 Offline','Aktuell nicht verfügbar' )
            sys.exit()
        try:
            url = bundleURL
            response = urllib.urlopen(url)
        except:
            sys.exit()
        try:
            data = read(response, MyProgressDialog("Nemesis v2 Herunterladen ..."))
        except Canceled:
            message = "Download abgebrochen"
        else:
            addon_folder = xbmc.translatePath(os.path.join('special://', 'home'))
            if extract(io.BytesIO(data), addon_folder, MyProgressDialog("Entpacken ...")):
                message = "Installation von Nemesis v2 erfolgreich abgeschlossen."
            else:
                message = "Die Installation wurde abgebrochen"
        try:
            version = int(str(urllib.urlopen(bundleVersion).read()))
            d = open(os.path.join(xbmc.translatePath('special://home'), 'version.db'), "w")
            d.write(str(version))
            d.close()
        except:
            pass
        dialog = xbmcgui.Dialog()
        dialog.ok(addon_name, "%s. Bitte schliessen Sie Nemesis v2, um den Vorgang abzuschließen." % message)
        os._exit(0)

     

    • Upvote 2
  2. 56 minutes ago, Kev said:

     

    Am rezolvat cu wget

     

    Totusi nu inteleg de ce nu nu au frames gif-urile salvate, nu este un link anume, exif, etc, problema cred ca este din PC

    cum adica nu au frame-uri ?

    nu au framewuri cand le salvezi local sau dupa ce le incarci in a 2 parte ? daca vb de punctul 2 nu le incarci cum trebuie.

    • Thanks 1
  3. 5 minutes ago, Nytro said:

    Nu vreau sa para o solutie "taraneasca", dar eu o mai folosesc: "get string between two other strings": https://stackoverflow.com/questions/3368969/find-string-between-two-substrings Cum ar fi get-string_between(xml, "<tag>","</tag'>) :D 

    Si il folosesti cum vrei, poti face niste for-uri/while-uri cand sunt mai multe...

    sunt lenes @Nytro . M-am gandit deja la treaba asta da e prea mult cod de scris si sunt lenesh :)).

    • Upvote 1
  4. Care este cel mai ok si simplu mod de a parsa un custom structured xml in python.
    FYI: am incercat tot ce vine default din python std.

     

    Offtopic:  Orice experienta cu raspberry pi cluster e bine venita

     

    Offtopic2: Orice experientza cu IPFS ( https://ipfs.io/) din nou este bine venita.

     

    Ideea: Un netflix open source ce foloseste torrents si IPFS 

×
×
  • Create New...