Kodi Community Forum

Full Version: Hiding entries in Files view or only show removable USB
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I have Kodi running under Raspian on a Raspberry Pi, but I've seen threads relating this idea to Windows users as well so I figure I'd put it here.

I have USB automounting working. When I insert a USB drive, it gets mounted, and shows up under Video->Files, as expected. However, Video->Files also shows all of my OS-related mounts, which under my particular install is quite a few. This can lead to confusion, as there is a 1GB partition for /boot, so if someone inserts an unnamed 1GB flash disk, it can be hard to distinguish between them. Obviously, however, having those OS-level mounts is useful at times, especially when setting up.

One way to solve this would be to have some sort of ability of "hiding" entries in Video->Files. I'm not sure how easy this is.

Another option would be to have some "other" view for removable USB devices. I haven't found such a thing, but searching for "kodi usb" leads to a lot of "installing Kodi onto/from a USB" so it's not the easiest thing to search. Maybe one addon-option would be to add an extra main-menu option called "USB (%s)" where %s is replaced with the name of the USB device.

Does anyone know of a good solution for this? Failing anything decent, I might have a go at coding up the addon-option.
I've been thinking some more, and I have a few more ideas/thoughts.

Firstly I can make my OS mount USB flash drives under a certain path. Add that path as a source. This seems like the easiest for now. It works, but possibly not the nicest UI choice.

Making an addon change the home screen seems hard. It doesn't appear like the API supports anything like that. On a good note, I've worked out the DBus magic (in python) to get the mounted removable drives, and their mount paths:
Code:
import dbus

bus = dbus.SystemBus()
ud_manager_obj = bus.get_object("org.freedesktop.UDisks2", "/org/freedesktop/UDisks2")
ud_manager = dbus.Interface(ud_manager_obj, 'org.freedesktop.DBus.ObjectManager')
gmo = ud_manager.GetManagedObjects()
for k in gmo:
  mount_paths = []
  device = gmo[k]
  if "org.freedesktop.UDisks2.Block" not in device:
    continue
  drive_path = "".join(map(str,device["org.freedesktop.UDisks2.Block"]["Drive"]))
  if drive_path == "/":
    continue
  drive = bus.get_object("org.freedesktop.UDisks2", drive_path)
  drive_int = dbus.Interface(drive, 'org.freedesktop.DBus.Properties')
  is_removable = drive_int.Get("org.freedesktop.UDisks2.Drive", "Removable")
  if is_removable:
    device_int = dbus.Interface("org.freedesktop.DBus.Properties", device)
    fs = "org.freedesktop.UDisks2.Filesystem"
    if fs in device:
      res = device[fs]["MountPoints"]
      for arr in res:
        arr.pop(-1) # Remove \x00 from end
        point = "".join(map(str,arr))
        mount_paths.append(point)
      print "%s mount on %s"%(k, mount_paths)

I've read through the source to kodi itself. It does make mention of GetLocalDrives and GetRemovableDrives (at least in the win32 section). I couldn't find documentation on when or why these would be used though, so no idea on the relevance.

I think a nice addition would be to have a USB option for skins. Something akin to "Player.HasAudio" that can be used inside <visible> tags. Maybe Player.HasRemovableUSB. This could be complicated though, especially for other operating systems.