SageTV Community  

Go Back   SageTV Community > SageTV Development and Customizations > SageTV Studio
Forum Rules FAQs Community Downloads Today's Posts Search

Notices

SageTV Studio Discussion related to the SageTV Studio application produced by SageTV. Questions, issues, problems, suggestions, etc. relating to the Studio software application should be posted here.

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 10-19-2010, 08:28 AM
PLUCKYHD PLUCKYHD is offline
SageTVaholic
 
Join Date: Dec 2007
Posts: 6,257
Questions about metadata and the pecking order...

Okay I have some questions about metadata and the SageDB objects since I have never written to them much before.

I am more concerned with the pecking order which things get written.

Lets say a new file is found during the scan that contains a .properties file. I am going to assume that properties file info gets written first to the database. Then the even listener for mediafile added gets fired. That is where my worry comes in and maybe I shouldn't be worried, but if a user has BMT and say my program installed it seems to be it is going to be last one called that gets the info written. As if BMT is called first and then my listener files then my info is going to overwrite BMT's info. Is that correct? What stops both from trying to write at the same time and causing errors?

Maybe I am over worrying thinking this but I just now users are going to install both even if I tell them not to and then someone is going to complain I or BMT is breaking their metadata and wanting to make sure I understand the process correctly before I decide to change my ways and go this route.

cheers
Reply With Quote
  #2  
Old 10-19-2010, 09:06 AM
stuckless's Avatar
stuckless stuckless is offline
SageTVaholic
 
Join Date: Oct 2007
Location: London, Ontario, Canada
Posts: 9,713
Quote:
Originally Posted by PLUCKYHD View Post
Okay I have some questions about metadata and the SageDB objects since I have never written to them much before.

I am more concerned with the pecking order which things get written.

Lets say a new file is found during the scan that contains a .properties file. I am going to assume that properties file info gets written first to the database. Then the even listener for mediafile added gets fired. That is where my worry comes in and maybe I shouldn't be worried, but if a user has BMT and say my program installed it seems to be it is going to be last one called that gets the info written. As if BMT is called first and then my listener files then my info is going to overwrite BMT's info. Is that correct? What stops both from trying to write at the same time and causing errors?

Maybe I am over worrying thinking this but I just now users are going to install both even if I tell them not to and then someone is going to complain I or BMT is breaking their metadata and wanting to make sure I understand the process correctly before I decide to change my ways and go this route.

cheers
I've been meaning to start this discussion for some time now, so the timing is good. With BMT/Phoenix, Ortus, and MyMovies all contributing metadata and fanart, I think we need to cordially come up with some nice ways of working together.

Currently BMT is written to NEVER update metadata, automatically, if the the mediafile already has an existing MediaTitle field, or in the case of TV if it already has a SeaonNumber or EpisodeNumber. I made this change to BMT some time ago, in preparation for the fact the Ortus and MM was on the horizon. I didn't want BMT overwriting metadata if people were getting it from another location. You can also turn off the automatic lookups as well, so that you can still have the bmt web ui, but it will never automatically update metadata.

There are some drawbacks to this approach...

First, it assumes that all metadata providers use the same custom fields. Initially for phoenix fanart, we had an open discussion around which fields we think we should all agree upon, but perhaps we need to be a little more transparent and create "known" set of custom fields.

Second, bmt only checks a couple of fields to see if it should fetch metadata automatically. So if Ortus or MyMovies populates the metadata, but doesn't actually download the fanart, for some reason, then BMT will never actually download any fanart either.

Third, I can't be sure that MyMovies or Ortus doesn't overwrite BMT metadata automatically. And there is no way to debug if another plugin updates the metadata. While BMT writes a log entry to the phoenix-metadata.log stating that it updated the metadata, but there's no indication that onother plugin may have updated it as well.

Moving forward, since there are going to be several players, I think it would be wise to come up with a "standard" way of allowing the users to choose which metadata/fanart providers to use... or to NEVER enable automatic lookups by default, and only enable them if the user goes into a plugin and enables it, etc, etc, etc.
Reply With Quote
  #3  
