Source Code#

Our source code is documented using the standard documentation guidelines.

Source#

class Jellyfin.Plugin.Themerr.Configuration.PluginConfiguration : BasePluginConfiguration#

Inheritence diagram for Jellyfin::Plugin::Themerr::Configuration::PluginConfiguration:

digraph {
    graph [bgcolor="#00000000"]
    node [shape=rectangle style=filled fillcolor="#FFFFFF" font=Helvetica padding=2]
    edge [color="#1414CE"]
    "1" [label="Jellyfin.Plugin.Themerr.Configuration.PluginConfiguration" tooltip="Jellyfin.Plugin.Themerr.Configuration.PluginConfiguration" fillcolor="#BFBFBF"]
    "2" [label="BasePluginConfiguration" tooltip="BasePluginConfiguration"]
    "1" -> "2" [dir=forward tooltip="public-inheritance"]
}

Collaboration diagram for Jellyfin::Plugin::Themerr::Configuration::PluginConfiguration:

digraph {
    graph [bgcolor="#00000000"]
    node [shape=rectangle style=filled fillcolor="#FFFFFF" font=Helvetica padding=2]
    edge [color="#1414CE"]
    "1" [label="Jellyfin.Plugin.Themerr.Configuration.PluginConfiguration" tooltip="Jellyfin.Plugin.Themerr.Configuration.PluginConfiguration" fillcolor="#BFBFBF"]
    "2" [label="BasePluginConfiguration" tooltip="BasePluginConfiguration"]
    "1" -> "2" [dir=forward tooltip="public-inheritance"]
}

Initializes a new instance of the PluginConfiguration class.

Public Functions

PluginConfiguration ()#

Initializes a new instance of the PluginConfiguration class.

Properties

int? UpdateInterval { get; set; }#

Gets or sets the time between scheduled updates, in minutes.

Minimum value of 15.

Private Members

int _updateInterval#
class Jellyfin.Plugin.Themerr.Api.ThemerrController : ControllerBase#

Inheritence diagram for Jellyfin::Plugin::Themerr::Api::ThemerrController:

digraph {
    graph [bgcolor="#00000000"]
    node [shape=rectangle style=filled fillcolor="#FFFFFF" font=Helvetica padding=2]
    edge [color="#1414CE"]
    "2" [label="ControllerBase" tooltip="ControllerBase"]
    "1" [label="Jellyfin.Plugin.Themerr.Api.ThemerrController" tooltip="Jellyfin.Plugin.Themerr.Api.ThemerrController" fillcolor="#BFBFBF"]
    "1" -> "2" [dir=forward tooltip="public-inheritance"]
}

Collaboration diagram for Jellyfin::Plugin::Themerr::Api::ThemerrController:

digraph {
    graph [bgcolor="#00000000"]
    node [shape=rectangle style=filled fillcolor="#FFFFFF" font=Helvetica padding=2]
    edge [color="#1414CE"]
    "2" [label="ControllerBase" tooltip="ControllerBase"]
    "1" [label="Jellyfin.Plugin.Themerr.Api.ThemerrController" tooltip="Jellyfin.Plugin.Themerr.Api.ThemerrController" fillcolor="#BFBFBF"]
    "1" -> "2" [dir=forward tooltip="public-inheritance"]
}

The Themerr api controller.

Public Functions

ActionResult GetProgress (int page = 1, int pageSize = 10)#

Get the data required to populate the progress dashboard.

Loop over all Jellyfin libraries and supported items, creating a json object with the following structure: { “items”: [BaseItems], “media_count”: BaseItems.Count, “media_percent_complete”: ThemedItems.Count / BaseItems.Count * 100, }

Param page:

The page number to return.

Param pageSize:

The number of items to return per page.

Return:

JSON object containing progress data.

ActionResult GetTranslations ()#

Get the localization strings from Locale/{selected_locale}.json.

Return:

JSON object containing localization strings.

ThemerrController (IApplicationPaths applicationPaths, ILibraryManager libraryManager, ILogger<ThemerrController> logger, IServerConfigurationManager configurationManager, ILoggerFactory loggerFactory, IXmlSerializer xmlSerializer)#

Initializes a new instance of the ThemerrController class.

Param applicationPaths:

The application paths.

Param libraryManager:

The library manager.

Param logger:

The logger.

Param configurationManager:

The configuration manager.

Param loggerFactory:

The logger factory.

Param xmlSerializer:

The XML serializer.

async Task TriggerUpdateRequest ()#

Trigger an update from the configuration html page.

A response code of 204 indicates that the download has started successfully.

