Jump to content

Tutorial/exemple on plugins/channel creation


AMenard
Go to solution Solved by Luke,

Recommended Posts

bakes82

Ive never tried to see if remote debugging works, but I just add extra log calls so then you can find where its erroring and that with the error message is usually enough.

Link to comment
Share on other sites

DragonSkills99

@bakes82 I never planned debugging remotely... I planned to import the emby server project from git and run it using VS22, then it would also stop at breakpoints in the plugin...

Link to comment
Share on other sites

bakes82
1 minute ago, DragonSkills99 said:

@bakes82 I never planned debugging remotely... I planned to import the emby server project from git and run it using VS22, then it would also stop at breakpoints in the plugin...

you dont "run" DLLs you need to copy the dll in to your emby plugin folder and it runs with emby.  There is no way to "debug" it unless you can remote debug which Ive not tried.

Link to comment
Share on other sites

DragonSkills99
Just now, bakes82 said:

you dont "run" DLLs you need to copy the dll in to your emby plugin folder and it runs with emby.  There is no way to "debug" it unless you can remote debug which Ive not tried.

Thats not completely correct. You CAN debug DLLs if you have them opened in the same project, you just require to run the base-project in VS so the debugger is attached and the project can load/use the DLL, thats also how I tested the API wrapper. I built another project (console application), imported the DLL, set my Break-Points (inside the console app but also inside the plugin code), started the app and it stopped at every breakpoint it reached.

But if you'd really read my messages, you could know from sentences like "I planned to import the emby server project from git [...]" that I never planned to run a DLL...

Link to comment
Share on other sites

bakes82
26 minutes ago, DragonSkills99 said:

Thats not completely correct. You CAN debug DLLs if you have them opened in the same project, you just require to run the base-project in VS so the debugger is attached and the project can load/use the DLL, thats also how I tested the API wrapper. I built another project (console application), imported the DLL, set my Break-Points (inside the console app but also inside the plugin code), started the app and it stopped at every breakpoint it reached.

But if you'd really read my messages, you could know from sentences like "I planned to import the emby server project from git [...]" that I never planned to run a DLL...

You just described remote debugging.  You also dont sound like a developer...  Im a Sr Soft Eng for my day job, I know how to "debug" and you want to run the server project that is CLOSED SOURCE so youre not going to get it.  The only way to "debug" plugins in emby is to add extra logging calls, drop the dll in to a working emby server, run the task or whatever it is, look at logs, unless you can attach a remote debugger to it, which I have not tried as I stated above multiple times.

Link to comment
Share on other sites

DragonSkills99

"You just described remote debugging."

> not really but I guess it was a little to less information here

"You also dont sound like a developer..."

> Well at least I'm not the only one failing at guessing...

"[...] project that is CLOSED SOURCE [...]"

> I didn't delve into the code further, but one the first look "https://github.com/MediaBrowser/Emby" very much seems like the Source-Code of the server to me...

"The only way to "debug" plugins in emby is to add extra logging calls, drop the dll in to a working emby server, run the task or whatever it is, look at logs, unless you can attach a remote debugger to it, which I have not tried as I stated above multiple times."

> There is also a 3rd option: Download the windows-server of Emby, attach a debugger to it, and maybe you can even set breakpoints somehow, but I didn't test that so it's only a guess.

 

But thats also why I requested a simple example where I don't have to figure different saving formats used in other projects as I only want to provide data that emby then manages for me. I don't want to use more than a week on a so simple plugin as just grabbing some data from a public website and save it to series/episodes (I started yesterday btw)

Link to comment
Share on other sites

bakes82
Just now, DragonSkills99 said:

Emby is closed source now, all the old shite you see is from before when it was open source, they are not maintained none of them been updated in years.  But you do you.

Link to comment
Share on other sites

1 minute ago, DragonSkills99 said:

Hi.  Those are very old versions and wouldn't work for debugging a current plugin most likely.

3 minutes ago, DragonSkills99 said:

just grabbing some data from a public website and save it to series/episodes

That's fine if it is just for your personal use.  If you plan to make this plug-in available to others, please describe exactly what you are doing here.

Thanks.

Link to comment
Share on other sites

DragonSkills99

@ebr

