Editing video files media sources on command line

I am trying to set up my OSMC (Kodi 18) Raspberry Pi3 box to use video file access to my Ubuntu server where I store all of my videos. The top node of the video tree is shared via samba on the Ubuntu server as “media”. Below that I have a number of different types of sources which I want to list below the Videos/Files node on the display, but I do not want media disk details to be shown.

While trying to (very tediously) setting this up using the TV remote I am making mistakes and I find no way to remove a so erroneously entered video source…

But I can see via ssh to the RPi box that the definitions of the sources are stored inside a file $home/.kodi/sources.xml

So now I ask:
Can I edit the sources.xml file directly and thus define my sources in a 100 times shorter time and also remove/change erroneous entries?
It would make things so much simpler to set up if this was the case.

But I do not want to totally break OSMC if it turns out it is guarding the configuration xml file…

Simple answer yes, just recommend to stop mediacenter before editing configuration files.

Editing sources.xml works just fine, but as @fzinken mentioned, stop kodi (mediacenter) before editing. Otherwise the changes may be lost.

Another way you could do this if you have a USB keyboard available: Just plug the keyboard into the Pi and use that to enter the sources directly from Kodi.

My personal way of doing this is via SSH: Stop kodi, edit sources.xml, start kodi.

Thanks, I have an additional question:
Is it possible (in the sources.xml file) to block certain directories in an smb share from being displayed in the Kodi browsing window?
It turns out that css, php, tmp and similar dirs not containing any video files are still shown as possible subdirectories to navigate into…
(These directories are part of my webserver feed of these videos)
In essence can I hide certain directories?

I have added this into the sources.xml file:

<sources>
    <video>
        <source>
            <name>Ubuntusrv media SMB</name>
            <path pathversion="1">smb://ubuntusrv/MSNBC</path>
            <allowsharing>true</allowsharing>
        </source>
    </video>
</sources>

And it works fine using the “stop mediacenter - edit sources.xml - start mediacenter” sequence.
Now just remaining the hiding of certain dirs.
Btw I had to connect a USB keyboard in order to enter the user/password for the new source…

Kodi Wiki is your friend, took me 2 seconds of search

https://kodi.wiki/view/Advancedsettings.xml#excludefromlisting

1 Like

But if it is located in advancedsettings.xml it would not be effective in sources.xml, right?

My case is not any “library” it is just a plain file share with sub-directories…

And I am totally lost concerning regexp usage…

What I need is something like:
<excludefromlisting>css, php, tmp, secret</excludefromlisting>
in the sources.xml file so it can be configured on a share basis.

I tried putting this into the sources.xml file:

        <source>
            <name>Ubuntusrv media SMB</name>
            <path pathversion="1">smb://ubuntusrv/MSNBC</path>
            <allowsharing>true</allowsharing>
            <excludefromlisting>
              <regexp>[-\._ ](css|download|log|php|testing)[-\._ ]</regexp>
            </excludefromlisting>
        </source>

But it has no effect, the dirs are still shown.
I used the example in the link you provided but changed the names…

Now also tested adding this to the advancedsettings.xml file:

<!-- Try to stop video file listings from including unnecessary dirs  -->
<video>
  <excludefromlisting>
    <regexp>[-\._ ](css|download|log|php|testing)[-\._ ]
    </regexp>
  </excludefromlisting>
</video>

Restarted mediacenter as before but no change, the dirs are still present in the listings…

EDIT:
Since nothing like this worked I decided to hide the dirs already on the server share:
In /etc/samba/smb.conf under the definition of the video share:
veto files = /css/log/php/testing/
This did the trick, no more showing of these dirs.