Search code examples
pythonunzipzipxbmckodi

A simple Script to extracting a zip file


Good Evening all,

I think I'm not understanding the zipfile structure properly heres the code

import xbmc
import zipfile

targetzip = xbmc.translatePath('special://home/userdata/addon_data/plugin.program.tester/test.zip')
extractto = xbmc.translatePath('special://home/userdata/addon_data/plugin.program.tester/')

zip = ZipFile(targetzip)
zip.extractall(extractto)

Any Ideas why Its not working?


Solution

  • Try to do it this way

    import zipfile
    
    fh = open(targetzip, 'rb')
    z = zipfile.ZipFile(fh)
    for name in z.namelist():
        z.extract(name, extractto)
    fh.close()