peno64 / service.subtitles.localsubtitle

addon to add a local subtitle to a kodi movie
GNU General Public License v3.0
21 stars 4 forks source link

[Errno 2] No such file or directory - when using Dual Subtitles #17

Closed shad00m closed 5 months ago

shad00m commented 5 months ago

Hi I'm running Kodi 21 RC2 with your localsubtitle addon 1.12.2.

When selecting a single subtitle it works fine, but when I select two subtitles it shows a Kodi error Window with the message: [Errno 2] No such file or directory: 'https://[url]:443/FirstSubtitle.srt'

The log shows the following:

error <general>: EXCEPTION Thrown (PythonToCppException) : -->Python callback/script returned the following error<--
                                                    - NOTE: IGNORING THIS CAN LEAD TO MEMORY LEAKS!
                                                   Error Type: <class 'FileNotFoundError'>
                                                   Error Contents: [Errno 2] No such file or directory: 'https://[url]:443/subs/e01-kr.srt'
                                                   Traceback (most recent call last):
                                                     File "/storage/emulated/0/Android/data/net.kodinerds.maven.kodi21.firetv/files/.kodi/addons/service.subtitles.localsubtitle/service.py", line 200, in <module>
                                                       finalfile = mergesubs(subs)
                                                                   ^^^^^^^^^^^^^^^
                                                     File "/storage/emulated/0/Android/data/net.kodinerds.maven.kodi21.firetv/files/.kodi/addons/service.subtitles.localsubtitle/resources/lib/dualsubs.py", line 67, in mergesubs
                                                       raise e
                                                     File "/storage/emulated/0/Android/data/net.kodinerds.maven.kodi21.firetv/files/.kodi/addons/service.subtitles.localsubtitle/resources/lib/dualsubs.py", line 64, in mergesubs
                                                       result = pysubs2.load(sub, encoding=__charset_detect(sub, bottom))
                                                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                                                     File "/storage/emulated/0/Android/data/net.kodinerds.maven.kodi21.firetv/files/.kodi/addons/script.module.pysubs2/lib/pysubs2/ssafile.py", line 106, in load
                                                       with open(path, encoding=encoding) as fp:
                                                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                                                   FileNotFoundError: [Errno 2] No such file or directory: 'https://[url]:443/subs/e01-kr.srt'
                                                   -->End of Python script error report<--

error <general>: GetDirectory - Error getting plugin://service.subtitles.localsubtitle/?action=browsedual

I'm getting the same error with SMB shares.

peno64 commented 5 months ago

I tried it here also with kodi-21.0-Omega_rc2-x64 (Windows) and I have no problem. I tried to play a local video file (from my hard drive) with a subtitle from my hard drive. You will have to give more information. It is strange that the subtitle file is supposed to be located at https://[url]:443/ as if it is from the internet. Where do you choose a subtitle from?

shad00m commented 5 months ago

Hey there, thanks for the quick reply. Sorry, I forgot to mention I'm running Kodi on a FireTV Stick 4k Max. I have tested it via SMB share and via Web Directory (https). When I select "single subtitle" it works with the exact same share and exact same subtitle. I know Amazon recently changed something about the ADB permissions, but I'm not sure if it's related to this issue. As a test I installed Kodi 19.5 on the FireStick, but the error is the same.

On a sidenote The "Opensubtitles Dual Subtitles" Add-on works, but it cannot load local subtitles like this add-on.

Same error via SMB:

2024-03-24 14:02:50.595 T:7443    error <general>: EXCEPTION Thrown (PythonToCppException) : -->Python callback/script returned the following error<--
                                                    - NOTE: IGNORING THIS CAN LEAD TO MEMORY LEAKS!
                                                   Error Type: <class 'FileNotFoundError'>
                                                   Error Contents: [Errno 2] No such file or directory: 'smb://192.168.1.14/share/e01-en-forced.srt'
                                                   Traceback (most recent call last):
                                                     File "/storage/emulated/0/Android/data/net.kodinerds.maven.kodi21.firetv/files/.kodi/addons/service.subtitles.localsubtitle/service.py", line 200, in <module>
                                                       finalfile = mergesubs(subs)
                                                                   ^^^^^^^^^^^^^^^
                                                     File "/storage/emulated/0/Android/data/net.kodinerds.maven.kodi21.firetv/files/.kodi/addons/service.subtitles.localsubtitle/resources/lib/dualsubs.py", line 67, in mergesubs
                                                       raise e
                                                     File "/storage/emulated/0/Android/data/net.kodinerds.maven.kodi21.firetv/files/.kodi/addons/service.subtitles.localsubtitle/resources/lib/dualsubs.py", line 64, in mergesubs
                                                       result = pysubs2.load(sub, encoding=__charset_detect(sub, bottom))
                                                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                                                     File "/storage/emulated/0/Android/data/net.kodinerds.maven.kodi21.firetv/files/.kodi/addons/script.module.pysubs2/lib/pysubs2/ssafile.py", line 103, in load
                                                       with open(path, encoding=encoding) as fp:
                                                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                                                   FileNotFoundError: [Errno 2] No such file or directory: 'smb://192.168.1.14/share/e01-en-forced.srt'
                                                   -->End of Python script error report<--

2024-03-24 14:02:50.766 T:7254    error <general>: GetDirectory - Error getting plugin://service.subtitles.localsubtitle/?action=browsedual
peno64 commented 5 months ago

Single subtitle directly passes the chosen subtitle to kodi to display it. The duals subtitle code converts the two chosen subtitle files to a merged ssa subtitle file and then passes this to code. It's in this process that for some reason the subtitle file cannot be read. I have no idea why. I don't have a firestick so I can't try this. Can you copy that srt file to the firestick and open it from there to see what happens then? You should be able to do this with the file manager in kodi.

shad00m commented 5 months ago

You're right, I can load both subtitles successfully when I place them under /storage/emulated/0/Download/ Any external source that I've tried (SMB/SFTP/Web directory HTTPS) does not work.

peno64 commented 5 months ago

On my windows system I also tried with a subtitle from a samba share and I get following error:

Error Contents: [Errno 22] Invalid argument: 'smb://192.168.1.1/exthd1/...

That is a simular error as you have. The error originates from another place in the code and the error code is different but that could be related to the different operating systems.

peno64 commented 5 months ago

I think the problem is that python, which is used to code the addons, cannot access an smb (samba) share. And that is what the addon is doing in dual subtitle mode. Whe you choose signe subtitle then the subtitle is directly processed by kodi which is written in C++ and that can access an smb share.

peno64 commented 5 months ago

I also think I have a work-around for the problem. Python is not able to access the smb share (and most probably also not your original location of the subtitle file (https://[url]:443/subs/e01-kr.srt), kodi can and it is possible to call a kodi copy function to copy the file to the local OS in a temporary file and then let Python (the addon) use that file. I tried it with my smb example and it works.

peno64 commented 5 months ago

The addon is updated. Give it a try with both cases (SMB share and the one that gave https://[url]:443/FirstSubtitle.srt) and please let me know.

shad00m commented 5 months ago

Amazing! Smb, https and SFTP all work now with version 1.12.3. Thank you so much!

peno64 commented 5 months ago

Great