mirror of
https://github.com/jellyfin/jellyfin-plugin-template.git
synced 2024-11-23 14:19:41 +00:00
make some readme changes
This commit is contained in:
parent
a437fa140b
commit
644088bad2
@ -5,6 +5,7 @@
|
||||
# Core EditorConfig Options #
|
||||
###############################
|
||||
root = true
|
||||
|
||||
# All files
|
||||
[*]
|
||||
indent_style = space
|
||||
@ -22,9 +23,11 @@ indent_size = 2
|
||||
# XML indentation
|
||||
[*.{csproj,xml}]
|
||||
indent_size = 2
|
||||
|
||||
###############################
|
||||
# .NET Coding Conventions #
|
||||
###############################
|
||||
|
||||
[*.{cs,vb}]
|
||||
# Organize usings
|
||||
dotnet_sort_system_directives_first = true
|
||||
@ -56,9 +59,11 @@ dotnet_prefer_inferred_anonymous_type_member_names = true:suggestion
|
||||
dotnet_style_prefer_auto_properties = true:silent
|
||||
dotnet_style_prefer_conditional_expression_over_assignment = true:silent
|
||||
dotnet_style_prefer_conditional_expression_over_return = true:silent
|
||||
|
||||
###############################
|
||||
# Naming Conventions #
|
||||
###############################
|
||||
|
||||
# Style Definitions (From Roslyn)
|
||||
|
||||
# Non-private static fields are PascalCase
|
||||
@ -133,6 +138,7 @@ dotnet_naming_style.pascal_case_style.capitalization = pascal_case
|
||||
###############################
|
||||
# C# Coding Conventions #
|
||||
###############################
|
||||
|
||||
[*.cs]
|
||||
# var preferences
|
||||
csharp_style_var_for_built_in_types = true:silent
|
||||
@ -159,9 +165,11 @@ csharp_style_deconstructed_variable_declaration = true:suggestion
|
||||
csharp_prefer_simple_default_expression = true:suggestion
|
||||
csharp_style_pattern_local_over_anonymous_function = true:suggestion
|
||||
csharp_style_inlined_variable_declaration = true:suggestion
|
||||
|
||||
###############################
|
||||
# C# Formatting Rules #
|
||||
###############################
|
||||
|
||||
# New line preferences
|
||||
csharp_new_line_before_open_brace = all
|
||||
csharp_new_line_before_else = true
|
||||
@ -189,9 +197,11 @@ csharp_space_between_method_call_empty_parameter_list_parentheses = false
|
||||
# Wrapping preferences
|
||||
csharp_preserve_single_line_statements = true
|
||||
csharp_preserve_single_line_blocks = true
|
||||
|
||||
###############################
|
||||
# VB Coding Conventions #
|
||||
###############################
|
||||
|
||||
[*.vb]
|
||||
# Modifier preferences
|
||||
visual_basic_preferred_modifier_order = Partial,Default,Private,Protected,Public,Friend,NotOverridable,Overridable,MustOverride,Overloads,Overrides,MustInherit,NotInheritable,Static,Shared,Shadows,ReadOnly,WriteOnly,Dim,Const,WithEvents,Widening,Narrowing,Custom,Async:suggestion
|
||||
|
@ -3,6 +3,8 @@
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
<RootNamespace>Jellyfin.Plugin.Template</RootNamespace>
|
||||
<AssemblyVersion>7.0.0</AssemblyVersion>
|
||||
<FileVersion>7.0.0</FileVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
42
README.md
42
README.md
@ -1,7 +1,9 @@
|
||||
# So you want to make a Jellyfin plugin
|
||||
|
||||
Awesome! This guide is for you. Jellyfin plugins are written using the dotnet standard framework. What that means is you can write them in any language that implements the CLI or the DLI and can compile to netstandard2.0. The examples on this page are in C# because that is what most of Jellyfin is written in, but F#, Visual Basic, and IronPython should all be compatible once compiled.
|
||||
|
||||
## 0. Things you need to get started:
|
||||
|
||||
- [Dotnet Core SDK 2.2](https://dotnet.microsoft.com/download)
|
||||
- An editor of your choice. Some free choices are:
|
||||
|
||||
@ -12,75 +14,91 @@ Awesome! This guide is for you. Jellyfin plugins are written using the dotnet st
|
||||
[Mono Develop](https://www.monodevelop.com/)
|
||||
|
||||
## 0.5. Quickstarts
|
||||
|
||||
We have a number of quickstart options available to speed you along the way
|
||||
|
||||
- [Download the Example Plugin Project](https://github.com/jellyfin/jellyfin-plugin-template/tree/master/Jellyfin.Plugin.Template) from this repository, open it in your IDE and go to [step 3](https://github.com/jellyfin/jellyfin-plugin-template#3-customize-plugin-information)
|
||||
|
||||
- Install our dotnet template by [downloading the dotnet-template/content folder from this repo](https://github.com/jellyfin/jellyfin-plugin-template/tree/master/dotnet-template/content) or off of Nuget (Coming soon)
|
||||
|
||||
```
|
||||
dotnet new -i /path/to/templatefolder
|
||||
```
|
||||
|
||||
- and run this command then skip to step 4
|
||||
- Run this command then skip to step 4
|
||||
|
||||
```
|
||||
dotnet new Jellyfin-plugin -name MyPlugin
|
||||
```
|
||||
- Install our visual studio plugin (coming soon) and make a new Jellyfin plugin project, then skip to step 4
|
||||
|
||||
If you'd rather start from scratch keep going on to step 1. This assumes no specific editor or IDE and requires only the command line with dotnet in the path.
|
||||
|
||||
## 1. Initialize your project
|
||||
|
||||
Make a new dotnet standard project with the following command, it will make a directory for itself:
|
||||
|
||||
```dotnet new classlib -f netstandard2.0 -n MyJellyFinPlugin```
|
||||
```
|
||||
dotnet new classlib -f netstandard2.0 -n MyJellyFinPlugin
|
||||
```
|
||||
|
||||
Now add the Jellyfin shared libraries
|
||||
Now add the Jellyfin shared libraries.
|
||||
|
||||
```
|
||||
dotnet add package Jellyfin.Model
|
||||
dotnet add package Jellyfin.Controller
|
||||
```
|
||||
|
||||
You have an autogenerated Class1.cs file, you won't be needing this, so go ahead and delete it.
|
||||
|
||||
## 2. Setup Basics
|
||||
|
||||
There are a few mandatory classes you'll need for a plugin so we need to make them.
|
||||
|
||||
### Make a new class called PluginConfiguration
|
||||
|
||||
You can call it watever you'd like readlly. This class is used to hold settings your plugin might need. We can leave it empty for now. This class should inherit from `MediaBrowser.Model.Plugins.BasePluginConfiguration`
|
||||
|
||||
### Make a new class called Plugin
|
||||
|
||||
This is the main class for your plugin. It will define your name, version and Id. It should inherit from `MediaBrowser.Common.Plugins.BasePlugin<PluginConfiguration> `
|
||||
|
||||
Note: If you called your PluginConfiguration class something different, you need to put that between the <>
|
||||
|
||||
### Implement Required Properties
|
||||
|
||||
The Plugin class needs a few properties implemented before it can work correctly.
|
||||
|
||||
It needs an override on ID, an override on Name and a constructor that follows a specific model. To get started you can use the following snippit:
|
||||
|
||||
```c#
|
||||
public Plugin(IApplicationPaths applicationPaths, IXmlSerializer xmlSerializer) : base(applicationPaths, xmlSerializer){}
|
||||
public override string Name => throw new System.NotImplementedException();
|
||||
public override Guid Id => Guid.Parse("");
|
||||
```
|
||||
|
||||
## 3. Customize Plugin Information
|
||||
|
||||
You need to populate some of your plugin's information. Go ahead a put in a string of the Name you've overridden name, and generate a GUID
|
||||
- **Windows Users**: you can use the Powershell command `New-Guid` or the Visual Studio GUID generator
|
||||
- **Windows Users**: you can use the Powershell command `New-Guid` or the Visual Studio GUID generator
|
||||
- **Linux and OS X users**: you can use the Powershell Core command `New-Guid` or this command from your shell of choice:
|
||||
|
||||
```bash
|
||||
od -x /dev/urandom | head -1 | awk '{OFS="-"; srand($6); sub(/./,"4",$5); sub(/./,substr("89ab",rand()*4,1),$6); print $2$3,$4,$5,$6,$7$8$9}'
|
||||
```
|
||||
- Place that guid inside the `Guid.Parse("")` quotes to define your plugin's ID.
|
||||
|
||||
## 4. Adding Functionality
|
||||
|
||||
Congratulations, you now have everything you need for a perfectly functional functionless Jellyfin plugin! You can try it out right now if you'd like by compiling it, then placing the dll you generate in the plugins folder under your Jellyfin config directory. If you want to try and hook it up to a debugger make sure you copy the generated PDB file alongside it.
|
||||
|
||||
Most people aren't satisfied with just having an entry in a menu for their plugin, most people want to have some functionality, so lets look at how to add it.
|
||||
|
||||
### Step 4a. Implement interfaces to add components
|
||||
### 4a. Implement interfaces to add components
|
||||
|
||||
If the functionality you are trying to add is functionality related to something that Jellyfin has an interface for you're in luck. Jellyfin uses some automatic discovery and injection to allow any interfaces you implement in your plugin to be available in Jellyfin.
|
||||
|
||||
Here's some interfaces you could implement for common use cases:
|
||||
|
||||
|
||||
- **IAuthenticationProvider** - Allows you to add an authentication provider that can authenticate a user based on a name and a password, but that doesn't expect to deal with local users.
|
||||
- **IBaseItemComparer** - Allows you to add sorting rules for dealing with media that will show up in sort menus
|
||||
- **IImageEnhancer** - Allows you to intercept and manipulate images served by Jellyfin
|
||||
@ -91,20 +109,21 @@ Here's some interfaces you could implement for common use cases:
|
||||
- **IMetadataSaver** - Allows you to define a metadata standard that Jellyfin can use to write metadata
|
||||
- **IResolverIgnoreRule** - Allows you to define subpaths that are ignored by media resolvers for use with another function (i.e. you wanted to have a theme song for each tv series stored in a subfolder that could be accessed by your plugin for playback in a menu).
|
||||
- **IScheduledTask** - Allows you to create a scheduled task that will appear in the scheduled task lists on the dashboard.
|
||||
|
||||
|
||||
There are loads of other interfaces that can be used, but you'll need to poke around the API to get some info. If you're an expert on a particular interface, you should help [contribute some documentation](https://jellyfin.org/docs/general/contributing/index.html)!
|
||||
|
||||
### 4b. Use plugin aimed interfaces to add custom functionality
|
||||
|
||||
If your plugin doesn't fit perfectly neatly into a predefined interface, never fear, there are a set of interfaces that allow your plugin to extend Jellyfin any which way you please. Here's a quick overview on how to use them
|
||||
|
||||
- **IPluginConfigurationPage** - Allows you to have a plugin config page on the dashboard. If you used one of the quickstart example projects, a premade page with some useful components to work with has been created for you! If not you can check out this guide here for how to whip one up.
|
||||
- **IRestfulService** - Allows you to extend the Jellyfin http API and handle API calls that come in on the routes you define.
|
||||
- **IServerEntryPoint** - Allows you to run code at server startup that will stay in memory. You can make as many of these as you need and it is wildly useful for loading configs or persisting state.
|
||||
|
||||
|
||||
Likewise you might need to get data and services from the Jellyfin core, Jellyfin provides a number of interfaces you can add as parameters to your plugin constructor which are then made available in your project (you can see the 2 mandatory ones that are needed by the plugin system in the constructor as is).
|
||||
|
||||
- **IBlurayExaminer** - Allows you to examine blu-ray folders
|
||||
- **IDtoService** - Allows you to create data transport objects, presumably to send to other plugins or to the core, not 100% on this one honestly :)
|
||||
- **IDtoService** - Allows you to create data transport objects, presumably to send to other plugins or to the core
|
||||
- **IIsoManager** - Allows the mounting and unmounting of ISO files
|
||||
- **IJsonSerializer** - Allows you to use the main json serializer
|
||||
- **ILibraryManager** - Allows you to directly access the media libraries without hopping through the API
|
||||
@ -116,10 +135,11 @@ Likewise you might need to get data and services from the Jellyfin core, Jellyfi
|
||||
- **IServerConfigurationManager** - Allows you to write or read server configuration data into the application paths
|
||||
- **ITaskManager** - Allows you to execute and manipulate scheduled tasks
|
||||
- **IUserManager** - Allows you to retrieve user info and user library related info
|
||||
- **IXmlSerializer** - Allows you to use the main xml serializer
|
||||
- **IXmlSerializer** - Allows you to use the main xml serializer
|
||||
- **IZipClient** - Allows you to use the core zip client for compressing and decompressing data
|
||||
|
||||
## 5. Submit your plugin to the Jellyfin repo
|
||||
|
||||
- Choose a License, Jellyfin recommends [GPLv2](https://www.gnu.org/licenses/old-licenses/gpl-2.0.html). If you would like your plugin to be integrated into Jellyfin and available from the plugin browser you MUST choose a [GPL Compatible License](https://www.gnu.org/licenses/license-list.html#GPLCompatibleLicenses)
|
||||
- Upload your plugin to github.
|
||||
- Contact the Jellyfin Team!
|
||||
|
@ -2,6 +2,7 @@
|
||||
name: "jellyfin-plugin-template"
|
||||
guid: "eb5d7894-8eef-4b36-aa6f-5d124e828ce1"
|
||||
version: "1.0.0"
|
||||
jellyfin_version: "10.3.7"
|
||||
nicename: "Template"
|
||||
description: "Short description about your plugin"
|
||||
overview: >
|
||||
|
Loading…
Reference in New Issue
Block a user