|
|
@@ -1,6 +1,7 @@
|
|
|
import zipfile,os.path
|
|
|
import subprocess
|
|
|
|
|
|
+USE_UNRAR=True
|
|
|
|
|
|
def unar(source,dest_dir):
|
|
|
if source.lower().endswith("zip"):
|
|
|
@@ -32,13 +33,22 @@ def unzip(source_filename, dest_dir):
|
|
|
|
|
|
def unrar(source, dest_dir):
|
|
|
out=[]
|
|
|
- with subprocess.Popen(["lsar",source], stdout=subprocess.PIPE) as proc:
|
|
|
+ list_files=[]
|
|
|
+ extract_files=[]
|
|
|
+ if USE_UNRAR:
|
|
|
+ list_files=["unrar","lb",source]
|
|
|
+ extract_files=["unrar","x",source,dest_dir]
|
|
|
+ else:
|
|
|
+ list_files=["lsar",source]
|
|
|
+ extract_files=["unar","-f","-o",dest_dir,source]
|
|
|
+
|
|
|
+ with subprocess.Popen(list_files, stdout=subprocess.PIPE) as proc:
|
|
|
out=proc.stdout.read().decode('utf-8').split("\n")
|
|
|
if out[0].endswith(": RAR"):
|
|
|
del out[0] #header
|
|
|
if len(out[-1])==0:
|
|
|
del out[-1]
|
|
|
#print(out)
|
|
|
- subprocess.run(["unar","-f","-o",dest_dir,source],stdout=subprocess.DEVNULL)
|
|
|
+ subprocess.run(extract_files,stdout=subprocess.DEVNULL)
|
|
|
|
|
|
return [os.path.join(dest_dir,file) for file in out ]
|