Old 10-19-2010, 09:30 AM
PLUCKYHD PLUCKYHD is offline
SageTVaholic
 
Join Date: Dec 2007
Posts: 6,257
Glad I am not the only one worried about this and it was initially and currently SMM doesn't write to the Database (outside of if it is creating property files). I didn't want to overwrite or mess with BMT.

I like your method but see issues with it as well as if BMT gets called first it won't find metadata so it will do it's lookup and then if MyMovies is checking the same thing it won't do anything.

and of course there is the issue of fields that are written to and respected by all developers. I know some/most of the BMT fields it writes to and of course i would need several additional ones that I create.

I have one suggestions in thinking out loud. What if I or someone else creates a simple STVi (if even necessary). The allows editing of a 2 properties such as

DefaultMetadataFetcherForMovies=
DefaultMetadataFetcherForTV=

and me and you and hopefully everyone else agree to check that property for our name. If our name exist we do our thing if it doesn't our automatic writers to the db are disabled. Of course any new players in the game and Ortus would have to respect the same two server properties when implementing their plugins and listeners.

It would be fairly easy to keep the stvi (if necessary) updated with the choices currently available as long as every dev gave me the name/ value they needed in the property to have it as an option.

My thought is this would give all users regardless of their metadata installations a choice to switch back and fourth between the fetchers they have at will/demand. Without interaction of each individual plugin except for us checking the current state of the above mentioned properties. It would also allow for control seperately of TV and movie scrapers (I still wish Sagetv would add a TV import type so us scrapers could easily determine what is what on imported movies and tv without having to guess).

thoughts?
Reply With Quote
  #4  
Old 10-24-2010, 02:51 PM
Tiki's Avatar
Tiki Tiki is offline
Sage Icon
 
Join Date: Feb 2005
Location: Southwest Florida, USA
Posts: 2,009
Why not devise a custom metadata field that indicates what plugin updated the data last? Then any metadata plugins could check this field and know not to automatically overwrite data for an object whose metadata had been set by some other plugin.
__________________
Server: Ryzen 2400G with integrated graphics, ASRock X470 Taichi Motherboard, HDMI output to Vizio 1080p LCD, Win10-64Bit (Professional), 16GB RAM
Capture Devices (7 tuners): Colossus (x1), HDHR Prime (x2)
,USBUIRT (multi-zone)
Source:
Comcast/Xfinity X1 Cable
Primary Client: Server Other Clients: (1) HD200, (1) HD300
Retired Equipment: MediaMVP, PVR150 (x2), PVR150MCE,
HDHR, HVR-2250, HD-PVR
Reply With Quote
  #5  
Old 10-24-2010, 03:17 PM
PLUCKYHD PLUCKYHD is offline
SageTVaholic
 
Join Date: Dec 2007
Posts: 6,257
Quote:
Originally Posted by Tiki View Post
Why not devise a custom metadata field that indicates what plugin updated the data last? Then any metadata plugins could check this field and know not to automatically overwrite data for an object whose metadata had been set by some other plugin.
That wouldn't work when people want to change providers very well.
Reply With Quote
  #6  
Old 10-25-2010, 04:42 AM
Fuzzy's Avatar
Fuzzy Fuzzy is offline
SageTVaholic
 
Join Date: Sep 2005
Location: Jurupa Valley, CA
Posts: 9,957
Quote:
Originally Posted by PLUCKYHD View Post
That wouldn't work when people want to change providers very well.
What complications do you see in this method (not that I'm saying it WOULD work - I'm just not seeing the problem). If a mediafile is added, and say, a the time, BMT is the preferred source. The 'MetadataSource' property - originally null - is set with something like "BMT:TVDB:71398". No other 'friendly' plugins would modify metadata once that is populated - unless specifically asked to do so, via a manual update. Simply changing a preferred provider shouldn't trigger a re-hash of all existing data. (I'd also like to point out that having this somewhat easily readable 'MetadataSource' property might be useful for the user in general to figure out where the data is coming from).
__________________
Buy Fuzzy a beer! (Fuzzy likes beer)