Return:

A NoContentResult indicating success.

Private Members

readonly IServerConfigurationManager _configurationManager#
readonly ILogger<ThemerrController> _logger#
readonly ThemerrManager _themerrManager#
class Jellyfin.Plugin.Themerr.ThemerrManager : BasePlugin<PluginConfiguration>, IDisposable#

Inheritence diagram for Jellyfin::Plugin::Themerr::ThemerrManager:

digraph {
    graph [bgcolor="#00000000"]
    node [shape=rectangle style=filled fillcolor="#FFFFFF" font=Helvetica padding=2]
    edge [color="#1414CE"]
    "3" [label="IDisposable" tooltip="IDisposable"]
    "2" [label="BasePlugin< PluginConfiguration >" tooltip="BasePlugin< PluginConfiguration >"]
    "1" [label="Jellyfin.Plugin.Themerr.ThemerrManager" tooltip="Jellyfin.Plugin.Themerr.ThemerrManager" fillcolor="#BFBFBF"]
    "1" -> "2" [dir=forward tooltip="public-inheritance"]
    "1" -> "3" [dir=forward tooltip="public-inheritance"]
}

Collaboration diagram for Jellyfin::Plugin::Themerr::ThemerrManager:

digraph {
    graph [bgcolor="#00000000"]
    node [shape=rectangle style=filled fillcolor="#FFFFFF" font=Helvetica padding=2]
    edge [color="#1414CE"]
    "3" [label="IDisposable" tooltip="IDisposable"]
    "2" [label="BasePlugin< PluginConfiguration >" tooltip="BasePlugin< PluginConfiguration >"]
    "1" [label="Jellyfin.Plugin.Themerr.ThemerrManager" tooltip="Jellyfin.Plugin.Themerr.ThemerrManager" fillcolor="#BFBFBF"]
    "1" -> "2" [dir=forward tooltip="public-inheritance"]
    "1" -> "3" [dir=forward tooltip="public-inheritance"]
}

The main entry point for the plugin.

Public Functions

bool ContinueDownload (string themePath, string themerrDataPath)#

Check if the theme song should be downloaded.

Various checks are performed to determine if the theme song should be downloaded.

Param themePath:

The path to the theme song.

Param themerrDataPath:

The path to the themerr data file.

Return:

True to continue with downloaded, false otherwise.

Create a link to the themerr database.

Param tmdbId:

The tmdb id.

Param dbType:

The database type.

Return:

The themerr database link.

void Dispose ()#

Cleanup.

List<string> GetCultureResource (string culture)#

Get the resources of the given culture.

Param culture:

The culture to get the resource for.

Return:

A list of file names.

string GetExistingThemerrDataValue (string key, string themerrDataPath)#

Get a value from the themerr data file if it exists.

Param key:

The key to search for.

Param themerrDataPath:

The path to the themerr data file.

Return:

The value of the key if it exists, null otherwise.

string GetIssueUrl (BaseItem item)#

Get ThemerrDB issue url.

This url can be used to easily add/edit theme songs in ThemerrDB.

Param item:

The Jellyfin media object.

Return:

The ThemerrDB issue url.

string GetMd5Hash (string filePath)#

Get the MD5 hash of a file.

Param filePath:

The file path.

Return:

The MD5 hash of the file.

string GetThemePath (BaseItem item)#

Get the path to the theme song.

Param item:

The Jellyfin media object.

Return:

The path to the theme song.

string GetThemeProvider (BaseItem item)#

Get the theme provider.

Param item:

The Jellyfin media object.

Return:

The theme provider.

string GetThemerrDataPath (BaseItem item)#

Get the path to the themerr data file.

Param item:

The Jellyfin media object.

Return:

The path to the themerr data file.

string GetTmdbId (BaseItem item)#

Get TMDB id from an item.

Param item:

The Jellyfin media object.

Return:

TMDB id.

IEnumerable<BaseItem> GetTmdbItemsFromLibrary ()#

Get all supported items from the library that have a tmdb id.

Return:

List of BaseItem objects.

string GetYoutubeThemeUrl (string themerrDbUrl, BaseItem item)#

Get the YouTube theme url from the themerr database.

Param themerrDbUrl:

The themerr database url.

Param item:

The Jellyfin media object.

Return:

The YouTube theme url.

void ProcessItemTheme (BaseItem item)#

Download the theme song for a media item if it doesn’t already exist.

Param item:

The Jellyfin media object.

Task RunAsync ()#

Run the task, asynchronously.

Return:

A Task representing the asynchronous operation.

