-
Notifications
You must be signed in to change notification settings - Fork 59
/
Copy pathextract.py
43 lines (36 loc) · 1.21 KB
/
extract.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import zipfile
from libs import kodi
def all(_in, _out, dp=None):
if dp:
return allWithProgress(_in, _out, dp)
return allNoProgress(_in, _out)
def allNoProgress(_in, _out):
import xbmcgui
# xbmcgui.Dialog().ok('no progress', _in, _out)
try:
zin = zipfile.ZipFile(_in, 'r')
zin.extractall(_out)
except Exception as e:
kodi.message("There was an error:", str(e), 'Please try again later, Attempting to continue...')
return False
return True
def allWithProgress(_in, _out, dp):
import xbmcgui
# xbmcgui.Dialog().ok('with progress', _in, _out)
try:
zin = zipfile.ZipFile(_in, 'r')
nFiles = float(len(zin.infolist()))
count = 0
except Exception as e:
kodi.message("There was an error:", str(e), 'Please try again later, Attempting to continue...')
return False
try:
for item in zin.infolist():
count += 1
update = count / nFiles * 100
dp.update(int(update))
zin.extract(item, _out)
except Exception as e:
kodi.message("There was an error:", str(e), 'Please try again later, Attempting to continue...')
return False
return True