unRAID Server: i7-6700, 32GB RAM, Dual 128GB SSD cache and 13TB pool, with SageTVv9, openDCT, Logitech Media Server and Plex Media Server each in Dockers.
Sources: HRHR Prime with Charter CableCard. HDHR-US for OTA.
Primary Client: HD-300 through XBoxOne in Living Room, Samsung HLT-6189S
Other Clients: Mi Box in Master Bedroom, HD-200 in kids room
Reply With Quote
  #7  
Old 10-25-2010, 04:52 AM
PLUCKYHD PLUCKYHD is offline
SageTVaholic
 
Join Date: Dec 2007
Posts: 6,257
Yeah I guess that does make since but then still requires a property somewhere that providers check to make sure they are default. As if they aren't doing that and a user thinks they are default and it isn't writing because that property on the mediafile already exist....in otherwords if I was set as default provider but another provider wasn't checking the default property and wrote before mine and my check against the file reveals metadata already written by another provider so I don't write anything the user will wonder why.
Reply With Quote
  #8  
Old 10-25-2010, 05:06 AM
Fuzzy's Avatar
Fuzzy Fuzzy is offline
SageTVaholic
 
Join Date: Sep 2005
Location: Jurupa Valley, CA
Posts: 9,957
Perhaps, instead of making a simple STVi that would be used for setting a property that all plugins would have to check - what if instead a 'metadata clearing house' general plugin was developed that would handle the arbitration. Of course, the plugins would still then have to utilize that - but it would probably provide a bit more control over how the plugins are called (could not only offer a 'preferred' option - but perhaps a preferred order).

So the ClearingHouse is what actually responds to the MediaFileImported event - then fires off whatever specific metadata gathering doodads are in it's list. The individual behavior of those doodads should be defined - but I'd say by default, it shouldn't overwrite any already populated metadata field. this would allow a higher priority doodad to fill in what it can - but more specific information could be added by lower priority plugins. (MyMovies might be used first - and would get a majority of information - but then BMT could also be used, which could populate the things MyMovies might miss, fanart, etc.).
__________________
Buy Fuzzy a beer! (Fuzzy likes beer)

unRAID Server: i7-6700, 32GB RAM, Dual 128GB SSD cache and 13TB pool, with SageTVv9, openDCT, Logitech Media Server and Plex Media Server each in Dockers.
Sources: HRHR Prime with Charter CableCard. HDHR-US for OTA.
Primary Client: HD-300 through XBoxOne in Living Room, Samsung HLT-6189S
Other Clients: Mi Box in Master Bedroom, HD-200 in kids room
Reply With Quote
  #9  
Old 10-25-2010, 06:13 AM
PLUCKYHD PLUCKYHD is offline
SageTVaholic
 
Join Date: Dec 2007
Posts: 6,257
Quote:
Originally Posted by Fuzzy View Post
Perhaps, instead of making a simple STVi that would be used for setting a property that all plugins would have to check - what if instead a 'metadata clearing house' general plugin was developed that would handle the arbitration. Of course, the plugins would still then have to utilize that - but it would probably provide a bit more control over how the plugins are called (could not only offer a 'preferred' option - but perhaps a preferred order).

So the ClearingHouse is what actually responds to the MediaFileImported event - then fires off whatever specific metadata gathering doodads are in it's list. The individual behavior of those doodads should be defined - but I'd say by default, it shouldn't overwrite any already populated metadata field. this would allow a higher priority doodad to fill in what it can - but more specific information could be added by lower priority plugins. (MyMovies might be used first - and would get a majority of information - but then BMT could also be used, which could populate the things MyMovies might miss, fanart, etc.).
hmm I think that might work although multiple providers (ie one filling in where another misses out) is a bit much for what I was thinking. I can see having different scrapers for tv vs movies but in all honesty I can't see having multiple scrapers installed and expecting one to fill in where the other leaves off. That is a nice idea but would be very complicated on the "clearing house" plugin to decipher all of that and rely on the providers to cohere to allot more code. Personally I think that is overkill being that we are all doing this for hobby or whatever reason you want to give it. I think I simply property check/stvi is more than sufficient and even then you might have a provider that doesn't adhere to even that as there is nothing forcing them to.
Reply With Quote
  #10  
