Jump to content

Recommended Posts

Logos302
Posted

  Any one got some advice for someone who wanted to make a plugin.   I have so far go the template loaded into VS 2013 Desktop and can compile it, and copied it to the server.  But of course it doesn't do anything yet.  I was hoping someone might have some simple examples that I could look at to get and idea of what to do next.   

 

Posted

What are you trying to build?

Logos302
Posted

I'm just trying to build a simple plugin that talks to uTorrent and remove finished torrents.  I have the code bits written in C# and working (with the help of a free uTorrentAPI), now I just need to convert it to a MBS plugin.  

Posted

Okay, that should be pretty simple. Let me know if you get hung up.

Cheesegeezer
Posted (edited)

I'm just trying to build a simple plugin that talks to uTorrent and remove finished torrents. I have the code bits written in C# and working (with the help of a free uTorrentAPI), now I just need to convert it to a MBS plugin.

 

Not sure if this will help,

 

http://www.aeonity.com/xuanming/automatically-remove-torrents-after-download

 

The logic of how he gets it working may help you on your workflow, to find the actual working version is far down the comments near the bottom.

 

Edit - To save you the hassle here is link http://www.aeonity.com/xuanming/automatically-remove-torrents-after-download#comment-995367355

 

Good luck

Edited by Cheesegeezer
Logos302
Posted

I have already looked at that but thank you for the encouragement.  It's starting to come along, just takes time to learning as you go.  

Logos302
Posted

@@ebr any help that you can give me on this Cancellation Token would be greatly appreciated.  I'm trying to get the Scheduled task to work  on an interval of every 15 mins (I'd like less like every 5mins) 

Posted

Okay, the cancellation token and the schedule are two different things.

 

A cancellation token is passed into the execute method of your task.  You should have a line like this at periodic points in your logic so that your task can be cancelled (like if the user requests to shut down or restart the server, or just hits the cancel button in the manager):

cancellationToken.ThrowIfCancellationRequested();

The default schedule for your task is defined by implementing the following method:

        public IEnumerable<ITaskTrigger> GetDefaultTriggers()
        {
            return new ITaskTrigger[] 
            { 
                new IntervalTrigger{ Interval = TimeSpan.FromHours(24)}
            };
        }

There are a few different trigger types you can provide but these are just defaults.  The user will be able to add, remove or modify any of them.

Logos302
Posted (edited)

ok I'll have to add the cancellationToken into my program then.  As for the Task I have the exact code in a .cs file but I must be missing something as I don't see how that tells the server to run the main method i have made (the code that does it all).   :).  

 

When I was doing it stand alone I had it as a button that called what I would have called a function (but I believe in C# they call a method) which then also triggered a timer to keep doing it ever do often. So I figured that the easiest way to port the code over would to just have the Task Scheduler do the work of calling the function.  

 

And Thanks again for the help.  Learning as I code is so much fun. :).

Edited by Logos302
Posted

Okay, you need to create a class that inherits from IScheduledTask.  Once you do that you will see several methods that you need to implement.  one of them is the default triggers I noted above.  Another one is an "Execute" method.  This is where your logic goes.

  • 2 weeks later...
Logos302
Posted (edited)

took me forever to figure out.  But I got it.  How do I reset the settings so that my new task settings will show? IE :  I changed my trigger from 15 to 10 mins but it didn't change.  

 

 

* Never mind found it C:\Users\%username%\AppData\Roaming\MediaBrowser-Server\config\ScheduledTasks

Edited by Logos302
Logos302
Posted

Hopefully someone can help.  I currently use a DLL and have referenced and included it in the program (which worked in my stand alone project).  But when it runs on the server it throws an error that it can't find this dll.  Have I done something that just not possible?  If I have too the Source for the DLL is available so I should be able to take the src and incorporate it all in to one dll (allowed by dev of dll based on my reading of his EULA).     

Posted

You either need to fold the source code into your assembly (if allowed) or include the dll as an embedded resource and resolve it at runtime.

Logos302
Posted

I thought I had included it as an embedded resource.  I'll take a closer look and make sure.  

Posted

Source is strongly preferred over embedding the dll. The adult plugin fails on linux and osx and i haven't had a chance to really dive into it but i suspect that's the reason.

Posted

Ah, yes, that's a good point.  If you can include it in source then that would eliminate any possible platform issues with that dll.

Posted

I thought I had included it as an embedded resource.  I'll take a closer look and make sure.  

 

Just embedding it won't do the whole trick.  The system is not going to look inside your resources for it unless you tell it to with an assemblyresolve event.  However, like Luke said, if you can include the source, definitely do that.

Posted

Truthfully the assembly load method should be ok, but as it's only one plugin i just don't have time to look into it right now. the simple solution is always preferable.

Logos302
Posted

I got the source and it's now part of the solution, no long using the embedded dll,  And is working at that yeah!!!!  next step is to see if I can figure out if I can display the information about what is being downloaded from uTorrent.    

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...