Bug XBMC.Extract
#24
OK, I think I've figured this out.  Just documenting my findings for anyone else that is stuck on this.

zip and rar files will (currently) not copy contents with the 'archive://' vfs url.  They will copy if you use the 'zip://' or the 'rar://' url

7z/bz2/gzip/xz/etc (all the formats that libarchive supports) will copy if you use the 'archive://' url

The contents of an rar/zip/7z etc will correctly be listed using xbmcvfs.listdir using 'archive://' regardless of the format.  The builtin xbmc.extract does not work with 'archive://', only 'zip://' and 'rar://'

@spiff
I'm not sure if this is the expected behavior?  I'd think extraction/copying would work on zip/rar files with libarchive since it also supports zip and rar.

Edit:  One thing I still cannot get to work is extracting / copying data a folder or file in a folder in a libarchive supported file.  xbmcvfs.copy will generate a file for a folder, but it's an invalid file.  Is there a valid method for extracting all files/folders within a libarchive supported file?


Test code:
python:

print('libarchive test')
import os
from urllib import quote_plus as url_quote
from kodi_six import xbmc, xbmcaddon, xbmcplugin, xbmcgui, xbmcvfs
directory_from = '/Users/xxx/Downloads/1941.zip'
directory_to = '/Users/xxx/Downloads/test/'
path = url_quote(directory_from)
print('Archive file test')
(dirs, files) = xbmcvfs.listdir('archive://%s' % (path))
print('Dirs and files')
print(dirs)
print(files)
src = os.path.join('archive://%s' % (path),files[0])
print(xbmcvfs.exists(src))
dest = os.path.join(directory_to,files[0])
print('Test copy from archive %s to %s' %(src, dest))
success = xbmcvfs.copy(src, dest)
print(success)
print('Copied file exists test from archive')
print(xbmcvfs.exists(dest))
print('Zip file test')
(dirs, files) = xbmcvfs.listdir('zip://%s' % (path))
print('Dirs and files')
print(dirs)
print(files)
src = os.path.join('zip://%s' % (path),files[0])
print(xbmcvfs.exists(src))
dest = os.path.join(directory_to,files[0])
print('Test copy from zip %s to %s' %(src, dest))
success = xbmcvfs.copy(src, dest)
print(success)
print('Copied file exists test from zip')
print(xbmcvfs.exists(dest))
print('Done.')
Returns:
xml:

13:42:32.338 T:123145461903360   DEBUG: libarchive test
13:42:32.419 T:123145461903360   DEBUG: Archive file test
13:42:32.428 T:123145461903360   DEBUG: Dirs and files
13:42:32.428 T:123145461903360   DEBUG:
13:42:32.429 T:123145461903360   DEBUG: ['41_09.rom', '41_18.rom', '41_19.rom', '41_32.rom', '41_gfx1.rom', '41_gfx3.rom', '41_gfx5.rom', '41_gfx7.rom', '41e_30.rom', '41e_31.rom', '41e_35.rom', '41e_36.rom']
13:42:32.429 T:123145461903360   DEBUG: 0
13:42:32.429 T:123145461903360   DEBUG: Test copy from archive archive://%2FUsers%2Fxxx%2FDownloads%2F1941.zip/41_09.rom to /Users/xxx/Downloads/test/41_09.rom
13:42:32.430 T:123145461903360   DEBUG: 0
13:42:32.430 T:123145461903360   DEBUG: Copied file exists test from archive
13:42:32.430 T:123145461903360   DEBUG: 0
13:42:32.430 T:123145461903360   DEBUG: Zip file test
13:42:32.432 T:123145461903360   DEBUG: Dirs and files
13:42:32.433 T:123145461903360   DEBUG:
13:42:32.433 T:123145461903360   DEBUG: ['41_09.rom', '41_18.rom', '41_19.rom', '41_32.rom', '41_gfx1.rom', '41_gfx3.rom', '41_gfx5.rom', '41_gfx7.rom', '41e_30.rom', '41e_31.rom', '41e_35.rom', '41e_36.rom']
13:42:32.433 T:123145461903360   DEBUG: 1
13:42:32.434 T:123145461903360   DEBUG: Test copy from zip zip://%2FUsers%2Fxxx%2FDownloads%2F1941.zip/41_09.rom to /Users/xxx/Downloads/test/41_09.rom
13:42:32.437 T:123145461903360   DEBUG: 1
13:42:32.438 T:123145461903360   DEBUG: Copied file exists test from zip
13:42:32.438 T:123145461903360   DEBUG: 1
13:42:32.438 T:123145461903360   DEBUG: Done.
Reply


