First, thanks for the reply,
The problem really is in some addons that they don't return all the information. The script is work well, really Kodi return 0 because the addon don't inform the correct total length, but in this case, if KodiQuery can return the Label information when Kodi return 0 the Script can obtain the length with the Label value.
Thanks for all.