bool SaveMp3 (string destination, string videoUrl)#

Save a mp3 file from a YouTube video url.

Param destination:

The destination path.

Param videoUrl:

The YouTube video url.

Return:

True if the file was saved successfully, false otherwise.

bool SaveThemerrData (string themePath, string themerrDataPath, string youtubeThemeUrl)#

Save the themerr data file.

Param themePath:

The path to the theme song.

Param themerrDataPath:

The path to the themerr data file.

Param youtubeThemeUrl:

The YouTube theme url.

Return:

True if the file was saved successfully, false otherwise.

ThemerrManager (IApplicationPaths applicationPaths, ILibraryManager libraryManager, ILogger<ThemerrManager> logger, IXmlSerializer xmlSerializer)#

Initializes a new instance of the ThemerrManager class.

Param applicationPaths:

The application paths.

Param libraryManager:

The library manager.

Param logger:

The logger.

Param xmlSerializer:

The XML serializer.

Task UpdateAll ()#

Enumerate through all supported items in the library and downloads their theme songs as required.

Return:

A Task representing the asynchronous operation.

bool WaitForFile (string filePath, int timeout)#

Wait for file to exist on disk and is not locked by another process.

Param filePath:

The file path to check.

Param timeout:

The maximum amount of time (in milliseconds) to wait.

Return:

True if the file exists and is not locked, false otherwise.

Properties

override string Name { get; set; }#

Gets the plugin instance.

Private Functions

void OnTimerElapsed ()#

Called when the plugin is loaded.

Private Members

readonly ILibraryManager _libraryManager#
readonly ILogger<ThemerrManager> _logger#
readonly Timer _timer#
class Jellyfin.Plugin.Themerr.ThemerrPlugin : BasePlugin<PluginConfiguration>, IHasWebPages#

Inheritence diagram for Jellyfin::Plugin::Themerr::ThemerrPlugin:

digraph {
    graph [bgcolor="#00000000"]
    node [shape=rectangle style=filled fillcolor="#FFFFFF" font=Helvetica padding=2]
    edge [color="#1414CE"]
    "1" [label="Jellyfin.Plugin.Themerr.ThemerrPlugin" tooltip="Jellyfin.Plugin.Themerr.ThemerrPlugin" fillcolor="#BFBFBF"]
    "3" [label="IHasWebPages" tooltip="IHasWebPages"]
    "2" [label="BasePlugin< PluginConfiguration >" tooltip="BasePlugin< PluginConfiguration >"]
    "1" -> "2" [dir=forward tooltip="public-inheritance"]
    "1" -> "3" [dir=forward tooltip="public-inheritance"]
}

Collaboration diagram for Jellyfin::Plugin::Themerr::ThemerrPlugin:

digraph {
    graph [bgcolor="#00000000"]
    node [shape=rectangle style=filled fillcolor="#FFFFFF" font=Helvetica padding=2]
    edge [color="#1414CE"]
    "1" [label="Jellyfin.Plugin.Themerr.ThemerrPlugin" tooltip="Jellyfin.Plugin.Themerr.ThemerrPlugin" fillcolor="#BFBFBF"]
    "3" [label="IHasWebPages" tooltip="IHasWebPages"]
    "2" [label="BasePlugin< PluginConfiguration >" tooltip="BasePlugin< PluginConfiguration >"]
    "1" -> "2" [dir=forward tooltip="public-inheritance"]
    "1" -> "3" [dir=forward tooltip="public-inheritance"]
}

The Themerr plugin class.

Public Functions

IEnumerable<PluginPageInfo> GetPages ()#

Get the plugin’s html config page.

Return:

Instance of the PluginPageInfo configuration page.

ThemerrPlugin (IApplicationPaths applicationPaths, IXmlSerializer xmlSerializer)#

Initializes a new instance of the ThemerrPlugin class.

Param applicationPaths:

Instance of the IApplicationPaths interface.

Param xmlSerializer:

Instance of the IXmlSerializer interface.

Properties

override string Description { get; set; }#

Gets the description of the plugin.

override Guid Id { get; set; }#

Gets the plugin instance id.

ThemerrPlugin Instance { get; set; }#

Gets the plugin instance.

override string Name { get; set; }#

Gets the name of the plugin.

Private Members

readonly Guid _id = new Guid("84b59a39-bde4-42f4-adbd-c39882cbb772")#
class Jellyfin.Plugin.Themerr.ScheduledTasks.ThemerrTasks : IScheduledTask#

Inheritence diagram for Jellyfin::Plugin::Themerr::ScheduledTasks::ThemerrTasks:

