Kodi Community Forum
xbmcvfs.translatePath not working in Android - Printable Version

+- Kodi Community Forum (https://forum.kodi.tv)
+-- Forum: Development (https://forum.kodi.tv/forumdisplay.php?fid=32)
+--- Forum: Add-ons (https://forum.kodi.tv/forumdisplay.php?fid=26)
+--- Thread: xbmcvfs.translatePath not working in Android (/showthread.php?tid=373717)

Pages: 1 2 3 4


xbmcvfs.translatePath not working in Android - lpence - 2023-07-08

Hello I am using the following code and it is actually working on Windows and mac OSx however it does not work on Android. It gives the followin error on Android 'squlite3.OperationalError: unable to open database file'.

What I am doing wrong do I need to use a different approach to get it working across all platforms?

DB_FILMS_FILE = "rtd_films.db"
DB_FILMS = xbmcvfs.translatePath("special://profile/addon_data/%s/%s" % (PLUGIN_NAME, DB_FILMS_FILE))

Thanks in advance


RE: xbmcvfs.translatePath not working in Android - zachmorris - 2023-07-13

Depending on which path are you trying to get:

Code:

addon_handle = xbmcaddon.Addon(id=MY_ADDON_NAME)
addon_path = xbmcvfs.translatePath(addon_handle.getAddonInfo('path'))
userdata_path = xbmcvfs.translatePath(addon_handle.getAddonInfo('profile'))



RE: xbmcvfs.translatePath not working in Android - Roman_V_M - 2023-07-13

Also I'd like to recommend to check what paths you are actually getting from Kodi API.


RE: xbmcvfs.translatePath not working in Android - lpence - 2023-07-13

ok with that code I am reading/writing to the db file in windows, linux and macosx in the following locations:

"/library/Application Support/Kodi/userdata/addon_data/plugin.video.rtd/rtd_films.db"

I would like to do the same in Android!
But in Android I get 'squlite3.OperationalError: unable to open database file'


RE: xbmcvfs.translatePath not working in Android - izprtxqkft - 2023-07-13

(2023-07-13, 19:29)lpence Wrote: ok with that code I am reading/writing to the db file in windows, linux and macosx in the following locations:

"/library/Application Support/Kodi/userdata/addon_data/plugin.video.rtd/films.db"

I would like to do the same in Android!
But in Android I get 'squlite3.OperationalError: unable to open database file'

special://userdata/addon_data/plugin.video.rtd/films.db should get you there - https://kodi.wiki/view/Special_protocol


RE: xbmcvfs.translatePath not working in Android - lpence - 2023-07-13

I am new trying to put some code together for kodi...
Is there a path solution to be used in all kodi platforms for all platforms or do I need to use a specific one when using it for Android ?
If thus is the case how do I arrange the code for 'if' to get these options?
I can see this in the wiki for Android:

special://xbmc - /data/data/org.xbmc.kodi/cache/apk/assets/
special://home - /sdcard/Android/data/org.xbmc.kodi/files/.kodi/
special://temp - /sdcard/Android/data/org.xbmc.kodi/files/.kodi/temp/


RE: xbmcvfs.translatePath not working in Android - Roman_V_M - 2023-07-13

As @zachmorris pointed, 
Code:
xbmcvfs.translatePath(addon_handle.getAddonInfo('profile'))
is the correct way of getting addon data dir. There shouldn't be any differences, be it Android or not. Of course, on different platforms absolute paths of different Kodi directories will differ.
I'd recommend you to debug your code step by step at least with debug logging to check what paths you are actually getting from Kodi. If Android returns wrong (non existing) paths, then it should be fixed.


RE: xbmcvfs.translatePath not working in Android - lpence - 2023-07-14

(2023-07-13, 21:51)Roman_V_M Wrote: As @zachmorris pointed, 
Code:
xbmcvfs.translatePath(addon_handle.getAddonInfo('profile'))
is the correct way of getting addon data dir. There shouldn't be any differences, be it Android or not. Of course, on different platforms absolute paths of different Kodi directories will differ.
I'd recommend you to debug your code step by step at least with debug logging to check what paths you are actually getting from Kodi. If Android returns wrong (non existing) paths, then it should be fixed.

Apologies to ask again but what am I suppose to do with 
Code:
xbmcvfs.translatePath(addon_handle.getAddonInfo('profile'))
? I do not understand.


RE: xbmcvfs.translatePath not working in Android - zachmorris - 2023-07-14

For your purposes, this should work.

Code:

MY_ADDON_NAME = 'plugin.video.rtd'
DB_FILMS_FILE = "films.db"
addon_handle = xbmcaddon.Addon(id=MY_ADDON_NAME)
print('My addons special path is: {}'.format(addon_handle.getAddonInfo('path')))
addon_path = xbmcvfs.translatePath(addon_handle.getAddonInfo('path'))
print('My addons translated addon path is: {}'.format(addon_path))
print('My addons special profile path is: {}'.format(addon_handle.getAddonInfo('profile')))
userdata_path = xbmcvfs.translatePath(addon_handle.getAddonInfo('profile'))
print('My addons translated profile path is: {}'.format(userdata_path))
if xbmcvfs.exists(os.path.join(userdata_path,DB_FILMS_FILE)):
print('My DB file was found')
else:
print('My DB file was not found')

What does that spit out in your addon debug log? The special paths you note should be the same (I think), but the above ensures it will be correct, regardless of the weird installs people may have.


RE: xbmcvfs.translatePath not working in Android - lpence - 2023-07-15

This is what I get: 
2023-07-15 08:19:44.790 T:756184 debug : My addon's special path is: /Users/pence/Library/Application Support/Kodi/addons/plugin.video.rtd/ 2023-07-15 08:19:44.790 T:756184 debug : My addon's translated addon path is: /Users/pence/Library/Application Support/Kodi/addons/plugin.video.rtd/ 2023-07-15 08:19:44.791 T:756184 debug : My addon's special profile path is: special://profile/addon_data/plugin.video.rtd/ 2023-07-15 08:19:44.791 T:756184 debug : My addon's translated profile path is: /Users/pence/Library/Application Support/Kodi/userdata/addon_data/plugin.video.rtd/ 2023-07-15 08:19:47.335 T:756287 debug : My addon's special path is: /Users/pence/Library/Application Support/Kodi/addons/plugin.video.rtd/ 2023-07-15 08:19:47.336 T:756287 debug : My addon's translated addon path is: /Users/pence/Library/Application Support/Kodi/addons/plugin.video.rtd/ 2023-07-15 08:19:47.337 T:756287 debug : My addon's special profile path is: special://profile/addon_data/plugin.video.rtd/ 2023-07-15 08:19:47.337 T:756287 debug : My addon's translated profile path is: /Users/pence/Library/Application Support/Kodi/userdata/addon_data/plugin.video.rtd/ 2023-07-15 08:19:44.792 T:756184 debug : My DB file was not found 2023-07-15 08:19:47.338 T:756287 debug : My DB file was not found:



RE: xbmcvfs.translatePath not working in Android - lpence - 2023-07-15

Updating my lat post here is what I got out from Mac OSx:

2023-07-15 08:19:44.790 T:756184   debug <general>: My addon's special path is: /Users/pence/Library/Application Support/Kodi/addons/plugin.video.rtd/
2023-07-15 08:19:44.790 T:756184   debug <general>: My addon's translated addon path is: /Users/pence/Library/Application Support/Kodi/addons/plugin.video.rtd/
2023-07-15 08:19:44.791 T:756184   debug <general>: My addon's special profile path is: special://profile/addon_data/plugin.video.rtd/
2023-07-15 08:19:44.791 T:756184   debug <general>: My addon's translated profile path is: /Users/pence/Library/Application Support/Kodi/userdata/addon_data/plugin.video.rtd/
2023-07-15 08:19:47.335 T:756287   debug <general>: My addon's special path is: /Users/pence/Library/Application Support/Kodi/addons/plugin.video.rtd/
2023-07-15 08:19:47.336 T:756287   debug <general>: My addon's translated addon path is: /Users/pence/Library/Application Support/Kodi/addons/plugin.video.rtd/
2023-07-15 08:19:47.337 T:756287   debug <general>: My addon's special profile path is: special://profile/addon_data/plugin.video.rtd/
2023-07-15 08:19:47.337 T:756287   debug <general>: My addon's translated profile path is: /Users/pence/Library/Application Support/Kodi/userdata/addon_data/plugin.video.rtd/

2023-07-15 08:38:31.608 T:767547   debug <general>: My DB file was found
2023-07-15 08:38:33.130 T:767579   debug <general>: My DB file was found

All seems to by correct but still not able to get it to work on Android...


RE: xbmcvfs.translatePath not working in Android - pkscout - 2023-07-16

(2023-07-15, 14:42)lpence Wrote: Updating my lat post here is what I got out from Mac OSx:

2023-07-15 08:19:44.790 T:756184   debug <general>: My addon's special path is: /Users/pence/Library/Application Support/Kodi/addons/plugin.video.rtd/
2023-07-15 08:19:44.790 T:756184   debug <general>: My addon's translated addon path is: /Users/pence/Library/Application Support/Kodi/addons/plugin.video.rtd/
2023-07-15 08:19:44.791 T:756184   debug <general>: My addon's special profile path is: special://profile/addon_data/plugin.video.rtd/
2023-07-15 08:19:44.791 T:756184   debug <general>: My addon's translated profile path is: /Users/pence/Library/Application Support/Kodi/userdata/addon_data/plugin.video.rtd/
2023-07-15 08:19:47.335 T:756287   debug <general>: My addon's special path is: /Users/pence/Library/Application Support/Kodi/addons/plugin.video.rtd/
2023-07-15 08:19:47.336 T:756287   debug <general>: My addon's translated addon path is: /Users/pence/Library/Application Support/Kodi/addons/plugin.video.rtd/
2023-07-15 08:19:47.337 T:756287   debug <general>: My addon's special profile path is: special://profile/addon_data/plugin.video.rtd/
2023-07-15 08:19:47.337 T:756287   debug <general>: My addon's translated profile path is: /Users/pence/Library/Application Support/Kodi/userdata/addon_data/plugin.video.rtd/

2023-07-15 08:38:31.608 T:767547   debug <general>: My DB file was found
2023-07-15 08:38:33.130 T:767579   debug <general>: My DB file was found

All seems to by correct but still not able to get it to work on Android...

You’re showing us the output from a Mac. Show us the Android output. It’s impossible to help with your Android issue if you don’t show us output from that.


RE: xbmcvfs.translatePath not working in Android - lpence - 2023-07-16

Just checking if what I am doing is correct:
1- I am using 'Log viewer for kodi
2- I added following lines to my advancedsettings.xml 

Code:
  <loglevel>6</loglevel>
  <debug>true</debug>
  <nativelogging>true</nativelogging>
  <logfile>/tmp/xbmc.log</logfile>

I do not see any prints on the log about the path! I am probably doing something wrong...
Is there any other app to check logger better that the one I am using? What else can I do? tks.


RE: xbmcvfs.translatePath not working in Android - izprtxqkft - 2023-07-16

check the easy method here Debug Log


RE: xbmcvfs.translatePath not working in Android - lpence - 2023-07-16

2023-07-16 08:55:53.740 T:31404   debug <general>: My addon's special path is: /storage/emulated/0/Android/data/org.xbmc.kodi/files/.kodi/addons/plugin.video.rtd/
2023-07-16 08:55:53.740 T:31404   debug <general>: My addon's translated addon path is: /storage/emulated/0/Android/data/org.xbmc.kodi/files/.kodi/addons/plugin.video.rtd/
2023-07-16 08:55:53.740 T:31404   debug <general>: My addon's special profile path is: special://profile/addon_data/plugin.video.rtd/
2023-07-16 08:55:53.740 T:31404   debug <general>: My addon's translated profile path is: /storage/emulated/0/Android/data/org.xbmc.kodi/files/.kodi/userdata/addon_data/plugin.video.rtd/

2023-07-16 08:55:53.741 T:31404   debug <general>: My DB file was not found