Old 10-25-2010, 06:56 AM
stuckless's Avatar
stuckless stuckless is offline
SageTVaholic
 
Join Date: Oct 2007
Location: London, Ontario, Canada
Posts: 9,713
Personally... I think that Tiki's and Fuzzy's idea (which are the same), of creating a custom metadata field on the mediaitem, is the simplest approach. Even if we were to create a "clearing house" type of app, then there is still no guarantee that another plugin will adhere to the rules.

In terms of what is stored, I'd prefer to go with Tiki's approach, and only store the plugin id of what updated the metadata, instead of Fuzzy's approach of also adding in the provider id and provider's data id, mainly because I already store those against the media item as well in 2 different fields (MetadataProviderID, MetadataProviderDataId).

In terms of the process flow, bmt's automatic scraper would simply check the MetadataSource field, and if it is null, or has bmt, then it will automatically update the mediafile.

BUT, from the web ui, if you fired off a scan or manual update, then I would NOT check that field, since there is real user driving the application.

I could also easily show the MetadataSource in the details for a media item.

Of course, during an automatic update, there is no way that bmt will handle the media item first, or last. But if a user ONLY wants to have SMM to handle the metadata automatically, then they can already turn off the automatic scraping in bmt, but still use the web ui, if they want to do manual updates.

We don't have that many plugins updating metadata automatically, so I don't really see this as being that huge of an issue. And, if other plugins come along and start duplicating the features of bmt in that they also pull metadata form tvdb, imdb, tmdb, dvdprofiler, etc, etc, then maybe I'll change bmt to use those... it'll be less work for me.
Reply With Quote
  #11  
Old 10-25-2010, 10:54 AM
PLUCKYHD PLUCKYHD is offline
SageTVaholic
 
Join Date: Dec 2007
Posts: 6,257
My only fear on that route is the users themselves (yes not allot of faith sometimes) not disabling one plugin scraping when enabling another plugin. I mean wouldn't you want to fallback to writing if your plugin was enabled to even if another plugin had already written it?

Either way I am open and a bit of from actually writing to the db and still not 100% convinced I am going to do it (hit some caveats with it in testing), but still to good to have a plan of action.
Reply With Quote
  #12  
Old 10-25-2010, 11:27 AM
stuckless's Avatar
stuckless stuckless is offline
SageTVaholic
 
Join Date: Oct 2007
Location: London, Ontario, Canada
Posts: 9,713
Quote:
Originally Posted by PLUCKYHD View Post
I mean wouldn't you want to fallback to writing if your plugin was enabled to even if another plugin had already written it?
No. Actually I go out of my way to find excuses to NOT update the metadata on an automatic scan. ie, if detect that there is an existing .properties, i do nothing. If I detect that the the mediafile already has a MediaTitle, then I skip it. Bottom line, I don't want BMT fetching metadata, automatically, for stuff that could already be updated. The "MediaTitle" field, today, acts the the proposed "MediaSource" fields, in that if there's a value in that field, then I skip the file.

Just because I work this way, I don't expect that your plugin should do the same. if people complain that BMT is not getting the right metadata, and they have other scrapers installed, then I'll probably have people uninstall the other plugins before submitting bugs.

I think a "good faith" solution is the best we can hope for in terms of fetching metadata. I'm not against Fuzzy's broker solution, but BMT is already a broker. ie, you can have different plugins, you can order the plugins, you can have different plugins for tv, movies, and music, etc, etc. I don't see the point in implementing another broker (from my point of view).
Reply With Quote
  #13  
Old 10-25-2010, 11:32 AM
PLUCKYHD PLUCKYHD is offline
SageTVaholic
 
