Kodi Community Forum

Full Version: Read video metadata (duration, codec, etc.) while scanning
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
When I add a new file to my video storage, I use the API to trigger a library scan and have it added to Kodi. Unfortunately, the file itself isn't read in order to figure out the duration, codec, etc., so the data in the video library is only partially filled in. Would it be possible to at least have an option in the VideoLibrary.Scan API call so that the files are parsed in order to add all the missing metadata information?
(2021-09-29, 20:45)alexiri Wrote: [ -> ]When I add a new file to my video storage, I use the API to trigger a library scan and have it added to Kodi. Unfortunately, the file itself isn't read in order to figure out the duration, codec, etc., so the data in the video library is only partially filled in. Would it be possible to at least have an option in the VideoLibrary.Scan API call so that the files are parsed in order to add all the missing metadata information?

Digging into this further, I realized that Movies apparently *do* get this information during scanning, but it's missing for TV Shows. I'm trying to dig through the code to see why this is, but it's a bit complicated and hard to follow, at least for someone not familiar with C++ and the Kodi code base.
(2021-10-03, 12:47)alexiri Wrote: [ -> ]but it's missing for TV Shows
Yes, because TV Shows do not have any A/V metadata. Its the episodes that have that data.
(2021-10-03, 20:52)Karellen Wrote: [ -> ]
(2021-10-03, 12:47)alexiri Wrote: [ -> ]but it's missing for TV Shows
Yes, because TV Shows do not have any A/V metadata. Its the episodes that have that data.
Yes, you're right, I misspoke. I meant episodes have no metadata when they're loaded.
(2021-10-03, 22:24)alexiri Wrote: [ -> ]
(2021-10-03, 20:52)Karellen Wrote: [ -> ]
(2021-10-03, 12:47)alexiri Wrote: [ -> ]but it's missing for TV Shows
Yes, because TV Shows do not have any A/V metadata. Its the episodes that have that data.
Yes, you're right, I misspoke. I meant episodes have no metadata when they're loaded.

Ok.
Metadata of episode video files are read exactly the same way as for movie files.
If you have nfo files, the <fileinfo></fileinfo> tag can prevent this scan, loading what is in the nfo file instead of polling the file.
(2021-10-03, 22:34)Karellen Wrote: [ -> ]Metadata of episode video files are read exactly the same way as for movie files.
If you have nfo files, the <fileinfo></fileinfo> tag can prevent this scan, loading what is in the nfo file instead of polling the file.

And if you don't have nfo files? If my reading of the Kodi code is correct, the scraper plugins are used to find the name of the episode, series info, etc. It doesn't look like the file is actually opened to examine the duration, codec, etc., is it? Any pointers to the bit of the code where this information is read would be helpful, I spent a while this afternoon trying to find it and I wasn't able to.
(2021-10-03, 22:40)alexiri Wrote: [ -> ]And if you don't have nfo files?
Then Kodi will read the video file for all the streams
(2021-10-03, 22:40)alexiri Wrote: [ -> ]f my reading of the Kodi code is correct, the scraper plugins are used to find the name of the episode, series info, etc
Yes. The Kodi scanner first searches through your file system to find the folders and files and grab the tv show name from the folder name and episodes from the filename. If no nfo files are present, then the scanner will call the Scraper to search for those titles.
(2021-10-03, 22:40)alexiri Wrote: [ -> ]t doesn't look like the file is actually opened to examine the duration, codec, etc., is it?
Yes. See my log. Line 2087... https://paste.kodi.tv/bimajavuhi.kodi
(2021-10-03, 22:40)alexiri Wrote: [ -> ]Any pointers to the bit of the code where this information is read would be helpful, I spent a while this afternoon trying to find it and I wasn't able to.
Sorry, I can't. Maybe someone else can.
(2021-10-03, 22:57)Karellen Wrote: [ -> ]
(2021-10-03, 22:40)alexiri Wrote: [ -> ]it doesn't look like the file is actually opened to examine the duration, codec, etc., is it?
Yes. See my log. Line 2087... https://paste.kodi.tv/bimajavuhi.kodi
That log shows that the file information wasn't read until a lot after scanning, while you were already moving around the interface. Notice that that file was scanned and added in line 1411 of your logs.

However, thanks a lot for taking the time to reply and post that log, you actually made me see something that led me to the answer I was looking for! This tiny change does exactly what I wanted: it reads the detailed stream information while loading a new video into the library so it's available for the user from the very first moment.
(2021-10-04, 20:51)alexiri Wrote: [ -> ]However, thanks a lot for taking the time to reply and post that log, you actually made me see something that led me to the answer I was looking for! This tiny change does exactly what I wanted: it reads the detailed stream information while loading a new video into the library so it's available for the user from the very first moment.

I've been looking for something like this, but I can't seem to find the file I need to insert your code into in Kodi 19.4 (for Windows).  Is there any assistance available? :-)
(2022-09-05, 19:33)flskydiver Wrote: [ -> ]I've been looking for something like this, but I can't seem to find the file I need to insert your code into in Kodi 19.4 (for Windows).  Is there any assistance available? :-)
It has been added to v20 and it was not backported to v19.
It is not something you can edit on your setup, it is built that way.
Install v20 if you need this feature. It is pretty stable, and Alpha 3 is being released by the end of the week. Maybe wait until then.
(2022-09-05, 22:40)Karellen Wrote: [ -> ]It has been added to v20 and it was not backported to v19.
So I can't just insert that code somewhere in Matrix and recompile?  Dang.  Okay, I'll take a look at 20.  Assuming I can get it to use the same library?
(2022-09-06, 00:09)flskydiver Wrote: [ -> ]Okay, I'll take a look at 20.  Assuming I can get it to use the same library?
Yes, it will upgrade your databases to v20.
If you are on Windows, maybe install a Portable version and test first.
(2022-09-06, 00:09)flskydiver Wrote: [ -> ]
(2022-09-05, 22:40)Karellen Wrote: [ -> ]It has been added to v20 and it was not backported to v19.
Okay, I'll take a look at 20.

Okay, so my library came across fine.  Problem is, since I already imported the files, I can't figure out how to get them scanned (for <fileinfo>).  Update Library doesn't work.  Neither does viewing the the files season by season as in 19.4.  Neither does manually refreshing.  Is my only out scraping everything again?  Is there no way to force a scan of my files?
(2022-09-06, 00:21)flskydiver Wrote: [ -> ]Problem is, since I already imported the files, I can't figure out how to get them scanned (for <fileinfo>). 
Need to rescan/rescrape.
Aw, crud.  So, I forgot that 19 made Kodi stop working with my NAS folders.  And I forgot how I fixed that.
Apparently 20 did the same thing ... and even reverting back to 19 hasn't helped the matter.  Kodi no longer recognizes my share links as valid.
So that might explain why 20 didn't work.  But now I have to figure out what I did to make 19 work again.  Sigh.


@Karellen:

Turns out I just need to open up the group policy editor (gpedit.exe) to the Computer Config/Admin Templates/Network/Lanman Workstation item (where the "Enable insecure guest logons" setting needs to be toggled to "Enabled") each time I re-install a new version of Kodi (19+), even though the setting is never reverted.  Beats the heck out of me why that works.  (I'm using Windows 10)

But I've now got 20.0 Apha2 humming along with @pkscout's fantastic update to the TMDb TV Shows scraper and I'm a happy boy now that everything is working like I believed it ought to.  Thank you!
Pages: 1 2