Compare commits

...

44 Commits

Author SHA1 Message Date
DarkFighterLuke 604ed24f7c Update version 2024-04-18 21:51:33 +02:00
DarkFighterLuke eefdd2a635 Merge pull request #2 from ThisIsHetz/ThisIsHetz-Patch-1
Add fix for unclosed HTML breaks
2024-04-18 21:36:19 +02:00
Patrick Hetz 30715d5c26 Add fix for unclosed HTML breaks
This changes the order of operations, truncating description before
replacing newlines with HTML breaks, to prevent the creation of unclosed
breaks which may otherwise cause rendering issues in Jellyfin.
2024-04-18 07:29:42 -04:00
DarkFighterLuke c12340583e Change old repository references 2024-04-17 23:01:33 +02:00
DarkFighterLuke a9b335f797 Update README.md
Delete references to old tubearchivist-jf
2024-04-17 22:59:23 +02:00
DarkFighterLuke 6d5c0b86b2 Update README.md
Update references to point to the new repository
2024-04-17 22:48:55 +02:00
DarkFighterLuke 347b2131db Merge branch 'master' of github.com:DarkFighterLuke/TubeArchivistMetadata 2024-03-15 10:15:32 +01:00
DarkFighterLuke 5a7b43f6e9 Add new version 2024-03-15 10:15:19 +01:00
DarkFighterLuke 6f6cb3dab6 Fix bug on description length substringing 2024-03-15 10:11:25 +01:00
DarkFighterLuke 80b236d643 Update README.md 2024-03-14 22:11:26 +01:00
DarkFighterLuke 8b491ee673 Add new version 2024-03-14 21:51:12 +01:00
DarkFighterLuke 7e6a757aa1 Make maximum description length configurable 2024-03-14 21:47:12 +01:00
DarkFighterLuke c3b2512f6a Truncate descriptions to 500 characters 2024-03-14 21:26:53 +01:00
DarkFighterLuke df36579616 Add new version 2024-03-14 20:01:06 +01:00
DarkFighterLuke 46088c2373 Add episodes and series overview 2024-03-14 19:56:23 +01:00
DarkFighterLuke f9a82e2109 Update manifest 2024-03-14 16:40:43 +01:00
DarkFighterLuke 7436c8643c Fix URL by removing trailing slash for images 2024-03-14 16:34:12 +01:00
DarkFighterLuke c1969a949c Handle empty tags for videos and channels 2024-03-14 15:38:50 +01:00
DarkFighterLuke a2429c89ff Update version 2024-03-13 21:52:54 +01:00
DarkFighterLuke 06860f43fc Update checksum 2024-03-13 21:35:12 +01:00
DarkFighterLuke d03ee06947 Merge branch 'master' of github.com:DarkFighterLuke/TubeArchivistMetadata
manifest.json
2024-03-13 15:27:34 +01:00
DarkFighterLuke a3cf4564b4 Fix image URL 2024-03-13 15:26:05 +01:00
DarkFighterLuke 57263ee789 Fix image URL 2024-03-13 15:22:55 +01:00
DarkFighterLuke 313a53fe44 Add new version 2024-03-13 15:07:32 +01:00
DarkFighterLuke 3514ab34d4 Fix field name and add placeholders 2024-03-13 11:48:18 +01:00
DarkFighterLuke 23e4c38944 Fix URL in logs after redirection 2024-03-13 11:36:50 +01:00
DarkFighterLuke 78564eea98 Add schema to TubeArchivist URL if not present in settings 2024-03-13 11:36:21 +01:00
DarkFighterLuke 2c33e28d36 Fix a particular case 2024-03-13 10:47:21 +01:00
DarkFighterLuke 4fdd41ed0f Log configuration settings at initialization 2024-03-13 10:32:14 +01:00
DarkFighterLuke 38d0b2c261 Sanitize URLs 2024-03-13 10:31:29 +01:00
DarkFighterLuke 6db6ee2ebb Update README.md banner 2024-03-12 10:37:11 +01:00
DarkFighterLuke 33ab2109ed Merge branch 'master' of github.com:DarkFighterLuke/TubeArchivistMetadata 2024-03-12 10:34:37 +01:00
DarkFighterLuke c6780ba66a Update checksum 2024-03-12 10:34:02 +01:00
DarkFighterLuke 84c5f7d00a New image 2024-03-12 10:31:32 +01:00
DarkFighterLuke f9a6edc7a5 Update README.md 2024-03-11 23:31:24 +01:00
DarkFighterLuke 7d8787bea9 Update checksum 2024-03-11 23:25:20 +01:00
DarkFighterLuke acb9be9b06 Update README.md 2024-03-11 23:14:07 +01:00
DarkFighterLuke 7ba2813105 Update checksum 2024-03-11 20:39:32 +01:00
DarkFighterLuke 9aa49ece01 Update checksum 2024-03-11 20:36:34 +01:00
DarkFighterLuke b45eb0ce52 Update checksum 2024-03-11 17:21:28 +01:00
DarkFighterLuke 039786e1d7 Update manifest 2024-03-11 16:49:23 +01:00
DarkFighterLuke a503714647 Merge branch 'master' of github.com:DarkFighterLuke/TubeArchivistMetadata 2024-03-11 16:43:37 +01:00
DarkFighterLuke dc7c30a55f Add image 2024-03-11 16:30:56 +01:00
DarkFighterLuke 24650861c0 Update checksum 2024-03-11 16:26:20 +01:00
19 changed files with 312 additions and 378 deletions
+7
View File
@@ -0,0 +1,7 @@
<Project>
<PropertyGroup>
<Version>1.2.3.0</Version>
<AssemblyVersion>1.2.3.0</AssemblyVersion>
<FileVersion>1.2.3.0</FileVersion>
</PropertyGroup>
</Project>
@@ -1,4 +1,8 @@
using System;
using System.Data;
using Jellyfin.Plugin.TubeArchivistMetadata.Utilities;
using MediaBrowser.Model.Plugins;
using Microsoft.Extensions.Logging;
namespace Jellyfin.Plugin.TubeArchivistMetadata.Configuration
{
@@ -7,14 +11,27 @@ namespace Jellyfin.Plugin.TubeArchivistMetadata.Configuration
/// </summary>
public class PluginConfiguration : BasePluginConfiguration
{
private ILogger _logger;
private string _tubeArchivistUrl;
/// <summary>
/// Initializes a new instance of the <see cref="PluginConfiguration"/> class.
/// </summary>
public PluginConfiguration()
{
CollectionTitle = "YouTube";
TubeArchivistUrl = string.Empty;
if (Plugin.Instance == null)
{
throw new DataException("Uninitialized plugin!");
}
else
{
_logger = Plugin.Instance.Logger;
}
CollectionTitle = string.Empty;
_tubeArchivistUrl = string.Empty;
TubeArchivistApiKey = string.Empty;
MaxDescriptionLength = 500;
}
/// <summary>
@@ -25,11 +42,35 @@ namespace Jellyfin.Plugin.TubeArchivistMetadata.Configuration
/// <summary>
/// Gets or sets TubeArchivist URL.
/// </summary>
public string TubeArchivistUrl { get; set; }
public string TubeArchivistUrl
{
get
{
return _tubeArchivistUrl;
}
set
{
if (value.StartsWith("http://", StringComparison.CurrentCulture) || value.StartsWith("https://", StringComparison.CurrentCulture))
{
_tubeArchivistUrl = Utils.SanitizeUrl(value);
}
else
{
_logger.LogInformation("{Message}", "Given TubeArchivist URL contains no schema. Adding http://...");
_tubeArchivistUrl = Utils.SanitizeUrl("http://" + value);
}
}
}
/// <summary>
/// Gets or sets TubeArchivist API key.
/// </summary>
public string TubeArchivistApiKey { get; set; }
/// <summary>
/// Gets or sets maximum series and episodes overviews length.
/// </summary>
public int MaxDescriptionLength { get; set; }
}
}
@@ -14,19 +14,24 @@
<form id="TemplateConfigForm">
<div class="inputContainer">
<label class="inputLabel inputLabelUnfocused" for="CollectionTitle">Collection Title</label>
<input id="CollectionTitle" name="CollectionTitle" type="text" is="emby-input" />
<input id="CollectionTitle" name="CollectionTitle" type="text" is="emby-input" placeholder="eg. YouTube" />
<div class="fieldDescription">TubeArchivist collection display name</div>
</div>
<div class="inputContainer">
<label class="inputLabel inputLabelUnfocused" for="TubeArchivistUrl">TubeArchivist URL</label>
<input id="TubeArchivistUrl" name="TubeArchivistUrl" type="text" is="emby-input" />
<div class="fieldDescription">TubeArchivist collection display name</div>
<input id="TubeArchivistUrl" name="TubeArchivistUrl" type="text" is="emby-input" placeholder="http://..." />
<div class="fieldDescription">TubeArchivist URL</div>
</div>
<div class="inputContainer">
<label class="inputLabel inputLabelUnfocused" for="TubeArchivistApiKey">TubeArchivist API key</label>
<input id="TubeArchivistApiKey" name="TubeArchivistApiKey" type="text" is="emby-input" />
<div class="fieldDescription">TubeArchivist API key</div>
</div>
<div class="inputContainer">
<label class="inputLabel inputLabelUnfocused" for="MaxDescriptionLength">Maximum overviews length</label>
<input id="MaxDescriptionLength" name="MaxDescriptionLength" type="number" is="emby-input" min="0" />
<div class="fieldDescription">This is the maximum length of the descriptions showed in series and episodes</div>
</div>
<div>
<button is="emby-button" type="submit" class="raised button-submit block emby-button">
<span>Save</span>
@@ -47,6 +52,7 @@
document.querySelector('#CollectionTitle').value = config.CollectionTitle;
document.querySelector('#TubeArchivistUrl').value = config.TubeArchivistUrl;
document.querySelector('#TubeArchivistApiKey').value = config.TubeArchivistApiKey;
document.querySelector('#MaxDescriptionLength').value = config.MaxDescriptionLength;
Dashboard.hideLoadingMsg();
});
});
@@ -58,6 +64,7 @@
config.CollectionTitle = document.querySelector('#CollectionTitle').value;
config.TubeArchivistUrl = document.querySelector('#TubeArchivistUrl').value;
config.TubeArchivistApiKey = document.querySelector('#TubeArchivistApiKey').value;
config.MaxDescriptionLength = document.querySelector('#MaxDescriptionLength').value;
ApiClient.updatePluginConfiguration(TAMetadataConfig.pluginUniqueId, config).then(function (result) {
Dashboard.processPluginConfigurationUpdateResult(result);
});
@@ -32,6 +32,8 @@ namespace Jellyfin.Plugin.TubeArchivistMetadata
handler.CheckCertificateRevocationList = true;
HttpClient = new HttpClient(handler);
HttpClient.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Token", Instance?.Configuration.TubeArchivistApiKey);
logger.LogInformation("{Message}", "Collection display name: " + Instance?.Configuration.CollectionTitle);
logger.LogInformation("{Message}", "TubeArchivist API URL: " + Instance?.Configuration.TubeArchivistUrl);
}
/// <inheritdoc />
@@ -7,6 +7,7 @@ using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
using Jellyfin.Plugin.TubeArchivistMetadata.TubeArchivist;
using Jellyfin.Plugin.TubeArchivistMetadata.Utilities;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.TV;
using MediaBrowser.Controller.Providers;
@@ -85,7 +86,7 @@ namespace Jellyfin.Plugin.TubeArchivistMetadata.Providers
}
else
{
return await Plugin.Instance.HttpClient.GetAsync(new Uri(Plugin.Instance.Configuration.TubeArchivistUrl + url), cancellationToken).ConfigureAwait(false);
return await Plugin.Instance.HttpClient.GetAsync(new Uri(Utils.SanitizeUrl(Plugin.Instance.Configuration.TubeArchivistUrl + url).TrimEnd('/')), cancellationToken).ConfigureAwait(false);
}
}
}
@@ -7,6 +7,7 @@ using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
using Jellyfin.Plugin.TubeArchivistMetadata.TubeArchivist;
using Jellyfin.Plugin.TubeArchivistMetadata.Utilities;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.TV;
using MediaBrowser.Controller.Providers;
@@ -97,7 +98,7 @@ namespace Jellyfin.Plugin.TubeArchivistMetadata.Providers
}
else
{
return await Plugin.Instance.HttpClient.GetAsync(url, cancellationToken).ConfigureAwait(false);
return await Plugin.Instance.HttpClient.GetAsync(new Uri(Utils.SanitizeUrl(Plugin.Instance.Configuration.TubeArchivistUrl + url).TrimEnd('/')), cancellationToken).ConfigureAwait(false);
}
}
}
@@ -7,6 +7,7 @@ using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
using Jellyfin.Plugin.TubeArchivistMetadata.TubeArchivist;
using Jellyfin.Plugin.TubeArchivistMetadata.Utilities;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.TV;
using MediaBrowser.Controller.Providers;
@@ -98,7 +99,7 @@ namespace Jellyfin.Plugin.TubeArchivistMetadata.Providers
}
else
{
return await Plugin.Instance.HttpClient.GetAsync(new Uri(Plugin.Instance.Configuration.TubeArchivistUrl + url), cancellationToken).ConfigureAwait(false);
return await Plugin.Instance.HttpClient.GetAsync(new Uri(Utils.SanitizeUrl(Plugin.Instance.Configuration.TubeArchivistUrl + url).TrimEnd('/')), cancellationToken).ConfigureAwait(false);
}
}
}
@@ -7,6 +7,7 @@ using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
using Jellyfin.Plugin.TubeArchivistMetadata.TubeArchivist;
using Jellyfin.Plugin.TubeArchivistMetadata.Utilities;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.TV;
using MediaBrowser.Controller.Providers;
@@ -97,7 +98,7 @@ namespace Jellyfin.Plugin.TubeArchivistMetadata.Providers
}
else
{
return await Plugin.Instance.HttpClient.GetAsync(url, cancellationToken).ConfigureAwait(false);
return await Plugin.Instance.HttpClient.GetAsync(new Uri(Utils.SanitizeUrl(Plugin.Instance.Configuration.TubeArchivistUrl + url).TrimEnd('/')), cancellationToken).ConfigureAwait(false);
}
}
}
@@ -1,6 +1,7 @@
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using Jellyfin.Plugin.TubeArchivistMetadata.Utilities;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.TV;
using MediaBrowser.Model.Entities;
@@ -70,6 +71,7 @@ namespace Jellyfin.Plugin.TubeArchivistMetadata.TubeArchivist
/// Gets channel tags.
/// </summary>
[JsonProperty(PropertyName = "channel_tags")]
[JsonConverter(typeof(TagsJsonConverter))]
public Collection<string> Tags { get; }
/// <summary>
@@ -108,6 +110,7 @@ namespace Jellyfin.Plugin.TubeArchivistMetadata.TubeArchivist
return new Series
{
Name = Name,
Overview = Utils.FormatDescription(Description),
Studios = new[] { Name },
ProviderIds = new Dictionary<string, string>()
{
@@ -0,0 +1,54 @@
using System;
using System.Collections.ObjectModel;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
namespace Jellyfin.Plugin.TubeArchivistMetadata.TubeArchivist
{
/// <summary>
/// Custom JsonConverter to handle tags list that could be null.
/// </summary>
public class TagsJsonConverter : JsonConverter
{
/// <inheritdoc/>
public override bool CanConvert(Type objectType)
{
return objectType == typeof(Collection<string>);
}
/// <inheritdoc/>
public override object? ReadJson(JsonReader reader, Type objectType, object? existingValue, JsonSerializer serializer)
{
JToken token = JToken.Load(reader);
var tags = new Collection<string>();
if (token.Type == JTokenType.Array)
{
var stringArray = token.ToObject<string[]>();
if (stringArray != null)
{
foreach (var tag in stringArray)
{
tags.Add(tag);
}
}
}
return tags;
}
/// <inheritdoc/>
public override void WriteJson(JsonWriter writer, object? value, JsonSerializer serializer)
{
var tags = (Collection<string>)(value ?? Array.Empty<string>());
writer.WriteStartArray();
foreach (var tag in tags)
{
writer.WriteValue(tag);
}
writer.WriteEndArray();
}
}
}
@@ -2,8 +2,8 @@ using System;
using System.Data;
using System.Net;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Threading.Tasks;
using Jellyfin.Plugin.TubeArchivistMetadata.Utilities;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
@@ -67,12 +67,13 @@ namespace Jellyfin.Plugin.TubeArchivistMetadata.TubeArchivist
ResponseContainer<Channel>? channel = null;
var channelsEndpoint = "/api/channel/";
var url = new Uri(Plugin.Instance?.Configuration.TubeArchivistUrl + channelsEndpoint + channelId);
var url = new Uri(Utils.SanitizeUrl(Plugin.Instance?.Configuration.TubeArchivistUrl + channelsEndpoint + channelId));
var response = await client.GetAsync(url).ConfigureAwait(true);
while (response.StatusCode == HttpStatusCode.Moved)
{
_logger.LogInformation("{Message}", "Received redirect to: " + response.Headers.Location);
response = await client.GetAsync(response.Headers.Location).ConfigureAwait(true);
url = response.Headers.Location;
_logger.LogInformation("{Message}", "Received redirect to: " + url);
response = await client.GetAsync(url).ConfigureAwait(true);
}
_logger.LogInformation("{Message}", url + ": " + response.StatusCode);
@@ -96,12 +97,13 @@ namespace Jellyfin.Plugin.TubeArchivistMetadata.TubeArchivist
ResponseContainer<Video>? video = null;
var videosEndpoint = "/api/video/";
var url = new Uri(Plugin.Instance?.Configuration.TubeArchivistUrl + videosEndpoint + videoId);
var url = new Uri(Utils.SanitizeUrl(Plugin.Instance?.Configuration.TubeArchivistUrl + videosEndpoint + videoId));
var response = await client.GetAsync(url).ConfigureAwait(true);
while (response.StatusCode == HttpStatusCode.Moved)
{
_logger.LogInformation("{Message}", "Received redirect to: " + response.Headers.Location);
response = await client.GetAsync(response.Headers.Location).ConfigureAwait(true);
url = response.Headers.Location;
_logger.LogInformation("{Message}", "Received redirect to: " + url);
response = await client.GetAsync(url).ConfigureAwait(true);
}
_logger.LogInformation("{Message}", url + ": " + response.StatusCode);
@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Globalization;
using System.Linq;
using Jellyfin.Plugin.TubeArchivistMetadata.Utilities;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.TV;
using MediaBrowser.Model.Entities;
@@ -54,6 +55,7 @@ namespace Jellyfin.Plugin.TubeArchivistMetadata.TubeArchivist
/// Gets video tags.
/// </summary>
[JsonProperty(PropertyName = "tags")]
[JsonConverter(typeof(TagsJsonConverter))]
public Collection<string> Tags { get; }
/// <summary>
@@ -112,6 +114,7 @@ namespace Jellyfin.Plugin.TubeArchivistMetadata.TubeArchivist
return new Episode
{
Name = Title,
Overview = Utils.FormatDescription(Description),
SeasonName = Published.Year.ToString(CultureInfo.CurrentCulture),
ParentIndexNumber = Published.Year,
SeriesName = Channel.Name,
@@ -0,0 +1,57 @@
using System.Text.RegularExpressions;
namespace Jellyfin.Plugin.TubeArchivistMetadata.Utilities
{
/// <summary>
/// Class containing common utils.
/// </summary>
public static class Utils
{
/// <summary>
/// Sanitize the given URL.
/// </summary>
/// <param name="inputUrl">An URL string.</param>
/// <returns>The URL string without spaces, doubled slashes and with a trailing slash.</returns>
public static string SanitizeUrl(string inputUrl)
{
// Extract the schema part
Match schemaMatch = Regex.Match(inputUrl, @"^(?<schema>https?://)");
// Remove double slashes and spaces from the remaining part of the URL
string cleanedPath = Regex.Replace(inputUrl.Substring(schemaMatch.Length), @"[/\s]+", "/");
// Remove slashes at the start
cleanedPath = cleanedPath.TrimStart('/');
// Add a trailing slash if not already present
cleanedPath = cleanedPath.TrimEnd('/') + "/";
// Combine the schema and cleaned path
string cleanedUrl = schemaMatch.Groups["schema"].Value + cleanedPath;
return cleanedUrl;
}
/// <summary>
/// Format episodes and series descriptions replacing newlines with br tags.
/// </summary>
/// <param name="description">String to format.</param>
/// <returns>A string with \n replaced by br tags.</returns>
public static string FormatDescription(string description)
{
var maxLength = 500;
if (Plugin.Instance != null)
{
maxLength = Plugin.Instance.Configuration.MaxDescriptionLength;
}
if (description.Length > maxLength)
{
description = description.Substring(0, maxLength);
description = description.Replace("\n", "<br>", System.StringComparison.CurrentCulture);
}
return description;
}
}
}
+58 -353
View File
@@ -1,373 +1,78 @@
# So you want to make a Jellyfin plugin
<h1 align="center">Jellyfin TubeArchivist Plugin</h1>
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 net6.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.
<p align="center">
<img alt="Plugin Banner" src="https://raw.githubusercontent.com/tubearchivist/tubearchivist-jf-plugin/master/images/logo.png"/>
<br/>
</p>
## 0. Things you need to get started
## About
- [Dotnet SDK 6.0](https://dotnet.microsoft.com/download)
<p>This plugin adds the metadata provider for <a href="https://www.tubearchivist.com/">TubeArchivist</a>, offering improved flexibility and native integration with Jellyfin compared to previous solutions.</p>
- An editor of your choice. Some free choices are:
## How it works
The media organization is a `Shows` collection, where each channel is a show and its videos are the episodes, organized in seasons by year.<br>
The plugin interacts with TubeArchivist APIs to fetch videos and channels metadata.
[Visual Studio Code](https://code.visualstudio.com)
### Features
- Add metadata for videos (episodes)
- Add metadata for channels (shows)
- Add images for videos (episodes), ie. thumb images
- Add images for channels (shows), ie. thumb, tvart and banner images
- Organize videos (episodes) by year (seasons)
[Visual Studio Community Edition](https://visualstudio.microsoft.com/downloads)
## Installation
### From official repository (recommended)
1. Go to `Dashboard -> Plugins` and select the `Repositories` tab
2. Add a new repository with the following details:
- Repository name: `TubeArchivistMetadata`
- Repository URL: `https://github.com/tubearchivist/tubearchivist-jf-plugin/raw/master/manifest.json`
![Add repository](https://github.com/tubearchivist/tubearchivist-jf-plugin/assets/31162436/b0216b21-79c4-445b-8cf1-fbf6b138dee0)
[Mono Develop](https://www.monodevelop.com)
3. Go to the `Catalog` tab
4. Find `TubeArchivistMetadata` in the `Metadata` section and install it
![Find plugin](https://github.com/tubearchivist/tubearchivist-jf-plugin/assets/31162436/86897215-bac5-4cef-8bd3-ffec731b0875)
5. Restart Jellyfin to apply the changes
## 0.5. Quickstarts
### From ZIP in GitHub releases
1. Download the latest available release (`TubeArchivistMetadata-*.zip`) from the repository releases section
2. Extract the contained files in the `plugins/TubeArchivistMetadata` folder (you might need to create the folders) of your Jellyfin installation
3. Restart Jellyfin to apply the changes
We have a number of quickstart options available to speed you along the way.
## Configuration
<p>This plugin requires that you have already an instance of TubeArchivist up and running.</p>
Once installed, you have to configure the following parameters in the plugin configuration:
<ul>
<li>Collection display name</li>
<li>TubeArchivist instance address</li>
<li>TubeArchivist API key</li>
<li>Overviews length (channels and videos descriptions)</li>
</ul>
- [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)
![Plugin configuration](https://github.com/tubearchivist/tubearchivist-jf-plugin/assets/31162436/d34464ea-ddfb-44b3-9d3e-5d5974956c58)
- 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
```
## Use the plugin
<p>Using the plugin is very simple. Let's start from the beginning:</p>
- Run this command then skip to step 4
_NOTE: If you are using Docker containers, it is important to mount the TubeArchivist media path into Jellyfin container as **read-only**, in order to avoid possible operations on the media files that will break TubeArchivist._ <br>
1. Go to `Dashboard -> Libraries` and add a media library
2. In the form select `Shows` as Content type, set a display name for the library and set the TubeArchivist media folder in the `Folders` section
![Add library](https://github.com/tubearchivist/tubearchivist-jf-plugin/assets/31162436/1eca534e-0929-4134-8587-3cff0009f618)
```
dotnet new Jellyfin-plugin -name MyPlugin
```
4. Scrolling down, uncheck all metadata and image providers except `TubeArchivist`. (You won't find TubeArchivist in seasons providers, so just disable everything there)
5. Save and come back to Home, you will see the newly added library. Jellyfin will have executed the metadata fetching for you after the collection creation and then you will see the metadata and the images of channels and videos
If you'd rather start from scratch keep going on to step one. This assumes no specific editor or IDE and requires only the command line with dotnet in the path.
## Build
## 1. Initialize Your Project
1. To build this plugin you will need [.Net 6.x](https://dotnet.microsoft.com/download/dotnet/6.0).
Make a new dotnet standard project with the following command, it will make a directory for itself.
2. Build plugin with following command
```
dotnet publish Jellyfin.Plugin.tubearchivist-jf-plugin --configuration Release --output bin
```
```
dotnet new classlib -f net6.0 -n MyJellyfinPlugin
```
3. Place the dll-file in the `plugins/tubearchivist-jf-plugin` folder (you might need to create the folders) of your Jellyfin installation
Now add the Jellyfin shared libraries.
## License
```
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. Set Up the Basics
There are a few mandatory classes you'll need for a plugin so we need to make them.
### PluginConfiguration
You can call it whatever you'd like really. 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`
### 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 section.
```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`, `[guid]::NewGuid()` 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}'
```
or
```bash
uuidgen
```
- 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.
### 4a. Implement Interfaces
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
- **IIntroProvider** - Allows you to play a piece of media before another piece of media (i.e. a trailer before a movie, or a network bumper before an episode of a show)
- **IItemResolver** - Allows you to define custom media types
- **ILibraryPostScanTask** - Allows you to define a task that fires after scanning a library
- **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://docs.jellyfin.org/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 and classes 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.
- **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. **Be aware that your main plugin class (IBasePlugin) cannot also be a IServerEntryPoint.**
- **ControllerBase** - Allows you to define custom REST-API endpoints. This is the default ASP.NET Web-API controller. You can use it exactly as you would in a normal Web-API project. Learn more about it [here](https://docs.microsoft.com/aspnet/core/web-api/?view=aspnetcore-5.0).
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
- **ILibraryManager** - Allows you to directly access the media libraries without hopping through the API
- **ILocalizationManager** - Allows you tap into the main localization engine which governs translations, rating systems, units etc...
- **INetworkManager** - Allows you to get information about the server's networking status
- **IServerApplicationPaths** - Allows you to get the running server's paths
- **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
- **IZipClient** - Allows you to use the core zip client for compressing and decompressing data
## 5. Create a Repository
- [See blog post](https://jellyfin.org/posts/plugin-updates/)
## 6. Set Up Debugging
Debugging can be set up by creating tasks which will be executed when running the plugin project. The specifics on setting up these tasks are not included as they may differ from IDE to IDE. The following list describes the general process:
- Compile the plugin in debug mode.
- Create the plugin directory if it doesn't exist.
- Copy the plugin into your server's plugin directory. The server will then execute it.
- Make sure to set the working directory of the program being debugged to the working directory of the Jellyfin Server.
- Start the server.
Some IDEs like Visual Studio Code may need the following compile flags to compile the plugin:
```shell
dotnet build Your-Plugin.sln /property:GenerateFullPaths=true /consoleloggerparameters:NoSummary
```
These flags generate the full paths for file names and **do not** generate a summary during the build process as this may lead to duplicate errors in the problem panel of your IDE.
### 6.a Set Up Debugging on Visual Studio
Visual Studio allows developers to connect to other processes and debug them, setting breakpoints and inspecting the variables of the program. We can set this up following this steps:
On this section we will explain how to set up our solution to enable debugging before the server starts.
1. Right-click on the solution, And click on Add -> Existing Project...
2. Locate Jellyfin executable in your installation folder and click on 'Open'. It is called `Jellyfin.exe`. Now The solution will have a new "Project" called Jellyfin. This is the executable, not the source code of Jellyfin.
3. Right-click on this new project and click on 'Set up as Startup Project'
4. Right-click on this new project and click on 'Properties'
5. Make sure that the 'Attach' parameter is set to 'No'
From now on, everytime you click on start from Visual Studio, it will start Jellyfin attached to the debugger!
The only thing left to do is to compile the project as it is specified a few lines above and you are done.
### 6.b Automate the Setup on Visual Studio Code
Visual Studio Code allows developers to automate the process of starting all necessary dependencies to start debugging the plugin. This guide assumes the reader is familiar with the [documentation on debugging in Visual Studio Code](https://code.visualstudio.com/docs/editor/debugging) and has read the documentation in this file. It is assumed that the Jellyfin Server has already been compiled once. However, should one desire to automatically compile the server before the start of the debugging session, this can be easily implemented, but is not further discussed here.
A full example, which aims to be portable may be found in this repo's `.vscode` folder.
This example expects you to clone `jellyfin`, `jellyfin-web` and `jellyfin-plugin-template` under the same parent directory, though you can customize this in `settings.json`
1. Create a `settings.json` file inside your `.vscode` folder, to specify common options specific to your local setup.
```jsonc
{
// 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",
}
```
1. To automate the launch process, create a new `launch.json` file for C# projects inside the `.vscode` folder. The example below shows only the relevant parts of the file. Adjustments to your specific setup and operating system may be required.
```jsonc
{
// 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/net6.0/jellyfin.dll",
"args": [
//"--nowebclient"
"--webdir",
"${config:jellyfinWebDir}/dist/"
],
"cwd": "${config:jellyfinDir}",
}
]
}
```
The `request` type is specified as `launch`, as this `launch.json` file will start the Jellyfin Server process. The `preLaunchTask` defines a task that will run before the Jellyfin Server starts. More on this later. It is important to set the `program` path to the Jellyin Server program and set the current working directory (`cwd`) to the working directory of the Jellyfin Server.
The `args` option allows to specify arguments to be passed to the server, e.g. whether Jellyfin should start with the web-client or without it.
2. Create a `tasks.json` file inside your `.vscode` folder and specify a `build-and-copy` task that will run in `sequence` order. This tasks depends on multiple other tasks and all of those other tasks can be defined as simple `shell` tasks that run commands like the `cp` command to copy a file. The sequence to run those tasks in is given below. Please note that it might be necessary to adjust the examples for your specific setup and operating system.
The full file is shown here - Specific sections will be discussed in depth
```jsonc
{
// 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",
"command": "mkdir",
"args": [
"-Force",
"-Path",
"${config:jellyfinDataDir}/plugins/${config:pluginName}/"
]
},
{
// 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/net6.0/publish/*",
"${config:jellyfinDataDir}/plugins/${config:pluginName}/"
]
},
]
}
```
1. The "build-and-copy" task which triggers all of the other tasks
```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"]
},
```
2. A build task. This task builds the plugin without generating summary, but with full paths for file names enabled.
```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"
},
```
3. A tasks which creates the necessary plugin directory and a sub-folder for the specific plugin. The plugin directory is located below the [data directory](https://jellyfin.org/docs/general/administration/configuration.html) of the Jellyfin Server. As an example, the following path can be used for the bookshelf plugin: `$HOME/.local/share/jellyfin/plugins/Bookshelf/`
```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}/"
]
},
```
4. A tasks which copies the plugin dll which has been built in step 2.1. The file is copied into it's specific plugin directory within the server's plugin directory.
```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/net6.0/publish/*",
"${config:jellyfinDataDir}/plugins/${config:pluginName}/"
]
},
```
## Licensing
Licensing is a complex topic. This repository features a GPLv3 license template that can be used to provide a good default license for your plugin. You may alter this if you like, but if you do a permissive license must be chosen.
Due to how plugins in Jellyfin work, when your plugin is compiled into a binary, it will link against the various Jellyfin binary NuGet packages. These packages are licensed under the GPLv3. Thus, due to the nature and restrictions of the GPL, the binary plugin you get will also be licensed under the GPLv3.
If you accept the default GPLv3 license from this template, all will be good. However if you choose a different license, please keep this fact in mind, as it might not always be obvious that an, e.g. MIT-licensed plugin would become GPLv3 when compiled.
Please note that this also means making "proprietary", source-unavailable, or otherwise "hidden" plugins for public consumption is not permitted. To build a Jellyfin plugin for distribution to others, it must be under the GPLv3 or a permissive open-source license that can be linked against the GPLv3.
This plugins code and packages are distributed under the GPLv3 License. See [LICENSE](./LICENSE) for more information.
+2 -2
View File
@@ -1,7 +1,7 @@
---
name: "TubeArchivistMetadata"
guid: "dc97d0c6-28b0-4242-afb4-5833ae1b3715"
version: "1.0.0.0"
version: "1.2.3.0"
targetAbi: "10.8.0.0"
framework: "net6.0"
overview: "Metadata for your TubeArchivist library on Jellyfin"
@@ -13,4 +13,4 @@ owner: "DarkFighterLuke"
artifacts:
- "Jellyfin.Plugin.TubeArchivistMetadata.dll"
changelog: >
First release
Add fix for unclosed HTML breaks
Binary file not shown.
BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 65 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 289 KiB

+55 -6
View File
@@ -5,15 +5,64 @@
"name": "TubeArchivistMetadata",
"description": "A new and fully integrated way to manage metadata and organize your TubeArchivist library videos on Jellyfin.",
"owner": "DarkFighterLuke",
"overview": "Metadata for your TubeArchivist library on Jellyfin.",
"overview": "Metadata for your TubeArchivist library on Jellyfin",
"imageUrl": "https://raw.githubusercontent.com/tubearchivist/tubearchivist-jf-plugin/master/images/logo.png",
"versions": [
{
"checksum": "07c81d5b5359b018ca251646d81910f5",
"changelog": "First release",
"version": "1.2.3.0",
"changelog": "Add fix for unclosed HTML breaks\n",
"targetAbi": "10.8.0.0",
"sourceUrl": "https://github.com/DarkFighterLuke/TubeArchivistMetadata/releases/download/v1.0.1/TubeArchivistMetadata-1.0.0.zip",
"timestamp": "2024-03-11 16:02:00",
"version": "1.0.0.0"
"sourceUrl": "https://github.com/tubearchivist/tubearchivist-jf-plugin/releases/download/v1.2.3/TubeArchivistMetadata-1.2.3.zip",
"checksum": "f5328a662444739eaa7c59855bfcb203",
"timestamp": "2024-04-18 21:45:00"
},
{
"version": "1.2.2.0",
"changelog": "Fix bug on description length substringing\n",
"targetAbi": "10.8.0.0",
"sourceUrl": "https://github.com/tubearchivist/tubearchivist-jf-plugin/releases/download/v1.2.2/TubeArchivistMetadata-1.2.2.zip",
"checksum": "82d04546916e1ba76d56de28e648447a",
"timestamp": "2024-03-15 10:12:00"
},
{
"version": "1.2.1.0",
"changelog": "Make maximum description length configurable\nTruncate descriptions to 500 characters\n",
"targetAbi": "10.8.0.0",
"sourceUrl": "https://github.com/tubearchivist/tubearchivist-jf-plugin/releases/download/v1.2.1/TubeArchivistMetadata-1.2.1.zip",
"checksum": "cf68d169956f166a6ee68a06192651c2",
"timestamp": "2024-03-14 21:50:00"
},
{
"version": "1.2.0.0",
"changelog": "Add episodes and series overview\n",
"targetAbi": "10.8.0.0",
"sourceUrl": "https://github.com/tubearchivist/tubearchivist-jf-plugin/releases/download/v1.2.0/TubeArchivistMetadata-1.2.0.zip",
"checksum": "75812a4464bf68c43fb9dcdb74d924e3",
"timestamp": "2024-03-14 20:00:00"
},
{
"version": "1.1.1.0",
"changelog": "Handle empty tags for videos and channels\nFix URL by removing trailing slash for images\n",
"targetAbi": "10.8.0.0",
"sourceUrl": "https://github.com/tubearchivist/tubearchivist-jf-plugin/releases/download/v1.1.1/TubeArchivistMetadata-1.1.1.zip",
"checksum": "84ce752ce662e834690512c88ba48664",
"timestamp": "2024-03-14 16:35:00"
},
{
"version": "1.1.0.0",
"changelog": "Fix field name and add placeholders\nFix URL in logs after redirection\nAdd schema to TubeArchivist URL if not present in settings\nFix a particular case\nLog configuration settings at initialization\nSanitize URLs\n",
"targetAbi": "10.8.0.0",
"sourceUrl": "https://github.com/tubearchivist/tubearchivist-jf-plugin/releases/download/v1.1.0/TubeArchivistMetadata-1.1.0.zip",
"checksum": "de4b6562973b7f75b6afe3a441bb0e19",
"timestamp": "2024-03-13 15:02:00"
},
{
"version": "1.0.0.0",
"changelog": "First release\n",
"targetAbi": "10.8.0.0",
"sourceUrl": "https://github.com/tubearchivist/tubearchivist-jf-plugin/releases/download/v1.0.0/TubeArchivistMetadata-1.0.0.zip",
"checksum": "444f8980671de494b1875ee7d1657bcf",
"timestamp": "2024-03-11 16:02:00"
}
]
}