digraph {
    graph [bgcolor="#00000000"]
    node [shape=rectangle style=filled fillcolor="#FFFFFF" font=Helvetica padding=2]
    edge [color="#1414CE"]
    "1" [label="Jellyfin.Plugin.Themerr.ScheduledTasks.ThemerrTasks" tooltip="Jellyfin.Plugin.Themerr.ScheduledTasks.ThemerrTasks" fillcolor="#BFBFBF"]
    "2" [label="IScheduledTask" tooltip="IScheduledTask"]
    "1" -> "2" [dir=forward tooltip="public-inheritance"]
}

Collaboration diagram for Jellyfin::Plugin::Themerr::ScheduledTasks::ThemerrTasks:

digraph {
    graph [bgcolor="#00000000"]
    node [shape=rectangle style=filled fillcolor="#FFFFFF" font=Helvetica padding=2]
    edge [color="#1414CE"]
    "1" [label="Jellyfin.Plugin.Themerr.ScheduledTasks.ThemerrTasks" tooltip="Jellyfin.Plugin.Themerr.ScheduledTasks.ThemerrTasks" fillcolor="#BFBFBF"]
    "2" [label="IScheduledTask" tooltip="IScheduledTask"]
    "1" -> "2" [dir=forward tooltip="public-inheritance"]
}

The Themerr scheduled task.

Public Functions

async Task ExecuteAsync (IProgress<double> progress, CancellationToken cancellationToken)#

Execute the task, asynchronously.

Param progress:

The progress reporter.

Param cancellationToken:

The cancellation token.

Return:

A Task representing the asynchronous operation.

IEnumerable<TaskTriggerInfo> GetDefaultTriggers ()#

Gets the default triggers.

Return:

A list of TaskTriggerInfo.

ThemerrTasks (IApplicationPaths applicationPaths, ILibraryManager libraryManager, ILogger<ThemerrTasks> logger, ILoggerFactory loggerFactory, IXmlSerializer xmlSerializer)#

Initializes a new instance of the ThemerrTasks class.

Param applicationPaths:

The application paths.

Param libraryManager:

The library manager.

Param logger:

The logger.

Param loggerFactory:

The logger factory.

Param xmlSerializer:

The XML serializer.

Properties

string Category { get; set; }#

Gets the category of the task.

string Description { get; set; }#

Gets the description of the task.

string Key { get; set; }#

Gets the key of the task.

string Name { get; set; }#

Gets the name of the task.

Private Members

readonly ILogger<ThemerrTasks> _logger#
readonly ThemerrManager _themerrManager#
namespace Jellyfin#
namespace Jellyfin.Data.Enums#
namespace Jellyfin.Plugin#
namespace Jellyfin.Plugin.Themerr#
namespace Jellyfin.Plugin.Themerr.Api#
namespace Jellyfin.Plugin.Themerr.Configuration#
namespace Jellyfin.Plugin.Themerr.ScheduledTasks#
namespace MediaBrowser.Common.Api#
namespace MediaBrowser.Common.Configuration#
namespace MediaBrowser.Common.Plugins#
namespace MediaBrowser.Controller.Configuration#
namespace MediaBrowser.Controller.Entities#
namespace MediaBrowser.Controller.Entities.Movies#
namespace MediaBrowser.Controller.Entities.TV#
namespace MediaBrowser.Controller.Library#
namespace MediaBrowser.Model.Entities#
namespace MediaBrowser.Model.Plugins#
namespace MediaBrowser.Model.Serialization#
namespace MediaBrowser.Model.Tasks#
namespace Microsoft.AspNetCore.Authorization#
namespace Microsoft.AspNetCore.Http#
namespace Microsoft.AspNetCore.Mvc#
namespace Microsoft.Extensions.Logging#
namespace Newtonsoft.Json#
namespace System#
namespace System.Collections#
namespace System.Collections.Generic#
namespace System.IO#
namespace System.Linq#
namespace System.Net.Http#
namespace System.Net.Mime#
namespace System.Reflection#
namespace System.Threading#
namespace System.Threading.Tasks#
namespace YoutubeExplode#
namespace YoutubeExplode.Videos.Streams#
file ThemerrController.cs
file PluginConfiguration.cs
file ThemerrTasks.cs
file ThemerrManager.cs
file ThemerrPlugin.cs
dir Jellyfin.Plugin.Themerr/Api
dir Jellyfin.Plugin.Themerr/Configuration
dir Jellyfin.Plugin.Themerr
dir Jellyfin.Plugin.Themerr/ScheduledTasks