Can I modify how the Movie Database Scraper add on resolves movie names
#11
Thanks scudlee,

I've got it working now and for anyone who reads this thread in the future here is a bit of info...

What did I get working?
I got Kodi to recognise filenames with two different naming conventions. The standard Kodi convention:
xml:
moviename year.ext

.. and another style like this:
xml:
20150813 2159 - NBC +1 - Prometheus.ts

Here is what I did

I got a terminal window to kodi (libreELEC in my case) using Putty.

I created an advancedsettings.xml file:
xml:
# nano /storage/.kodi/userdata/advancedsettings.xml

Added this contents:

xml:
<advancedsettings version="1.0">
<video>
  <cleandatetime>(?|(?&lt;= - )([^-]*?)(?=\.ts)|(.*[^ _\,\.\(\)\[\]\-])[ _\.\(\)\[\]\-]+(19[0-9][0-9]|20[0-9][0-9])([ _\,\.\(\)\[\]\-]|[^0-9]$)?)</cleandatetime>
</video>
</advancedsettings>

When the regex goes in the xml file you have to replace the "<" in the positive look behind with "&lt;" or it breaks the closing </cleandatetime> tag.

Obviously this regex is specific to my use-case that will apply to almost no one else. But you could modify it and get some flexibility with how you can get Kodi to recognise your movie collection even if not all your filenames are Kodi compliant.

Basically the regex is an alternation of two regexes...
This one matches my non standard filenames:
xml:
(?&lt;= - )([^-]*?)(?=\.ts)

.. and this is the standard Kodi cleandatetime regex:
xml:
(.*[^ _\,\.\(\)\[\]\-])[ _\.\(\)\[\]\-]+(19[0-9][0-9]|20[0-9][0-9])([ _\,\.\(\)\[\]\-]|[^0-9]$)?

They are placed in a branch reset pattern (?|alternation) so the numbered grouping starts from 1,2.. regardless of which regex matches the filename.

For anyone interested here is the regex I used to see and play with.

These are the filenames of my test movies:
xml:
The Edge Of Seventeen 2016 720p.mp4
21 Grams 2003.mp4
The Martian 2015 720p x264.mp4
20140724 0128 - more_movies - Closer.ts
20150813 2159 - NBC +1 - Prometheus.ts
20150831 2159 - CBS+1 - The Bourne Identity.ts

They were all added to the Kodi library with metadata and artwork:
Image

After making changes to (or creating the) advancedsettings.xml file you have to restart kodi.
xml:
# reboot

But actually before I did that, since I am still just testing, I reset my current Kodi library...

# systemctl stop kodi
Go to "Userdata" folder in Windows LibreELEC Samba share
In /Userdata folder rename Thumbnails to Thumbnails.old
In /Userdata/Database folder likewise add a .old extension to the MyVideos.. and Textures.. .db files
# reboot

When libreELEC restarts…

Open a putty ssh command line terminal session to libreELEC
Check if the advancedsettings.xml file was correctly loaded by kodi on start-up
Image

You also need to now set up your source again and set its content to Movies.
Then "Do you want to refresh information for all items in this path" = Yes

As Scudlees response above explains the <cleandatetime> regular expression creates numbered capture groups. Group 1 must be the movie name. Group 2 doesn't have to exist but it will only be used if it is a year. These two pieces of info are used to construct the CreateSearchUrl. See the tmdb.xml file for more info. I found that this file is in two locations but apparently the one that matters is here:

xml:
/usr/share/kodi/addons/metadata.themoviedb.org/tmdb.xml

This is a useful thread giving further explanation of the <cleandatetime> regex, some of its potential limitations and proposing an improved version.

I think all this info should go in the Wiki because I think this forum gets a lot of questions from confused people hoping to customise the MovieDB scraper to work with different file naming conventions.

While I'm still typing! Some more feedback I have is I think it should be possible to create a different advancedsettings.xml file for each kodi source. This way people could save their thousands of movies with file names, that are not kodi compliant, to a different folder and make a regex just for them then use the Kodi standard regexs for properly named files that are stored in a folder set up as a different source. This would give flexibility to people who have large collections with a variety of file name standards and also make less hassle to people supporting Kodi.

Thanks again for your help scudlee,

Flex
Reply


Messages In This Thread
RE: Can I modify how the Movie Database Scraper add on resolves movie names - by flexmcmurphy - 2020-03-04, 03:54
Logout Mark Read Team Forum Stats Members Help
Can I modify how the Movie Database Scraper add on resolves movie names0