### Install Jellyfin .NET Template (dotnet CLI)
Source: https://github.com/jellyfin/jellyfin-plugin-template/blob/master/README.md
Demonstrates how to install a Jellyfin plugin .NET template locally from a folder path. This allows for quicker project creation using the `dotnet new` command.
```bash
dotnet new -i /path/to/templatefolder
```
--------------------------------
### Create Jellyfin Plugin using Template (dotnet CLI)
Source: https://github.com/jellyfin/jellyfin-plugin-template/blob/master/README.md
Creates a new Jellyfin plugin project using a previously installed .NET template. This command simplifies the initial setup by generating a project with a specified name.
```bash
dotnet new Jellyfin-plugin -name MyPlugin
```
--------------------------------
### Configure Local Setup with settings.json for VS Code
Source: https://github.com/jellyfin/jellyfin-plugin-template/blob/master/README.md
Defines local paths for Jellyfin server, web client, and data directories, along with the plugin name. This JSON file customizes the debugging environment for a specific local setup.
```json
{
// jellyfinDir : The directory of the cloned jellyfin server project
// This needs to be built once before it can be used
"jellyfinDir" : "${workspaceFolder}/../jellyfin/Jellyfin.Server",
// jellyfinWebDir : The directory of the cloned jellyfin-web project
// This needs to be built once before it can be used
"jellyfinWebDir" : "${workspaceFolder}/../jellyfin-web",
// jellyfinDataDir : the root data directory for a running jellyfin instance
// This is where jellyfin stores its configs, plugins, metadata etc
// This is platform specific by default, but on Windows defaults to
// ${env:LOCALAPPDATA}/jellyfin
"jellyfinDataDir" : "${env:LOCALAPPDATA}/jellyfin",
// The name of the plugin
"pluginName" : "Jellyfin.Plugin.Template"
}
```
--------------------------------
### Copy Plugin DLLs to Jellyfin Plugins Directory
Source: https://github.com/jellyfin/jellyfin-plugin-template/blob/master/README.md
This task copies the compiled plugin DLLs from the build output directory to the designated Jellyfin plugin installation path. It uses the `cp` command to transfer all files from the publish directory, accommodating plugins that may include additional bundled requirements.
```jsonc
{
// Copy the plugin dll to the jellyfin plugin install path
// This command copies every .dll from the build directory to the plugin dir
// Usually, you probablly only need ${config:pluginName}.dll
// But some plugins may bundle extra requirements
"label": "copy-dll",
"type": "shell",
"command": "cp",
"args": [
"./${config:pluginName}/bin/Debug/net8.0/publish/*",
"${config:jellyfinDataDir}/plugins/${config:pluginName}/"
]
}
```
--------------------------------
### Create Jellyfin Plugin Project and Add Dependencies (dotnet CLI)
Source: https://github.com/jellyfin/jellyfin-plugin-template/blob/master/README.md
Initializes a new .NET Standard class library project for a Jellyfin plugin and adds the required Jellyfin Model and Controller packages. It also shows how to configure package references to exclude assets for correct plugin registration.
```bash
dotnet new classlib -f net9.0 -n MyJellyfinPlugin
dotnet add package Jellyfin.Model
dotnet add package Jellyfin.Controller
```
```xml
runtimeruntime
```
--------------------------------
### Configure Launch Configuration with launch.json for VS Code
Source: https://github.com/jellyfin/jellyfin-plugin-template/blob/master/README.md
Sets up the debugging configuration for launching the Jellyfin server in Visual Studio Code. It specifies the program to run, arguments, and a pre-launch task.
```json
{
// Paths and plugin names are configured in settings.json
"version": "0.2.0",
"configurations": [
{
"type": "coreclr",
"name": "Launch",
"request": "launch",
"preLaunchTask": "build-and-copy",
"program": "${config:jellyfinDir}/bin/Debug/net8.0/jellyfin.dll",
"args": [
//"--nowebclient"
"--webdir",
"${config:jellyfinWebDir}/dist/"
],
"cwd": "${config:jellyfinDir}"
}
]
}
```
--------------------------------
### Define Build and Copy Task with tasks.json for VS Code
Source: https://github.com/jellyfin/jellyfin-plugin-template/blob/master/README.md
Configures a sequence of tasks in Visual Studio Code to build the plugin and copy it to the Jellyfin server's plugin directory. This automates the deployment step before debugging.
```json
{
// Paths and plugin name are configured in settings.json
"version": "2.0.0",
"tasks": [
{
// A chain task - build the plugin, then copy it to your
// jellyfin server's plugin directory
"label": "build-and-copy",
"dependsOrder": "sequence",
"dependsOn": ["build", "make-plugin-dir", "copy-dll"]
},
{
// Build the plugin
"label": "build",
"command": "dotnet",
"type": "shell",
"args": [
"publish",
"${workspaceFolder}/${config:pluginName}.sln",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"group": "build",
"presentation": {
"reveal": "silent"
},
"problemMatcher": "$msCompile"
},
{
// Ensure the plugin directory exists before trying to use it
"label": "make-plugin-dir",
"type": "shell"
}
]
}
```
--------------------------------
### Build Jellyfin Plugin with Dotnet CLI
Source: https://github.com/jellyfin/jellyfin-plugin-template/blob/master/README.md
This task uses the `dotnet publish` command to build the Jellyfin plugin. It ensures full paths are generated for file names and suppresses the summary output for a cleaner log. The task is configured to run silently and uses the `$msCompile` problem matcher.
```jsonc
{
// Build the plugin
"label": "build",
"command": "dotnet",
"type": "shell",
"args": [
"publish",
"${workspaceFolder}/${config:pluginName}.sln",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"group": "build",
"presentation": {
"reveal": "silent"
},
"problemMatcher": "$msCompile"
}
```
--------------------------------
### Implement Required Plugin Properties (C#)
Source: https://github.com/jellyfin/jellyfin-plugin-template/blob/master/README.md
Implements the mandatory properties for a Jellyfin plugin, including overrides for 'ID' and 'Name', and a constructor that accepts IApplicationPaths and IXmlSerializer. This setup is essential for the plugin to be recognized and function correctly.
```csharp
public Plugin(IApplicationPaths applicationPaths, IXmlSerializer xmlSerializer) : base(applicationPaths, xmlSerializer){}
public override string Name => throw new System.NotImplementedException();
public override Guid Id => Guid.Parse("");
```
--------------------------------
### Generate Plugin GUID on Linux/macOS
Source: https://github.com/jellyfin/jellyfin-plugin-template/blob/master/README.md
Instructions for Linux and macOS users to generate a Globally Unique Identifier (GUID) for their Jellyfin plugin. This includes using PowerShell Core or shell commands.
```powershell
New-Guid
```
```bash
od -x /dev/urandom | head -n1 | awk '{OFS="-"; srand($6); sub(/./,"4",$5); sub(/./,substr("89ab",1+rand()*4,1),$6); print $2$3,$4,$5,$6,$7$8$9}'
```
```bash
uuidgen
```
--------------------------------
### Generate Plugin GUID on Windows
Source: https://github.com/jellyfin/jellyfin-plugin-template/blob/master/README.md
Instructions for Windows users to generate a Globally Unique Identifier (GUID) for their Jellyfin plugin. This can be done using PowerShell commands or the Visual Studio IDE.
```powershell
New-Guid
[guid]::NewGuid()
```
--------------------------------
### Define Plugin Configuration Class (C#)
Source: https://github.com/jellyfin/jellyfin-plugin-template/blob/master/README.md
Defines a basic plugin configuration class that inherits from MediaBrowser.Model.Plugins.BasePluginConfiguration. This class is intended to hold settings for the Jellyfin plugin and can be left empty initially.
```csharp
using MediaBrowser.Model.Plugins;
namespace MyJellyfinPlugin.Configuration;
class PluginConfiguration : BasePluginConfiguration
{
}
```
--------------------------------
### Sequence Build and Copy Tasks for Jellyfin Plugin
Source: https://github.com/jellyfin/jellyfin-plugin-template/blob/master/README.md
This task orchestrates the entire plugin deployment process by creating a sequence of dependent tasks. It first builds the plugin, then ensures the plugin directory exists, and finally copies the compiled DLLs to the correct location.
```jsonc
{
// A chain task - build the plugin, then copy it to your
// jellyfin server's plugin directory
"label": "build-and-copy",
"dependsOrder": "sequence",
"dependsOn": ["build", "make-plugin-dir", "copy-dll"]
}
```
--------------------------------
### Define Main Plugin Class (C#)
Source: https://github.com/jellyfin/jellyfin-plugin-template/blob/master/README.md
Defines the main plugin class for Jellyfin, inheriting from MediaBrowser.Common.Plugins.BasePlugin. This class serves as the entry point for the plugin and manages its core functionality.
```csharp
using MediaBrowser.Common.Plugins;
using MyJellyfinPlugin.Configuration;
namespace MyJellyfinPlugin;
class Plugin : BasePlugin
{
}
```
--------------------------------
### Create Jellyfin Plugin Directory
Source: https://github.com/jellyfin/jellyfin-plugin-template/blob/master/README.md
This task ensures that the necessary directory structure for the plugin exists within the Jellyfin data directory. It uses the `mkdir -Force` command to create the plugin's specific subfolder, preventing errors if the directory already exists.
```jsonc
{
// Ensure the plugin directory exists before trying to use it
"label": "make-plugin-dir",
"type": "shell",
"command": "mkdir",
"args": [
"-Force",
"-Path",
"${config:jellyfinDataDir}/plugins/${config:pluginName}/"
]
}
```
--------------------------------
### Implement Jellyfin Plugin Core with Configuration
Source: https://context7.com/jellyfin/jellyfin-plugin-template/llms.txt
Demonstrates the core implementation of a Jellyfin plugin, inheriting from BasePlugin for configuration management. It establishes the plugin's identity and integrates with Jellyfin's system, providing access to settings and defining web pages for configuration.
```csharp
using System;
using System.Collections.Generic;
using System.Globalization;
using Jellyfin.Plugin.Template.Configuration;
using MediaBrowser.Common.Configuration;
using MediaBrowser.Common.Plugins;
using MediaBrowser.Model.Plugins;
using MediaBrowser.Model.Serialization;
namespace Jellyfin.Plugin.Template;
///
/// The main plugin.
///
public class Plugin : BasePlugin, IHasWebPages
{
///
/// Initializes a new instance of the class.
///
/// Instance of the interface.
/// Instance of the interface.
public Plugin(IApplicationPaths applicationPaths, IXmlSerializer xmlSerializer)
: base(applicationPaths, xmlSerializer)
{
Instance = this;
}
///
public override string Name => "Template";
///
public override Guid Id => Guid.Parse("eb5d7894-8eef-4b36-aa6f-5d124e828ce1");
///
/// Gets the current plugin instance.
///
public static Plugin? Instance { get; private set; }
///
public IEnumerable GetPages()
{
return
[
new PluginPageInfo
{
Name = Name,
EmbeddedResourcePath = string.Format(CultureInfo.InvariantCulture, "{0}.Configuration.configPage.html", GetType().Namespace)
}
];
}
}
```
--------------------------------
### Create Web Configuration UI with HTML and Jellyfin Components
Source: https://context7.com/jellyfin/jellyfin-plugin-template/llms.txt
This HTML snippet defines the user interface for a plugin's configuration page. It utilizes Jellyfin's custom web components (like emby-input, emby-button, emby-select, emby-checkbox) for consistent styling and functionality. The embedded JavaScript fetches existing configurations using ApiClient and updates them upon form submission.
```html
Template
```
--------------------------------
### Configure .NET Project for Jellyfin Plugin
Source: https://context7.com/jellyfin/jellyfin-plugin-template/llms.txt
This XML configuration sets up a .NET project for a Jellyfin plugin. It targets .NET 9.0, includes Jellyfin core packages, excludes runtime assets to prevent conflicts, and embeds HTML resources.
```xml
net9.0Jellyfin.Plugin.TemplatetruetrueenableAllEnabledByDefault../jellyfin.rulesetruntimeruntime
```
--------------------------------
### Define Jellyfin Plugin Configuration Options
Source: https://context7.com/jellyfin/jellyfin-plugin-template/llms.txt
Defines the persistent configuration options for a Jellyfin plugin by extending BasePluginConfiguration. This class structures settings like booleans, integers, strings, and enums, which Jellyfin automatically serializes and persists.
```csharp
using MediaBrowser.Model.Plugins;
namespace Jellyfin.Plugin.Template.Configuration;
///
/// The configuration options.
///
public enum SomeOptions
{
///
/// Option one.
///
OneOption,
///
/// Second option.
///
AnotherOption
}
///
/// Plugin configuration.
///
public class PluginConfiguration : BasePluginConfiguration
{
///
/// Initializes a new instance of the class.
///
public PluginConfiguration()
{
// set default options here
Options = SomeOptions.AnotherOption;
TrueFalseSetting = true;
AnInteger = 2;
AString = "string";
}
///
/// Gets or sets a value indicating whether some true or false setting is enabled..
///
public bool TrueFalseSetting { get; set; }
///
/// Gets or sets an integer setting.
///
public int AnInteger { get; set; }
///
/// Gets or sets a string setting.
///
public string AString { get; set; }
///
/// Gets or sets an enum option.
///
public SomeOptions Options { get; set; }
}
```
--------------------------------
### Manage Jellyfin Plugin Configuration (JavaScript)
Source: https://github.com/jellyfin/jellyfin-plugin-template/blob/master/Jellyfin.Plugin.Template/Configuration/configPage.html
This JavaScript code manages the Jellyfin plugin configuration. It fetches the current plugin settings on page load and updates them when the form is submitted. It relies on the Dashboard API and ApiClient for interacting with Jellyfin.
```javascript
var TemplateConfig = { pluginUniqueId: 'eb5d7894-8eef-4b36-aa6f-5d124e828ce1' };
document.querySelector('#TemplateConfigPage')
.addEventListener('pageshow', function() {
Dashboard.showLoadingMsg();
ApiClient.getPluginConfiguration(TemplateConfig.pluginUniqueId).then(function (config) {
document.querySelector('#Options').value = config.Options;
document.querySelector('#AnInteger').value = config.AnInteger;
document.querySelector('#TrueFalseSetting').checked = config.TrueFalseSetting;
document.querySelector('#AString').value = config.AString;
Dashboard.hideLoadingMsg();
});
});
document.querySelector('#TemplateConfigForm')
.addEventListener('submit', function(e) {
Dashboard.showLoadingMsg();
ApiClient.getPluginConfiguration(TemplateConfig.pluginUniqueId).then(function (config) {
config.Options = document.querySelector('#Options').value;
config.AnInteger = document.querySelector('#AnInteger').value;
config.TrueFalseSetting = document.querySelector('#TrueFalseSetting').checked;
config.AString = document.querySelector('#AString').value;
ApiClient.updatePluginConfiguration(TemplateConfig.pluginUniqueId, config).then(function (result) {
Dashboard.processPluginConfigurationUpdateResult(result);
});
});
e.preventDefault();
return false;
});
```
=== COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.