TallBoiDez 8 Posted September 12, 2022 Share Posted September 12, 2022 3 hours ago, chef said: Yes to the first question. Place you thumb image as an embedded resource in your solution ,then you can use reflection to grab the resource stream in the methods created by implementing the interface. Let me know if I should go more indepth on that. For the second question... no I don't think so. IHasWebpage usually points to html and js pages for your plugin configuration in the dashboard. When I used an SQLite database in the past, I had to write my own implementation to use it. (In actual fact I used an implementation found inside the auto organizer plugin on GitHub). Emby uses SQLite, so the libraries to access these types of data tables are available with emby. "<PackageReference Include="SQLitePCL.pretty.core" Version="1.2.2" />" is this what I need to reference my database Link to comment Share on other sites More sharing options...
TallBoiDez 8 Posted September 13, 2022 Share Posted September 13, 2022 I want certain Library to be able to access my database would I put that code in the configuration.cs or the plugin.cs? Link to comment Share on other sites More sharing options...
chef 3748 Posted September 13, 2022 Share Posted September 13, 2022 5 hours ago, TallBoiDez said: I want certain Library to be able to access my database would I put that code in the configuration.cs or the plugin.cs? I think what you want to look at is the IChannel interface. This creates libraries (of a sort). Then you could read you db items into a channel. On 9/11/2022 at 11:18 PM, TallBoiDez said: "<PackageReference Include="SQLitePCL.pretty.core" Version="1.2.2" />" is this what I need to reference my database That looks right. Link to comment Share on other sites More sharing options...
bakes82 90 Posted September 14, 2022 Share Posted September 14, 2022 I thought he was making a meta provider not a channel. But his requirements don’t seem clear on the one post. Link to comment Share on other sites More sharing options...
TallBoiDez 8 Posted September 14, 2022 Share Posted September 14, 2022 4 minutes ago, bakes82 said: I thought he was making a meta provider not a channel. But his requirements don’t seem clear on the one post. Basically I want specific libraries to be able to access and retrieve actor Metadata (image, overview, birthday, and place of birth) from my database. I'm completely new to c# and emby plug-in development so I'm sorry any confusion I may have caused. Link to comment Share on other sites More sharing options...
bakes82 90 Posted September 14, 2022 Share Posted September 14, 2022 You want to build a metadata agent. Idk if chef has built one. I haven’t. But you don’t need to be making channels for it it’s still a plug-in but the wiring Is different Link to comment Share on other sites More sharing options...
TallBoiDez 8 Posted September 14, 2022 Share Posted September 14, 2022 32 minutes ago, bakes82 said: You want to build a metadata agent. Idk if chef has built one. I haven’t. But you don’t need to be making channels for it it’s still a plug-in but the wiring Is different Yeah, I've been looking at other similar plugin to get an idea of what I need to do. Link to comment Share on other sites More sharing options...
TeamB 2354 Posted September 14, 2022 Share Posted September 14, 2022 (edited) a good place to have a look at are some of the plugins in the MediaBrowser GitRepo The Nfo one might be something you can use to model your plugin: https://github.com/MediaBrowser/NfoMetadata there is also the anime one: https://github.com/MediaBrowser/Emby.Plugins.Anime/tree/master/MediaBrowser.Plugins.Anime I think the main service logic is in the ILocalMetadataProvider interface: https://github.com/MediaBrowser/NfoMetadata/blob/master/NfoMetadata/Providers/BaseNfoProvider.cs Edited September 14, 2022 by TeamB 1 Link to comment Share on other sites More sharing options...
chef 3748 Posted September 14, 2022 Share Posted September 14, 2022 5 minutes ago, TeamB said: a good place to have a look at are some of the plugins in the MediaBrowser GitRepo The Nfo one might be something you can use to model your plugin: https://github.com/MediaBrowser/Emby.Plugins.Anime/tree/master/MediaBrowser.Plugins.Anime I think the main service logic is in the ILocalMetadataProvider interface https://github.com/MediaBrowser/NfoMetadata/blob/master/NfoMetadata/Providers/BaseNfoProvider.cs Agreed. Link to comment Share on other sites More sharing options...
chef 3748 Posted September 14, 2022 Share Posted September 14, 2022 If you are going to make some kind of metadata provider then TeamB is right, those links are good resources. Link to comment Share on other sites More sharing options...
TallBoiDez 8 Posted September 14, 2022 Share Posted September 14, 2022 Thank you @TeamB for the resources @chef I am having trouble making the image for my plugin an embedded resource it's not giving me the option to do so Link to comment Share on other sites More sharing options...
bakes82 90 Posted September 14, 2022 Share Posted September 14, 2022 Look at the csproj file one the plugsins you can set it that way also Link to comment Share on other sites More sharing options...
TallBoiDez 8 Posted September 14, 2022 Share Posted September 14, 2022 @bakes82 i was able to get it. can someone take a look at my code Link to comment Share on other sites More sharing options...
chef 3748 Posted September 15, 2022 Share Posted September 15, 2022 7 minutes ago, TallBoiDez said: @bakes82 i was able to get it. can someone take a look at my code I might have time tomorrow for a code review. Unless someone gets to it before me. You can either post it on GitHub... Or you can zip up the solution and post it here. Link to comment Share on other sites More sharing options...
TeamB 2354 Posted September 15, 2022 Share Posted September 15, 2022 put it up on GitHub, its a great place to do social coding Link to comment Share on other sites More sharing options...
TallBoiDez 8 Posted September 15, 2022 Share Posted September 15, 2022 Can anyone tell or show me how i would implement an SQL Database Link to comment Share on other sites More sharing options...
chef 3748 Posted September 15, 2022 Share Posted September 15, 2022 (edited) 25 minutes ago, TallBoiDez said: Can anyone tell or show me how i would implement an SQL Database I can show you how to implement a database with SQLite. https://github.com/chefbennyj1/Emby.AutoOrganize/blob/chef_changes_2/Emby.AutoOrganize/Data/SqliteFileOrganizationRepository.cs Edited September 15, 2022 by chef Link to comment Share on other sites More sharing options...
TallBoiDez 8 Posted September 15, 2022 Share Posted September 15, 2022 13 minutes ago, chef said: I can show you how to implement a database with SQLite. https://github.com/chefbennyj1/Emby.AutoOrganize/blob/chef_changes_2/Emby.AutoOrganize/Data/SqliteFileOrganizationRepository.cs So I put "using sqlitepcl.pretty;" and then create a public class to connect to the sql database? Link to comment Share on other sites More sharing options...
chef 3748 Posted September 15, 2022 Share Posted September 15, 2022 (edited) First I would copy this class into your solution https://github.com/chefbennyj1/Emby.AutoOrganize/blob/chef_changes_2/Emby.AutoOrganize/Data/BaseSqliteRepository.cs That is the Base class for the SQLite repository. Next step would be to create a class that is the Repository (controller of sorts). This Repository class will handle your connection strings, database creation, all your gets, and saves. I'm not sure I'm the guy that it going to explain ( well enough) serializing and deserializing classes to and from a data table. Perhaps, read through the Auto organizer plugin, and see what you find. I can try to answer questions. Edited September 15, 2022 by chef Link to comment Share on other sites More sharing options...
TallBoiDez 8 Posted September 15, 2022 Share Posted September 15, 2022 6 hours ago, chef said: First I would copy this class into your solution https://github.com/chefbennyj1/Emby.AutoOrganize/blob/chef_changes_2/Emby.AutoOrganize/Data/BaseSqliteRepository.cs That is the Base class for the SQLite repository. Next step would be to create a class that is the Repository (controller of sorts). This Repository class will handle your connection strings, database creation, all your gets, and saves. I'm not sure I'm the guy that it going to explain ( well enough) serializing and deserializing classes to and from a data table. Perhaps, read through the Auto organizer plugin, and see what you find. I can try to answer questions. So, I would create a new class and copy and paste that into the new class Link to comment Share on other sites More sharing options...
chef 3748 Posted September 15, 2022 Share Posted September 15, 2022 (edited) 1 hour ago, TallBoiDez said: So, I would create a new class and copy and paste that into the new class That BaseRespository class has some methods that will help build out your database. Have you put you code on GitHub yet? That would be helpful because otherwise its like the blind leading the blind. You'll have to build out the class that mirrors your data table as well. All the columns are properties in you class. This way we can serialize the data base into your plugin. Whatever you do, don't give up. Once you figure it out, it's going to all make sense. The project is a bit advanced for when you are just learning c# (I think you said you are just learning). But, you can definitely do this! Edited September 15, 2022 by chef Link to comment Share on other sites More sharing options...
TallBoiDez 8 Posted September 15, 2022 Share Posted September 15, 2022 1 hour ago, chef said: That BaseRespository class has some methods that will help build out your database. Have you put you code on GitHub yet? That would be helpful because otherwise its like the blind leading the blind. You'll have to build out the class that mirrors your data table as well. All the columns are properties in you class. This way we can serialize the data base into your plugin. Whatever you do, don't give up. Once you figure it out, it's going to all make sense. The project is a bit advanced for when you are just learning c# (I think you said you are just learning). But, you can definitely do this! Haven't yet and I just start learning c# currently at work, but I'll put it up on git hub when I get home and thanks for the encouragement. Link to comment Share on other sites More sharing options...
TallBoiDez 8 Posted September 15, 2022 Share Posted September 15, 2022 4 hours ago, chef said: That BaseRespository class has some methods that will help build out your database. Have you put you code on GitHub yet? That would be helpful because otherwise its like the blind leading the blind. You'll have to build out the class that mirrors your data table as well. All the columns are properties in you class. This way we can serialize the data base into your plugin. Whatever you do, don't give up. Once you figure it out, it's going to all make sense. The project is a bit advanced for when you are just learning c# (I think you said you are just learning). But, you can definitely do this! So, the columns in my database, so based on what I just read about properties and from your telling me an example of one property for my plugin would be: public class Actor { public string name {get; set;} } Where "Actor" would be a column in my database and the public string "name" would read the name of the actor and write it as per the {get; set;} perimeter. Am I correct? Link to comment Share on other sites More sharing options...
chef 3748 Posted September 15, 2022 Share Posted September 15, 2022 4 minutes ago, TallBoiDez said: So, the columns in my database, so based on what I just read about properties and from your telling me an example of one property for my plugin would be: public class Actor { public string name {get; set;} } Where "Actor" would be a column in my database and the public string "name" would read the name of the actor and write it as per the {get; set;} perimeter. Am I correct? Not quite. The top level class would be called something like "PluginRespositoryResult" since we are going to serialize the repo into this class. public class PluginRepositoryResult { public List<Actor> actors { get; set; } } public class Actor { public string Name { get; set; } } However, there are some issues with this that you need to be aware of because a data table is one dimensional. Note: Right off the top, it might be best to use the same naming as emby. Instead of "Actor", use "Person". But... That's not the big issue you are about run into here... Because the database is one dimensional, serializing "Actor" into the table with a bunch of properties is going to be difficult. I'm going to try and not sound over top here and try to explain it (probabaly poorly).... So here we go... There are two ways to serialize a multi level class system into a database. Here is the easiest one... In my opinion (someone might chime in and say otherwise, or have a better way). If you are going to serialize Actor, then really what you might consider is serializing the Actor object to a JSON string, and place it in the database cell under "Actors". This way all the data can still be serialized back to the class object later. I just realized that I'm not going to even mention multiple tables in your .db file referencing each other. That $#!t get complicated. Serializing sub classes to JSON is best, strictly in my opinion. Link to comment Share on other sites More sharing options...
TallBoiDez 8 Posted September 15, 2022 Share Posted September 15, 2022 (edited) 44 minutes ago, chef said: Not quite. The top level class would be called something like "PluginRespositoryResult" since we are going to serialize the repo into this class. public class PluginRepositoryResult { public List<Actor> actors { get; set; } } public class Actor { public string Name { get; set; } } However, there are some issues with this that you need to be aware of because a data table is one dimensional. Note: Right off the top, it might be best to use the same naming as emby. Instead of "Actor", use "Person". But... That's not the big issue you are about run into here... Because the database is one dimensional, serializing "Actor" into the table with a bunch of properties is going to be difficult. I'm going to try and not sound over top here and try to explain it (probabaly poorly).... So here we go... There are two ways to serialize a multi level class system into a database. Here is the easiest one... In my opinion (someone might chime in and say otherwise, or have a better way). If you are going to serialize Actor, then really what you might consider is serializing the Actor object to a JSON string, and place it in the database cell under "Actors". This way all the data can still be serialized back to the class object later. I just realized that I'm not going to even mention multiple tables in your .db file referencing each other. That $#!t get complicated. Serializing sub classes to JSON is best, strictly in my opinion. So, if I change it from "Actor" to "Person" then the code would look like this public class PluginRepositoryResult { public List<Person> actor { get; set; } } public class Person { public string Name { get; set; } } Correct? Would it be easier to pull data from a .xml file or should I stick with the SQL database route? Edited September 15, 2022 by TallBoiDez Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now