Hello Community, my name is Aliet Expósito, and I am a programmer from Cuba.
As the title suggests, I am developing a simple add-on for LibreELEC/Kodi that allows instant search across your devices using plocate (https://plocate.sesse.net/) as the backend. It is currently in the early stages of development, and I would appreciate your feedback and answers to some questions.
plocate is an excellent project, faster than other locate implementations and with a smaller index. I am developing this add-on on a Raspberry Pi 4, running LibreELEC 12.0 and Kodi 21.0. plocate scans my 5TB disk full of multimedia, containing 17,502 files, in about 12 seconds on the first run:
LibreELEC:~ # time /storage/plinkr/plocate/obj-64bits-static/updatedb --database-root /var/media/easystore/ --output /storage/plinkr/plocate/plocate.db
real 0m 12.10s
user 0m 0.64s
sys 0m 0.23s
Subsequent runs are faster, taking less than 1 second, depending on file changes:
LibreELEC:~ # time /storage/plinkr/plocate/obj-64bits-static/updatedb --database-root /var/media/easystore/ --output /storage/plinkr/plocate/plocate.db
real 0m 0.77s
user 0m 0.54s
sys 0m 0.23s
The add-on uses a modified version of 95-udevil-mount.rules, copied to /storage/.config/udev.rules.d/95-udevil-mount.rules to run updatedb and create the index for the connected device. After the device is mounted by udevil, the script runs with /usr/bin/systemd-run --on-active=1, allowing it to execute in the background without affecting normal operation. The script (for BusyBox's sh) uses the UUID of the partitions to create an index for each scanned partition.
However, I face a challenge in appropriately copying the modified rules to /storage/.config/udev.rules.d/95-udevil-mount.rules post-installation and removing these rules upon add-on uninstallation. Similarly, making the shell script executable has posed difficulties. One workaround could be to check if the file exists each time the add-on is executed, but this does not resolve the issue of removal upon uninstallation.
The add-on returns search results in Kodi and allows you to open directories or play media files directly. Configuration options enable various plocate behaviors, such as case-insensitive searches, regular expressions, basename searches, and searching only currently connected devices or including disconnected ones. The results dialog also allows sorting by size in descending order, and color-codes directories differently from files.
Since plocate needs to be compiled, I am uncertain how to handle this requirement. Should the add-on be separated into two, with one containing plocate and the other serving as the Kodi search frontend?
I use this plugin frequently because I have a lot of multimedia content spread across multiple disks, and it is very useful for directly locating specific files. Being mostly offline, the global search requires internet access, which is often unavailable. I believe this add-on could be valuable to others and would like to share it with the community. I use LibreELEC a lot, and not only me, but my family as well, I am very grateful to this project.
I would greatly appreciate any recommendations or guidance on best practices for developing add-ons for LibreELEC or Kodi. Finding up-to-date documentation has been challenging.
The code is hosted at: https://github.com/plinkr/script.plocate.search and it's on a beta stage.
Thank you for your time and assistance.