Join Date: Dec 2007
Posts: 6,257
Quote:
Originally Posted by stuckless View Post
No. Actually I go out of my way to find excuses to NOT update the metadata on an automatic scan. ie, if detect that there is an existing .properties, i do nothing. If I detect that the the mediafile already has a MediaTitle, then I skip it. Bottom line, I don't want BMT fetching metadata, automatically, for stuff that could already be updated. The "MediaTitle" field, today, acts the the proposed "MediaSource" fields, in that if there's a value in that field, then I skip the file.
I gotcha and understand your reasoning for doing it that way.
Reply With Quote
  #14  
Old 10-25-2010, 12:08 PM
Fuzzy's Avatar
Fuzzy Fuzzy is offline
SageTVaholic
 
Join Date: Sep 2005
Location: Jurupa Valley, CA
Posts: 9,957
Quote:
Originally Posted by stuckless View Post
I think a "good faith" solution is the best we can hope for in terms of fetching metadata. I'm not against Fuzzy's broker solution, but BMT is already a broker. ie, you can have different plugins, you can order the plugins, you can have different plugins for tv, movies, and music, etc, etc. I don't see the point in implementing another broker (from my point of view).
I agree, and I think BMT's methodology for it works quite well. The limitation is that broker doens't extend to the other potential metadata sources out there. Perhaps Plucky should work on implementing his metadata source as a BMT source plugin? I don't know if it would give the capabilities required. I'm certainly not knowledgable in BMT's scraper api, or plucky's needs - but that's never stopped me from chiming in before.. ;-)

Maybe BMT 5.0 could become the SageTV Advanced Metadata Retreival System of the future, and would be sources would be built as addons to that system...
__________________
Buy Fuzzy a beer! (Fuzzy likes beer)

unRAID Server: i7-6700, 32GB RAM, Dual 128GB SSD cache and 13TB pool, with SageTVv9, openDCT, Logitech Media Server and Plex Media Server each in Dockers.
Sources: HRHR Prime with Charter CableCard. HDHR-US for OTA.
Primary Client: HD-300 through XBoxOne in Living Room, Samsung HLT-6189S
Other Clients: Mi Box in Master Bedroom, HD-200 in kids room
Reply With Quote
  #15  
Old 10-25-2010, 12:17 PM
PLUCKYHD PLUCKYHD is offline
SageTVaholic
 
Join Date: Dec 2007
Posts: 6,257
Quote:
Originally Posted by Fuzzy View Post
I agree, and I think BMT's methodology for it works quite well. The limitation is that broker doens't extend to the other potential metadata sources out there. Perhaps Plucky should work on implementing his metadata source as a BMT source plugin? I don't know if it would give the capabilities required. I'm certainly not knowledgable in BMT's scraper api, or plucky's needs - but that's never stopped me from chiming in before.. ;-)

Maybe BMT 5.0 could become the SageTV Advanced Metadata Retreival System of the future, and would be sources would be built as addons to that system...
Yeah great create more work for Stuckless just want he wants....


As for me I probably will still not use the default DB as I have been testing heavily and it really just doesn't do enough to fit the two providers am using with support for offline videos. I could make dummy files and then attach metadata to them but that creates the issue of constantly having to check the external database to make sure no new offline videos exist. As well as it creates the issue of keeping 2 database's in synch the sage db and the external ones. I have been giving the default db a fair shot in the last couple of weeks but I am afraid it will just create more issues/problems for me then it will fix.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Metadata questions bsung SageTV v7 Customizations 7 06-21-2010 08:00 AM
Clean out old metadata created by My Movies before creating new metadata for SageTV? Texas-Hansen SageTV Customizations 0 02-12-2009 10:31 AM
SageTV Pre-Order Questions -- Please Help Me! Outvit General Discussion 27 01-14-2005 02:07 PM
Just finished order, have two questions DWeade General Discussion 2 11-15-2004 08:29 AM


All times are GMT -6. The time now is 08:07 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2023, vBulletin Solutions Inc.
Copyright 2003-2005 SageTV, LLC. All rights reserved.