Messages In This Thread
XBMC.Extract - by L0RE - 2017-10-30, 23:28
RE: XBMC.Extract - by spiff - 2017-10-31, 08:26
XBMC.Extract - by Martijn - 2017-10-31, 08:36
RE: XBMC.Extract - by L0RE - 2017-11-01, 22:52
RE: XBMC.Extract - by spiff - 2017-11-02, 00:42
RE: XBMC.Extract - by zachmorris - 2017-11-02, 03:16
RE: XBMC.Extract - by spiff - 2017-11-02, 14:19
RE: XBMC.Extract - by spiff - 2017-11-02, 19:20
RE: XBMC.Extract - by L0RE - 2017-11-02, 22:50
RE: XBMC.Extract - by henricos - 2017-12-21, 22:30
RE: XBMC.Extract - by spiff - 2017-11-23, 17:58
RE: XBMC.Extract - by spiff - 2017-12-21, 23:14
RE: XBMC.Extract - by henricos - 2017-12-22, 00:23
RE: XBMC.Extract - by spiff - 2017-12-22, 01:51
RE: XBMC.Extract - by henricos - 2017-12-22, 11:45
RE: XBMC.Extract - by fape88 - 2019-08-16, 08:50
RE: XBMC.Extract - by spiff - 2017-12-22, 23:02
RE: XBMC.Extract - by cramm - 2018-03-06, 04:19
RE: XBMC.Extract - by spiff - 2018-03-06, 09:43
RE: XBMC.Extract - by cramm - 2018-03-11, 15:41
RE: XBMC.Extract - by zachmorris - 2018-07-27, 01:22
RE: XBMC.Extract - by garbear - 2018-07-29, 22:12
RE: XBMC.Extract - by spiff - 2018-09-06, 10:56
RE: XBMC.Extract - by garbear - 2018-09-06, 22:40
RE: XBMC.Extract - by zachmorris - 2019-01-03, 23:57
RE: XBMC.Extract - by spiff - 2019-01-06, 08:16
RE: XBMC.Extract - by zachmorris - 2019-01-06, 08:27
RE: XBMC.Extract - by spiff - 2019-01-22, 16:08
RE: XBMC.Extract - by cyriltra - 2019-02-12, 15:59
RE: XBMC.Extract - by helviojr - 2019-02-16, 18:26
RE: XBMC.Extract - by cyriltra - 2019-02-17, 16:00
RE: XBMC.Extract - by zachmorris - 2019-02-21, 01:17
RE: XBMC.Extract - by henricos - 2019-05-12, 15:02
RE: XBMC.Extract - by henricos - 2019-05-15, 03:04
RE: XBMC.Extract - by zachmorris - 2019-05-15, 07:29
RE: XBMC.Extract - by HiGhLaNdeR - 2019-11-07, 03:07
RE: XBMC.Extract - by zachmorris - 2019-11-07, 03:13
RE: XBMC.Extract - by HiGhLaNdeR - 2019-11-07, 12:20
RE: XBMC.Extract - by zachmorris - 2019-11-10, 18:56
RE: XBMC.Extract - by HiGhLaNdeR - 2020-04-10, 11:17
RE: XBMC.Extract - by zachmorris - 2020-04-12, 20:41
RE: XBMC.Extract - by HiGhLaNdeR - 2020-04-13, 10:38
RE: XBMC.Extract - by matthuisman - 2019-07-10, 03:38
RE: XBMC.Extract - by zachmorris - 2019-07-10, 04:44
RE: XBMC.Extract - by malte - 2020-04-13, 13:06
RE: XBMC.Extract - by zachmorris - 2020-04-13, 23:43
RE: XBMC.Extract - by malte - 2020-04-14, 06:28
RE: XBMC.Extract - by bugatsinho - 2020-12-23, 16:09
Logout Mark Read Team Forum Stats Members Help
XBMC.Extract0