0

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?

Simon Jeal
  • 153
  • 2
  • 4
  • 14

2 Answers2

0

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()
Aleksander Monk
  • 2,787
  • 2
  • 18
  • 31
0

Try this code:

with zipfile.ZipFile(targetzip) as zf:
    zf.extractall(extractto)
Delimitry
  • 2,987
  • 4
  • 30
  • 39