v18 How to extract subtitles from RAR archive in Kodi 18 ?
#1
Hello,

From what i've understood from various threads, it seems xbmc.extract does not work anymore for .rar in Kodi 18. Instead, we have to use external libraries (my addon -> Virtual Filesystems) vfs.rar (with rar://) or vfs.libarchive (archive://)
 
  • When I enable vfs.libarchive (and disable vfs.rar) and use below code:
python:

__temp__ = '/storage/.kodi/userdata/addon_data/service.subtitles.zimuku/temp'
tempfile = '/storage/.kodi/userdata/addon_data/service.subtitles.zimuku/temp/subtitles.rar'
path = urllib.quote_plus(tempfile)
(dirs, files) = xbmcvfs.listdir('archive://%s' % (path))
for file in files:
  src = 'archive://' + path + '/' + file
  dest = os.path.join(__temp__, file)
xbmcvfs.copy(src, dest)
i got the following error:
ERROR: GetDirectory - Error getting archive://%2fstorage%2f.kodi%2fuserdata%2faddon_data%2fservice.subtitles.zimuku%2ftemp%2fsubtitles.rar/
But the rar file exists and the path is correct !

 
  • Now, when I enable vfs.rar (and disable vfs.libarchive) and use below code:
python:

__temp__ = '/storage/.kodi/userdata/addon_data/service.subtitles.zimuku/temp'
tempfile = '/storage/.kodi/userdata/addon_data/service.subtitles.zimuku/temp/subtitles.rar'
path = urllib.quote_plus(tempfile)
(dirs, files) = xbmcvfs.listdir('rar://%s' % (path))
for file in files:
  src = 'rar://' + path + '/' + file
  dest = os.path.join(__temp__, file)
xbmcvfs.copy(src, dest)

the script finds the .rar and xbmcvfs.listdir finds the subtitle inside it, but xbmcvfs.copy does not "extract" the subtitle file. Instead i got below error:
ERROR: AddOnLog: RAR archive support: filerar::open failed to open file in cache: special://temp/rarfolderWKscUK/subtitle_file.ass

When I look in the folder mentioned: "/storage/.kodi/temp/rarfolderWKscUK/", it is actually empty.
One more thing I do not understand is why it is using a temp folder, while I specified a "dest" folder ?!?

So basically non of vfs.rar or vfs.libarchive seem to work so far for me in Kodi 18 :/

is anyone else having issues to extract subtitles from a RAR archive with Kodi 18 ?
(i'm using CoreElec 8.99.2)

Thank you
Reply
#2
After a reboot, I noticed the combination of vfs.rar enable + rar:// was actually working: I was able to extract a rar file and access subtitles.
However, when I wanted to watch another movie with subtitles, the rar:// was extracting the file but provides the previous subtitles, not the one from the archive !!
Even if I manually delete the temp folder, xbmcvfs.copy will still provide the previous subtitles files...
If I reboot, then it works for 1 movie, then it stops working.

I think this is related to some cache issue / bug, not sure if it's in Kodi 18, CoreElec or vfs.rar or my machine.....

I will try to investigate caching mechanism of Kodi
Reply
#3
I tried Kodi with my addon on Mac and have the exact same issue so far.
Reply
#4
Mod edit: English only, please - machine translation below. It triggers our spam filters otherwise, and we don't want to accidentally ban you Big Grin

Because you build zimuku, guess you will speak Chinese
Python does not have a built-in module to extract rar, so you need external tools to assist in decompression, 7z is also such a problem.

----

因为你建立zimuku,猜你会中文
python没有内置模块可以解压rar吧,所以需要外部工具来辅助解压,7z的也是这样的问题。
Reply
#5
(2019-04-29, 09:57)xdsnet Wrote: 因为

You already posted on this forum before, in English.
If you start spamming in an oriental language, your stay here will be shortened very quickly.
Reply
#6
@cyriltra
I, and all people that use this add-on, are having this same issue with Legendas.TV add-on (https://kodi.wiki/view/Add-on:Legendas.TV https://github.com/gfjardim/service.subt...legendastv).
Sometimes the add-on work, sometimes don't. Please, if you solve this problem share!
Supercalifragilisticexpialidocious! (inscribed in large friendly letters)
My hardware is a Raspberry Pi 3b (with LibreELEC)
Reply
#7
(2019-05-04, 00:24)edjalmo Wrote: @cyriltra
I, and all people that use this add-on, are having this same issue with Legendas.TV add-on (https://kodi.wiki/view/Add-on:Legendas.TV https://github.com/gfjardim/service.subt...legendastv).
Sometimes the add-on work, sometimes don't. Please, if you solve this problem share!
Hi,

yes I solved that issue by creating my own subtitles service scrapper and the trick, as suggested by xdsnet is to use an external program.
So I've installed the following addons:
- System Tools (it will install unrar)
- Locale (it changes the charset of kodi from POSIX to utf8 if i'm correct)

then in my personal addon, i'm using these 3 lines to extract RAR archives:

python:
import subprocess
cmd = "unrar e {0} {1}/".format(filepath, dirpath) # filepath = /path/to/your/archive.rar and dirpath = /path/to/where/you/want/to/extract/
subprocess.call(cmd, shell=True)
This may not work on all platform (i'm on CoreElec)

for zip files, i'm using below command:
python:
xbmc.executebuiltin(('XBMC.Extract("{0}","{1}")'.format(filepath, dirpath,)), True) # filepath = /path/to/your/archive.zip and dirpath = /path/to/where/you/want/to/extract/


I hope kodi 19 with full support of utf8 (python 3) will no longer require such workaround
Reply
#8
@cyriltra thank you for this!
I don't understand python. I asked to share with the dev of legendastv add-on.
But now another guy are fixing the add-on. Now it's working on Kodi 18.2, Windows version.
If you want take a look, this is the link: https://github.com/henricos/service.subt...legendastv
Supercalifragilisticexpialidocious! (inscribed in large friendly letters)
My hardware is a Raspberry Pi 3b (with LibreELEC)
Reply

Logout Mark Read Team Forum Stats Members Help
How to extract subtitles from RAR archive in Kodi 18 ?0