it is for my personal use only, and I don't plan on making it public, especially cause I'm not using any API but loading the html code, parsing it and getting the information that way (it would be a hassle to maintain it for longer and update every time the website changes the html structure)

But you're welcome

Link to comment
Share on other sites

DragonSkills99

@bakes82

yes exactly but I don't want to hassle with file system and formats, I just want to write the methods where I get the request object and return the answer with the data to the episodes/series and then emby should manage/save it for me, at least I hoped that that is possible, your example very much seems like I have to load/read/edit the Nfo Files...

Link to comment
Share on other sites

DragonSkills99

Well I dod look at the Anime one, for series it was ok, but for episodes it then started out with searching for a folder and XML file and so on, and I didn't want that, so it's not really what I want

image.thumb.png.5e47e66ba164f251c5aa018b6f23af1b.png

 

"Why not just write a console app to make NFO files in the emby format and then you can do everything outside of emby."

> Yeah, I thought about doing that too, but for today I'm done with that... Maybe I will start it tomorrow when I feel like it.

Link to comment
Share on other sites

  • 4 months later...
TallBoiDez

I'm trying to create a plugin that scraps actor data from a data base I'm making but I have absolutely no ideas where to start or how to even implement my database. I'm trying to make using c# as I am in the process of learning it. I watched @chefvideo on creating an emby plugin but ran into a road block can any help me or point me in the right direction. 

Link to comment
Share on other sites

9 hours ago, TallBoiDez said:

I'm trying to create a plugin that scraps actor data from a data base I'm making but I have absolutely no ideas where to start or how to even implement my database. I'm trying to make using c# as I am in the process of learning it. I watched @chefvideo on creating an emby plugin but ran into a road block can any help me or point me in the right direction. 

Yes! I would love to help. 

1. Spin up a new Dynamic Link Library project in Visual Studio.

2. When it loads rename the boiler plate class:  "Class1.cs" to "Plugin.cs" 

 

Let me know when you got that far.

 

What kind of database are you using? Is it SQLite? I only know SQLite. 

Edited by chef
Link to comment
Share on other sites

TallBoiDez
9 hours ago, chef said:

Yes! I would love to help. 

1. Spin up a new Dynamic Link Library project in Visual Studio.

2. When it loads rename the boiler plate class:  "Class1.cs" to "Plugin.cs" 

 

Let me know when you got that far.

 

What kind of database are you using? Is it SQLite? I only know SQLite. 

I made it that far and im using MS access for my data base, but i might be able to convert it to SqLite

Link to comment
Share on other sites

2 hours ago, TallBoiDez said:

I made it that far and im using MS access for my data base, but i might be able to convert it to SqLite

Great! 

Have you added all the dependancies for the solution yet?

System.Memory and the Media browser core?

 

The next step in building out the solution is to create a folder called "Configuration".

Inside the newly created Configuration folder create a new class called "PluginConfiguration".

 

Link to comment
Share on other sites

TallBoiDez
10 hours ago, chef said:

Great! 

Have you added all the dependancies for the solution yet?

System.Memory and the Media browser core?

 

The next step in building out the solution is to create a folder called "Configuration".

Inside the newly created Configuration folder create a new class called "PluginConfiguration".

 

Yep 

Link to comment
Share on other sites

great!

So now you have your two important files. 

  • Plugin.cs
  • /Configuration/PluginConfiguration.cs

 

Make sure that PluginConfiguration inherits "BasePluginConfiguration"

 

So you class file should look like this:

using System.Collections.Generic;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Model.Plugins;

namespace Emby.MyPluginExample.Configuration
{
    public class PluginConfiguration : BasePluginConfiguration
    {
        public bool IsAwesome { get; set; } = true;       

    }
}

 

Back in "Plugin.cs"  inherit BasePlugin class, and send it our newly created "PluginConfiguration" class though it's Generic type.

public class Plugin : BasePlugin<PluginConfiguration> 
{
  
}

Note: Are you familiar with dependency injection, and how interfaces/abstract classes work?

 

Now you are going to have some red "squiggly" lines under your class, (because BasePlugin is some kind of Abstract Class).

Right click the line and "Implement members".

