Logos302 86 Posted March 23, 2014 Share Posted March 23, 2014 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. Link to comment Share on other sites More sharing options...
Redshirt 1487 Posted March 23, 2014 Share Posted March 23, 2014 Have a look at these plugins they may give you some ideas for server plugins. MB Plugin Repo Redshirts Plugin Repo 1 Link to comment Share on other sites More sharing options...
ebr 14927 Posted March 23, 2014 Share Posted March 23, 2014 What are you trying to build? Link to comment Share on other sites More sharing options...
Logos302 86 Posted March 23, 2014 Author Share Posted March 23, 2014 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. Link to comment Share on other sites More sharing options...
ebr 14927 Posted March 23, 2014 Share Posted March 23, 2014 Okay, that should be pretty simple. Let me know if you get hung up. Link to comment Share on other sites More sharing options...
Cheesegeezer 3087 Posted March 24, 2014 Share Posted March 24, 2014 (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 March 24, 2014 by Cheesegeezer Link to comment Share on other sites More sharing options...
Logos302 86 Posted March 25, 2014 Author Share Posted March 25, 2014 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. Link to comment Share on other sites More sharing options...
Logos302 86 Posted March 26, 2014 Author Share Posted March 26, 2014 @@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) Link to comment Share on other sites More sharing options...
ebr 14927 Posted March 26, 2014 Share Posted March 26, 2014 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. Link to comment Share on other sites More sharing options...
Logos302 86 Posted March 27, 2014 Author Share Posted March 27, 2014 (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 March 26, 2014 by Logos302 Link to comment Share on other sites More sharing options...
ebr 14927 Posted March 27, 2014 Share Posted March 27, 2014 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. Link to comment Share on other sites More sharing options...
Logos302 86 Posted April 4, 2014 Author Share Posted April 4, 2014 (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 April 4, 2014 by Logos302 Link to comment Share on other sites More sharing options...
Logos302 86 Posted April 5, 2014 Author Share Posted April 5, 2014 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). Link to comment Share on other sites More sharing options...
ebr 14927 Posted April 5, 2014 Share Posted April 5, 2014 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. Link to comment Share on other sites More sharing options...
Logos302 86 Posted April 5, 2014 Author Share Posted April 5, 2014 I thought I had included it as an embedded resource. I'll take a closer look and make sure. Link to comment Share on other sites More sharing options...
Luke 37107 Posted April 5, 2014 Share Posted April 5, 2014 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. Link to comment Share on other sites More sharing options...
ebr 14927 Posted April 5, 2014 Share Posted April 5, 2014 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. Link to comment Share on other sites More sharing options...
ebr 14927 Posted April 5, 2014 Share Posted April 5, 2014 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. Link to comment Share on other sites More sharing options...
Luke 37107 Posted April 5, 2014 Share Posted April 5, 2014 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. Link to comment Share on other sites More sharing options...
Logos302 86 Posted April 5, 2014 Author Share Posted April 5, 2014 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. 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