Boom! the class should have written itself!

    public class Plugin : BasePlugin<PluginConfiguration>
    {
        public static Plugin Instance { get; set; }
        public Plugin(IApplicationPaths applicationPaths, IXmlSerializer xmlSerializer) : base(applicationPaths,
            xmlSerializer)
        {
           
        }

        public override string Name => "MY AWESOME PLUGIN";
        public override string Description => "MY AWESOME EMBY SERVER PLUGIN IS AMAZING";

        public override Guid Id =>  new Guid("CREATE_A_GUID_HERE!!");        
    }

Note: It doesn't look exactly like the code above, I've taken some liberties to me funny.

Let me know how you get on with that.

At this point you could build the project, and you should have a working plugin. Obviously it doesn't do anything... but it should build and load itself when the server restarts.

 

Edited by chef
Link to comment
Share on other sites

TallBoiDez
2 hours ago, chef said:

great!

So now you have your two important files. 

  • Plugin.cs
  • /Configuration/PluginConfiguration.cs

 

Make sure that PluginConfiguration inherits "BasePluginConfiguration"

 

So you class file should look like this:

using System.Collections.Generic;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Model.Plugins;

namespace Emby.MyPluginExample.Configuration
{
    public class PluginConfiguration : BasePluginConfiguration
    {
        public bool IsAwesome { get; set; } = true;       

    }
}

 

Back in "Plugin.cs"  inherit BasePlugin class, and send it our newly created "PluginConfiguration" class though it's Generic type.

public class Plugin : BasePlugin<PluginConfiguration> 
{
  
}

Note: Are you familiar with dependency injection, and how interfaces/abstract classes work?

 

Now you are going to have some red "squiggly" lines under your class, (because BasePlugin is some kind of Abstract Class).

Right click the line and "Implement members".

Boom! the class should have written itself!

    public class Plugin : BasePlugin<PluginConfiguration>
    {
        public static Plugin Instance { get; set; }
        public Plugin(IApplicationPaths applicationPaths, IXmlSerializer xmlSerializer) : base(applicationPaths,
            xmlSerializer)
        {
           
        }

        public override string Name => "MY AWESOME PLUGIN";
        public override string Description => "MY AWESOME EMBY SERVER PLUGIN IS AMAZING";

        public override Guid Id =>  new Guid("CREATE_A_GUID_HERE!!");        
    }

Note: It doesn't look exactly like the code above, I've taken some liberties to me funny.

Let me know how you get on with that.

At this point you could build the project, and you should have a working plugin. Obviously it doesn't do anything... but it should build and load itself when the server restarts.

 

okay it took a while but it looks similar to yours

  • Thanks 1
Link to comment
Share on other sites

22 minutes ago, TallBoiDez said:

okay it took a while but it looks similar to yours

Nice work.

Did it build for you? 

If you place it in your plugins directory, and restart the server, you should see it in your plugins page.

That's how you'll know you are on the right track.

There are many interfaces to try out.

Some of them need to be implemented in classes, and some you can reference using dependancy injection in class constructors.

Have a play around with the core library, it is very powerful.

If you have any questions ask them here, and I can try to help 😆.

 

Link to comment
Share on other sites

BillOatman
1 hour ago, chef said:

Nice work.

Did it build for you? 

If you place it in your plugins directory, and restart the server, you should see it in your plugins page.

That's how you'll know you are on the right track.

There are many interfaces to try out.

Some of them need to be implemented in classes, and some you can reference using dependancy injection in class constructors.

Have a play around with the core library, it is very powerful.

If you have any questions ask them here, and I can try to help 😆.

 

MasterClass on Emby plugin creation ;)

  • Haha 1
Link to comment
Share on other sites

TallBoiDez
5 hours ago, chef said:

Nice work.

Did it build for you? 

If you place it in your plugins directory, and restart the server, you should see it in your plugins page.

That's how you'll know you are on the right track.

There are many interfaces to try out.

Some of them need to be implemented in classes, and some you can reference using dependancy injection in class constructors.

Have a play around with the core library, it is very powerful.

If you have any questions ask them here, and I can try to help 😆.

 

yes, to give my plugin an image i have use the IHasImage and to access my DB i use the IHasWebpage?

Link to comment
Share on other sites

44 minutes ago, TallBoiDez said:

yes, to give my plugin an image i have use the IHasImage and to access my DB i use the IHasWebpage?

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.

 

Edited by chef
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...