### Fetch Image Example (Jellyfin) Source: https://github.com/metatube-community/jellyfin-plugin-metatube/blob/main/_autodocs/api-reference-apiclient.md Example of how to fetch image response and read it as a stream in Jellyfin. Ensure the URL and cancellationToken are provided. ```csharp // Jellyfin var response = await ApiClient.GetImageResponse(imageUrl, cancellationToken); using var stream = await response.Content.ReadAsStreamAsync(); ``` -------------------------------- ### Jellyfin Plugin Configuration Example Source: https://github.com/metatube-community/jellyfin-plugin-metatube/blob/main/_autodocs/translation.md Provides a JSON example of the Jellyfin plugin configuration, including translation mode and engine settings. ```json { "TranslationMode": 3, "TranslationEngine": 2, "GoogleApiKey": "AIzaSy...", "GoogleApiUrl": "" } ``` -------------------------------- ### Get Movie Provider Filter in C# Source: https://github.com/metatube-community/jellyfin-plugin-metatube/blob/main/_autodocs/configuration.md Example of how to retrieve the configured movie provider filter list in C#. ```csharp var filter = configuration.GetMovieProviderFilter(); // Returns List ``` -------------------------------- ### Movie Provider ID Example Source: https://github.com/metatube-community/jellyfin-plugin-metatube/blob/main/_autodocs/external-ids.md Example of how a MetaTube provider ID for a movie is stored and how Jellyfin uses the UrlFormatString to create an external link. ```csharp Provider ID: "MetaTube" = "FANZA:abcd123:0.5" Jellyfin creates an external link using UrlFormatString: https://metatube.example.com?redirect=FANZA:abcd123:0.5 ``` -------------------------------- ### TranslateAsync Example Source: https://github.com/metatube-community/jellyfin-plugin-metatube/blob/main/_autodocs/translation.md Example of using TranslationHelper.TranslateAsync to translate a movie's title and summary from Japanese to English. ```csharp var movie = await ApiClient.GetMovieInfoAsync("FANZA", "abcd123", ct); // movie.Title = "日本語のタイトル" // movie.Summary = "日本語の説明" await TranslationHelper.TranslateAsync(movie, "en", ct); // After translation: // movie.Title = "English Title" // movie.Summary = "English Description" ``` -------------------------------- ### Actor Provider ID Example Source: https://github.com/metatube-community/jellyfin-plugin-metatube/blob/main/_autodocs/external-ids.md Example of how a MetaTube provider ID for a person is stored and how Jellyfin creates an external link using the UrlFormatString. ```csharp Provider ID: "MetaTube" = "AVBASE:actor123" Jellyfin creates an external link: https://metatube.example.com?redirect=AVBASE:actor123 ``` -------------------------------- ### MovieProvider GetMetadata Example Source: https://github.com/metatube-community/jellyfin-plugin-metatube/blob/main/_autodocs/api-reference-providers.md Fetches and populates complete movie metadata. Use this to get all details for a movie, including cast, genres, and overview. ```csharp var movieInfo = new MovieInfo { Name = "ABCD123" }; var result = await provider.GetMetadata(movieInfo, cancellationToken); var movie = result.Item; Console.WriteLine($"Title: {movie.Name}"); Console.WriteLine($"Genres: {string.Join(", ", movie.Genres)}"); ``` -------------------------------- ### MetaTube Server URL Example Source: https://github.com/metatube-community/jellyfin-plugin-metatube/blob/main/_autodocs/configuration.md Provide the full URL for the MetaTube server backend. This is required for all metadata operations. ```text https://metatube.example.com http://192.168.1.100:8000 ``` -------------------------------- ### GenerateTrailersTask Error Logging Example Source: https://github.com/metatube-community/jellyfin-plugin-metatube/blob/main/_autodocs/scheduled-tasks.md Example of how errors are logged during trailer generation for individual movies. Errors are logged per movie and do not halt the entire task. ```csharp Generate trailer for video {Name} error: {ExceptionMessage} ``` -------------------------------- ### Template Substitution Example Source: https://github.com/metatube-community/jellyfin-plugin-metatube/blob/main/_autodocs/configuration.md Demonstrates the order and format of parameter substitution within templates. Null or empty fields result in empty strings. ```text Template: "{year} {number} {title}" {year} → "2023" {number} → "ABCD123" {title} → "Example Movie" Result: "2023 ABCD123 Example Movie" ``` -------------------------------- ### Example Translation Workflow Source: https://github.com/metatube-community/jellyfin-plugin-metatube/blob/main/_autodocs/translation.md Illustrates a complete workflow from configuring the translation plugin to fetching movie data and translating its title and summary. ```csharp // 1. Configuration var config = Plugin.Instance.Configuration; config.TranslationMode = TranslationMode.Both; config.TranslationEngine = TranslationEngine.Google; config.GoogleApiKey = "AIzaSy..."; // 2. Fetch movie var movie = await ApiClient.GetMovieInfoAsync("FANZA", "abcd123", ct); // movie.Title = "日本語" // movie.Summary = "説明" // 3. Translate await TranslationHelper.TranslateAsync(movie, "en", ct); // movie.Title = "Japanese" (translated) // movie.Summary = "Description" (translated) // 4. Use in metadata metadataResult.Item.Name = movie.Title; // Now in English metadataResult.Item.Overview = movie.Summary; // Now in English ``` -------------------------------- ### Tagline Template Examples Source: https://github.com/metatube-community/jellyfin-plugin-metatube/blob/main/_autodocs/configuration.md Examples of tagline templates using variables like date, year, month, series, and label. ```text 配信開始日 {date} # Default (Japanese: "Distribution start date") Released {year}-{month}-{date} # English {series} - {label} # Series and label ``` -------------------------------- ### DeepL Translation API Credentials Source: https://github.com/metatube-community/jellyfin-plugin-metatube/blob/main/_autodocs/configuration.md Example format for DeepL API Key and optional custom API URL. ```text API Key: xxxxx:fx API URL: https://api-free.deepl.com/v1 (or leave blank) ``` -------------------------------- ### Default NameTemplate Example Source: https://github.com/metatube-community/jellyfin-plugin-metatube/blob/main/_autodocs/configuration.md This is the default template used for naming media. It combines the media number and title. ```text {number} {title} ``` -------------------------------- ### MovieProvider GetSearchResults Example Source: https://github.com/metatube-community/jellyfin-plugin-metatube/blob/main/_autodocs/api-reference-providers.md Searches for movies by name or fetches by existing provider ID. Useful for displaying a list of potential matches to the user. ```csharp var results = await provider.GetSearchResults(movieInfo, cancellationToken); foreach (var result in results) { Console.WriteLine($"{result.Name} ({result.PremiereDate?.Year})"); } ``` -------------------------------- ### OpenAI Translation API Credentials Source: https://github.com/metatube-community/jellyfin-plugin-metatube/blob/main/_autodocs/configuration.md Example format for OpenAI API Key, optional custom API URL, and optional custom model. ```text API Key: sk-... API URL: https://api.openai.com/v1 (or leave blank, or custom) Model: gpt-4-turbo (or leave blank) ``` -------------------------------- ### Movie Name Template Examples Source: https://github.com/metatube-community/jellyfin-plugin-metatube/blob/main/_autodocs/configuration.md Illustrates different templates for the movie name field, showing how to include variables like provider, number, title, and year. ```text {number} {title} # Default [{provider}] {number} - {title} # Include provider {year}-{month}-{date} {title} # Date-prefixed {number} {title} - {first_actor} # With lead actor ``` -------------------------------- ### TranslationMode Usage Example Source: https://github.com/metatube-community/jellyfin-plugin-metatube/blob/main/_autodocs/translation.md Demonstrates how to check if specific translation modes are enabled using the HasFlag method. ```csharp if (config.TranslationMode.HasFlag(TranslationMode.Title)) { // Translate title } if (config.TranslationMode.HasFlag(TranslationMode.Summary)) { // Translate summary } ``` -------------------------------- ### Example Jellyfin UI External Links Source: https://github.com/metatube-community/jellyfin-plugin-metatube/blob/main/_autodocs/external-ids.md Illustrates how external links, including MetaTube, are displayed in the Jellyfin web UI's 'External Links' section for a movie or person. ```text External Links ├── IMDb: https://imdb.com/... ├── TheMovieDb: https://themoviedb.org/... └── MetaTube: https://metatube.example.com?redirect=FANZA:abcd123 ``` -------------------------------- ### Badge Image URL Examples Source: https://github.com/metatube-community/jellyfin-plugin-metatube/blob/main/_autodocs/configuration.md Specify the URL for badge images to overlay on primary images. This can be a server-relative path or an absolute URL. ```text "zimu.png" "https://example.com/badges/chinese.png" ``` -------------------------------- ### Google Translation API Credentials Source: https://github.com/metatube-community/jellyfin-plugin-metatube/blob/main/_autodocs/configuration.md Example format for Google Translate API Key and optional custom API URL. ```text API Key: AIzaSy... API URL: (leave blank for official Google, or use custom endpoint) ``` -------------------------------- ### Default TaglineTemplate Example Source: https://github.com/metatube-community/jellyfin-plugin-metatube/blob/main/_autodocs/configuration.md This is the default template for the media tagline. It includes the release date. ```text 配信開始日 {date} ``` -------------------------------- ### Image Aspect Ratio Examples Source: https://github.com/metatube-community/jellyfin-plugin-metatube/blob/main/_autodocs/configuration.md Set the target aspect ratio for primary images. Negative values use the server's default. Common values range from 0 to 2. ```text -1: Server default 0.67: Standard portrait (3:4) 1.5: Wider format ``` -------------------------------- ### Get Thumbnail Image URL (Basic) Source: https://github.com/metatube-community/jellyfin-plugin-metatube/blob/main/_autodocs/api-reference-apiclient.md Generates a URL to fetch a thumbnail image for a given provider and content ID. ```csharp public static string GetThumbImageApiUrl(string provider, string id) ``` -------------------------------- ### Error Handling Example Source: https://github.com/metatube-community/jellyfin-plugin-metatube/blob/main/_autodocs/README.md Demonstrates robust error handling for API calls using a try-catch block. Logs errors and allows for graceful fallback mechanisms. ```csharp try { var movie = await ApiClient.GetMovieInfoAsync(provider, id, ct); // Process movie } catch (Exception ex) { logger.Error("Failed to fetch movie: {0}", ex.Message); // Handle gracefully (skip metadata, use existing data, etc.) } ``` -------------------------------- ### Get Genre Substitution Table Source: https://github.com/metatube-community/jellyfin-plugin-metatube/blob/main/_autodocs/types.md Returns the parsed genre substitution table. Access plugin configuration via Plugin.Instance.Configuration. ```csharp public SubstitutionTable GetGenreSubstitutionTable() ``` -------------------------------- ### Movie Provider Filter Example Source: https://github.com/metatube-community/jellyfin-plugin-metatube/blob/main/_autodocs/configuration.md Define a comma-separated list of movie provider names in order of preference. This filters and reorders search results. ```text FANZA, DUGA, Getchu ``` -------------------------------- ### Example Log Entries for Scheduled Tasks Source: https://github.com/metatube-community/jellyfin-plugin-metatube/blob/main/_autodocs/scheduled-tasks.md Illustrates typical log entries generated by different scheduled tasks, including trailers generation, metadata organization, and subtitle updates. ```plaintext [GenerateTrailersTask] Generate trailer for video Movie Name at /path/to/trailers/movie-Trailer.strm [OrganizeMetadataTask] Organize metadata for video: Movie Name [OrganizeMetadataTask] Update ChineseSubtitle for video Movie Name: Exception message ``` -------------------------------- ### Baidu Translation API Credentials Source: https://github.com/metatube-community/jellyfin-plugin-metatube/blob/main/_autodocs/configuration.md Example format for Baidu Translate API App ID and App Key. ```text App ID: 2023... App Key: abc123def456... ``` -------------------------------- ### Provider ID Handling Source: https://github.com/metatube-community/jellyfin-plugin-metatube/blob/main/_autodocs/README.md Manages provider-specific IDs for Jellyfin movies, including storing and retrieving them. Also handles setting and getting trailer URLs. ```csharp var movie = /* Jellyfin Movie */; // Store provider ID movie.SetPid("MetaTube", "FANZA", "abcd123", position: 0.5); // Retrieve provider ID var pid = movie.GetPid("MetaTube"); Console.WriteLine($"Provider: {pid.Provider}, ID: {pid.Id}"); // Trailer URL movie.SetTrailerUrl("https://example.com/trailer.m3u8"); var trailerUrl = movie.GetTrailerUrl(); ``` -------------------------------- ### API Authentication Token Example Source: https://github.com/metatube-community/jellyfin-plugin-metatube/blob/main/_autodocs/configuration.md An optional API token used for authentication. If provided, it's sent in the 'Authorization: Bearer {token}' header. ```text abc123def456ghi789 ``` -------------------------------- ### Get Actor Substitution Table Source: https://github.com/metatube-community/jellyfin-plugin-metatube/blob/main/_autodocs/types.md Returns the parsed actor substitution table. Access plugin configuration via Plugin.Instance.Configuration. ```csharp public SubstitutionTable GetActorSubstitutionTable() ``` -------------------------------- ### Get Backdrop Image URL (Basic) Source: https://github.com/metatube-community/jellyfin-plugin-metatube/blob/main/_autodocs/api-reference-apiclient.md Generates a URL to fetch a backdrop or fanart image for library backgrounds using provider and content ID. ```csharp public static string GetBackdropImageApiUrl(string provider, string id) ``` -------------------------------- ### API Error Handling Example Source: https://github.com/metatube-community/jellyfin-plugin-metatube/blob/main/_autodocs/api-reference-apiclient.md Demonstrates how to wrap API calls in a try-catch block to handle potential network exceptions and API errors gracefully. The exception message contains server error details. ```csharp API request error: {ErrorCode} ({ErrorMessage}) Response data field is null ``` -------------------------------- ### SubstitutionTable Parse Method Example Source: https://github.com/metatube-community/jellyfin-plugin-metatube/blob/main/_autodocs/types.md Parses newline-separated key=value pairs into a case-insensitive substitution table. Empty values delete keys, and lines with empty keys are skipped. ```csharp var table = SubstitutionTable.Parse("foo=bar\nhello=world"); // table["foo"] = "bar", table["hello"] = "world" ``` -------------------------------- ### Get Image URLs Source: https://github.com/metatube-community/jellyfin-plugin-metatube/blob/main/_autodocs/README.md Generates URLs for primary, thumbnail, and backdrop images for a movie. Supports auto face detection for primary images. ```csharp var posterUrl = ApiClient.GetPrimaryImageApiUrl("FANZA", "abcd123"); var thumbUrl = ApiClient.GetThumbImageApiUrl("FANZA", "abcd123"); var backdropUrl = ApiClient.GetBackdropImageApiUrl("FANZA", "abcd123"); // With auto face detection var centeredUrl = ApiClient.GetPrimaryImageApiUrl( "FANZA", "abcd123", imageUrl: "https://example.com/img.jpg", auto: true, position: 0.5); ``` -------------------------------- ### Get Movie Provider Filter Source: https://github.com/metatube-community/jellyfin-plugin-metatube/blob/main/_autodocs/types.md Returns the parsed movie provider filter list. Access plugin configuration via Plugin.Instance.Configuration. ```csharp public List GetMovieProviderFilter() ``` -------------------------------- ### Example Subtitle Files for External Detection Source: https://github.com/metatube-community/jellyfin-plugin-metatube/blob/main/_autodocs/scheduled-tasks.md These external subtitle files will be detected based on their naming convention, including language codes and extensions. ```plaintext movie.chi.srt movie.zho-cn.ass movie.chs.vtt ``` -------------------------------- ### Get Title Substitution Table Source: https://github.com/metatube-community/jellyfin-plugin-metatube/blob/main/_autodocs/types.md Returns the parsed title substitution table. Access plugin configuration via Plugin.Instance.Configuration. ```csharp public SubstitutionTable GetTitleSubstitutionTable() ``` -------------------------------- ### Get Actor Info (Full Details) Source: https://github.com/metatube-community/jellyfin-plugin-metatube/blob/main/_autodocs/api-reference-apiclient.md Fetches detailed actor information using the provider and ID. Use this when full actor details are required. ```csharp var actor = await ApiClient.GetActorInfoAsync("AVBASE", "abc123", cancellationToken); Console.WriteLine($"Actor: {actor.Name}, Height: {actor.Height}cm"); ``` -------------------------------- ### Get Movie Images Source: https://github.com/metatube-community/jellyfin-plugin-metatube/blob/main/_autodocs/api-reference-providers.md Returns available images for a movie item, including poster, thumbnail, and backdrop. Fetches movie info from the MetaTube API. ```csharp public async Task> GetImages( BaseItem item, CancellationToken cancellationToken) { // ... implementation details ... } ``` ```csharp var images = await provider.GetImages(movie, cancellationToken); foreach (var img in images) { Console.WriteLine($"{img.Type}: {img.Url}"); } ``` -------------------------------- ### Image Quality Examples Source: https://github.com/metatube-community/jellyfin-plugin-metatube/blob/main/_autodocs/configuration.md Configure the JPEG compression quality for processed images, ranging from 0 to 100. Higher values mean better quality but more bandwidth. ```text 70: Lower bandwidth, visible compression 90: Balanced (default) 100: Maximum quality ``` -------------------------------- ### Get External URLs for Movie or Person Source: https://github.com/metatube-community/jellyfin-plugin-metatube/blob/main/_autodocs/api-reference-providers.md Constructs external URLs for a given movie or person item using the provider's configuration. This is useful for linking to external content sources. ```csharp public IEnumerable GetExternalUrls(BaseItem item) ``` ```csharp var urls = provider.GetExternalUrls(movie); // Result: ["https://metatube.example.com?redirect=FANZA:abcd123"] ``` -------------------------------- ### Get Movie Info (Full Details) Source: https://github.com/metatube-community/jellyfin-plugin-metatube/blob/main/_autodocs/api-reference-apiclient.md Fetches detailed movie metadata including genres, actors, director, and summary using the provider and ID. Use this for comprehensive movie data retrieval. ```csharp var movie = await ApiClient.GetMovieInfoAsync("FANZA", "abcd123", cancellationToken); Console.WriteLine($"{movie.Title} ({movie.ReleaseDate:yyyy-MM-dd})"); Console.WriteLine($"Director: {movie.Director}"); Console.WriteLine($"Genres: {string.Join(", ", movie.Genres)}"); ``` -------------------------------- ### Get Backdrop Image URL (Advanced) Source: https://github.com/metatube-community/jellyfin-plugin-metatube/blob/main/_autodocs/api-reference-apiclient.md Generates a URL for a backdrop image, allowing direct image URL processing with options for face detection and centering. ```csharp public static string GetBackdropImageApiUrl( string provider, string id, string url, double position = -1, bool auto = false) ``` -------------------------------- ### Get Movie Info (Lazy Loading) Source: https://github.com/metatube-community/jellyfin-plugin-metatube/blob/main/_autodocs/api-reference-apiclient.md Fetches movie metadata with an option for lazy loading via the 'lazy' parameter. This variant is useful for optimizing performance when full details are not immediately needed. ```csharp public static async Task GetMovieInfoAsync( string provider, string id, bool lazy, CancellationToken cancellationToken) ``` -------------------------------- ### Get Primary Image URL (Basic) Source: https://github.com/metatube-community/jellyfin-plugin-metatube/blob/main/_autodocs/api-reference-apiclient.md Generates a URL to fetch the primary poster or cover image for a movie or actor using provider and content ID. Supports optional position and badge parameters. ```csharp public static string GetPrimaryImageApiUrl( string provider, string id, double position = -1, string badge = default) ``` ```csharp var url = ApiClient.GetPrimaryImageApiUrl("FANZA", "abcd123", -1, "zimu.png"); // Result: https://server/v1/images/primary/FANZA/abcd123?ratio=1.5&pos=-1&auto=false&badge=zimu.png ``` -------------------------------- ### MovieImageProvider Constructor Source: https://github.com/metatube-community/jellyfin-plugin-metatube/blob/main/_autodocs/api-reference-providers.md Initializes the MovieImageProvider. Use the appropriate constructor based on your Jellyfin or Emby environment. ```csharp public MovieImageProvider(ILogger logger) // Jellyfin public MovieImageProvider(ILogManager logManager) // Emby ``` -------------------------------- ### ActorImageProvider Constructor Source: https://github.com/metatube-community/jellyfin-plugin-metatube/blob/main/_autodocs/api-reference-providers.md Initializes the ActorImageProvider. Use the appropriate constructor based on your Jellyfin or Emby environment. ```csharp public ActorImageProvider(ILogger logger) // Jellyfin public ActorImageProvider(ILogManager logManager) // Emby ``` -------------------------------- ### BaseExternalId UrlFormatString Example Source: https://github.com/metatube-community/jellyfin-plugin-metatube/blob/main/_autodocs/external-ids.md Example of overriding the UrlFormatString property to define the URL pattern for external links. This format string is used to generate clickable links to external services. ```csharp public override string UrlFormatString => "https://metatube.example.com?redirect={0}"; ``` -------------------------------- ### BaseProvider Constructor Source: https://github.com/metatube-community/jellyfin-plugin-metatube/blob/main/_autodocs/api-reference-providers.md Abstract base class for metadata providers. Handles logging and image responses. Requires an ILogger instance for logging. ```csharp protected BaseProvider(ILogger logger) ``` -------------------------------- ### Get Person Search Results Source: https://github.com/metatube-community/jellyfin-plugin-metatube/blob/main/_autodocs/api-reference-providers.md Searches for actors by name. Returns a list of potential actor matches. ```csharp public async Task> GetSearchResults( PersonLookupInfo info, CancellationToken cancellationToken) { // ... implementation details ... } ``` -------------------------------- ### Load Plugin Configuration Source: https://github.com/metatube-community/jellyfin-plugin-metatube/blob/main/Jellyfin.Plugin.MetaTube/Configuration/configPage.html Fetches the plugin configuration from the API and populates the configuration form fields. Displays a loading message while fetching. ```javascript $('.MetaTubeConfigurationPage').on('pageshow', function () { Dashboard.showLoadingMsg(); var page = this; ApiClient.getPluginConfiguration(MetaTubePluginConfig.pluginUniqueId).then(function (config) { $('#txtServer', page).val(config.Server).change(); $('#txtToken', page).val(config.Token).change(); page.querySelector('#chkEnableCollections').checked = config.EnableCollections; page.querySelector('#chkEnableDirectors').checked = config.EnableDirectors; page.querySelector('#chkEnableRatings').checked = config.EnableRatings; page ``` -------------------------------- ### Initialize HttpClient Source: https://github.com/metatube-community/jellyfin-plugin-metatube/blob/main/_autodocs/api-reference-apiclient.md The static constructor initializes a singleton HttpClient with pooled connections and TCP keep-alive settings for efficient network communication. ```csharp private static readonly HttpClient HttpClient ``` -------------------------------- ### C# Code for Translation Mode Check Source: https://github.com/metatube-community/jellyfin-plugin-metatube/blob/main/_autodocs/configuration.md Example of checking if title translation is enabled using the TranslationMode enum in C#. ```csharp if (config.TranslationMode.HasFlag(TranslationMode.Title)) { movie.Title = await TranslateAsync(movie.Title, ...); } ``` -------------------------------- ### Get Actor Images Source: https://github.com/metatube-community/jellyfin-plugin-metatube/blob/main/_autodocs/api-reference-providers.md Returns available profile images for an actor. This method retrieves actor primary (profile) images. ```csharp public async Task> GetImages( BaseItem item, CancellationToken cancellationToken) { // ... implementation details ... } ``` ```csharp var images = await provider.GetImages(person, cancellationToken); foreach (var img in images) { Console.WriteLine(img.Url); // Actor profile image URL } ``` -------------------------------- ### Build Plugin for Release Source: https://github.com/metatube-community/jellyfin-plugin-metatube/blob/main/_autodocs/README.md Builds the plugin in release configuration for .NET 9.0. This command is used for generating the final DLL for deployment. ```bash dotnet build -c Release ``` -------------------------------- ### Initialize Plugin Configuration Source: https://github.com/metatube-community/jellyfin-plugin-metatube/blob/main/Jellyfin.Plugin.MetaTube/Configuration/configPage.html Initializes the plugin unique ID and sets up event listeners for translation mode and engine selections. ```javascript var MetaTubePluginConfig = { pluginUniqueId: "01cc53ec-c415-4108-bbd4-a684a9801a32" }; ``` -------------------------------- ### Example Filenames for Chinese Subtitle Detection Source: https://github.com/metatube-community/jellyfin-plugin-metatube/blob/main/_autodocs/scheduled-tasks.md These filenames will trigger the Chinese subtitle detection mechanism based on embedded strings or tags. ```plaintext movie-C.mkv movie-UC.mkv movie_ch.mkv movie 中文字幕.mkv ``` -------------------------------- ### OrganizeMetadataTask Constructor Source: https://github.com/metatube-community/jellyfin-plugin-metatube/blob/main/_autodocs/scheduled-tasks.md Constructor for the OrganizeMetadataTask. Requires an ILogger for logging and an ILibraryManager for accessing library data. ```csharp public OrganizeMetadataTask( ILogger logger, ILibraryManager libraryManager) ``` -------------------------------- ### MovieProvider Constructor Source: https://github.com/metatube-community/jellyfin-plugin-metatube/blob/main/_autodocs/api-reference-providers.md Constructor for the MovieProvider. Accepts either an ILogger for Jellyfin or an ILogManager for Emby. ```csharp public MovieProvider(ILogger logger) // Jellyfin public MovieProvider(ILogManager logManager) // Emby ``` -------------------------------- ### Customizable UrlFormatString Configuration Source: https://github.com/metatube-community/jellyfin-plugin-metatube/blob/main/_autodocs/external-ids.md Shows how the UrlFormatString can be customized via plugin configuration, typically pointing to the configured MetaTube server with a redirect parameter. ```csharp public virtual string UrlFormatString => Plugin.Instance.Configuration.Server + "?redirect={0}"; ``` -------------------------------- ### BaseProvider GetImageResponse Method Source: https://github.com/metatube-community/jellyfin-plugin-metatube/blob/main/_autodocs/api-reference-providers.md Fetches image data from a URL, including authentication headers. Used for retrieving images for metadata. ```csharp public Task GetImageResponse(string url, CancellationToken cancellationToken) ``` -------------------------------- ### Load MetaTube Plugin Configuration Source: https://github.com/metatube-community/jellyfin-plugin-metatube/blob/main/Jellyfin.Plugin.MetaTube/Configuration/configPage.html Loads the current configuration for the MetaTube plugin and updates the UI elements accordingly. This is typically called when the configuration page is initialized. ```javascript ApiClient.getPluginConfiguration(MetaTubePluginConfig.pluginUniqueId).then(function (config) { page.querySelector('#chkEnableTrailers').checked = config.EnableTrailers; page.querySelector('#chkEnableRealActorNames').checked = config.EnableRealActorNames; page.querySelector('#chkEnableBadges').checked = config.EnableBadges; $('#txtBadgeUrl', page).val(config.BadgeUrl).change(); $('#txtPrimaryImageRatio', page).val(config.PrimaryImageRatio).change(); $('#txtDefaultImageQuality', page).val(config.DefaultImageQuality).change(); page.querySelector('#chkEnableMovieProviderFilter').checked = config.EnableMovieProviderFilter; $('#txtRawMovieProviderFilter', page).val(config.RawMovieProviderFilter).change(); page.querySelector('#chkEnableTemplate').checked = config.EnableTemplate; $('#txtNameTemplate', page).val(config.NameTemplate).change(); $('#txtTaglineTemplate', page).val(config.TaglineTemplate).change(); $('#selectTranslationMode', page).val(config.TranslationMode).change(); $('#selectTranslationEngine', page).val(config.TranslationEngine).change(); $('#txtBaiduAppId', page).val(config.BaiduAppId).change(); $('#txtBaiduAppKey', page).val(config.BaiduAppKey).change(); $('#txtGoogleApiKey', page).val(config.GoogleApiKey).change(); $('#txtGoogleApiUrl', page).val(config.GoogleApiUrl).change(); $('#txtDeepLApiKey', page).val(config.DeepLApiKey).change(); $('#txtDeepLApiUrl', page).val(config.DeepLApiUrl).change(); $('#txtOpenAiApiKey', page).val(config.OpenAiApiKey).change(); $('#txtOpenAiApiUrl', page).val(config.OpenAiApiUrl).change(); $('#txtOpenAiModel', page).val(config.OpenAiModel).change(); page.querySelector('#chkEnableTitleSubstitution').checked = config.EnableTitleSubstitution; $('#txtTitleRawSubstitutionTable', page).val(config.TitleRawSubstitutionTable).change(); page.querySelector('#chkEnableActorSubstitution').checked = config.EnableActorSubstitution; $('#txtActorRawSubstitutionTable', page).val(config.ActorRawSubstitutionTable).change(); page.querySelector('#chkEnableGenreSubstitution').checked = config.EnableGenreSubstitution; $('#txtGenreRawSubstitutionTable', page).val(config.GenreRawSubstitutionTable).change(); Dashboard.hideLoadingMsg(); }); ``` -------------------------------- ### Constructor for UpdatePluginTask Source: https://github.com/metatube-community/jellyfin-plugin-metatube/blob/main/_autodocs/scheduled-tasks.md Initializes the UpdatePluginTask with dependencies for logging, HTTP requests, and application paths. ```csharp public UpdatePluginTask( ILogger logger, IHttpClientFactory httpClientFactory, IApplicationPaths appPaths) ``` -------------------------------- ### Get Provider ID from Item Source: https://github.com/metatube-community/jellyfin-plugin-metatube/blob/main/_autodocs/extensions-and-helpers.md Retrieves and parses a provider ID from an item implementing IHasProviderIds. Returns an empty ProviderId if no ID is stored. ```csharp public static ProviderId GetPid(this IHasProviderIds instance, string name) ``` ```csharp var movie = /* Jellyfin Movie item */; var pid = movie.GetPid("MetaTube"); Console.WriteLine($"Provider: {pid.Provider}, ID: {pid.Id}"); // Output: Provider: FANZA, ID: abcd123 ``` -------------------------------- ### Get Person Metadata Source: https://github.com/metatube-community/jellyfin-plugin-metatube/blob/main/_autodocs/api-reference-providers.md Fetches actor information and populates a Person object. Use this to retrieve detailed metadata for a person based on lookup info. ```csharp public async Task> GetMetadata( PersonLookupInfo info, CancellationToken cancellationToken) { // ... implementation details ... } ``` ```csharp var actorInfo = new PersonLookupInfo { Name = "Yuki Uchida" }; var result = await provider.GetMetadata(actorInfo, cancellationToken); var person = result.Item; Console.WriteLine($"Name: {person.Name}"); Console.WriteLine($"Overview:\n{person.Overview}"); ``` -------------------------------- ### Handling Missing MetaTube ID Source: https://github.com/metatube-community/jellyfin-plugin-metatube/blob/main/_autodocs/external-ids.md This C# code demonstrates how Jellyfin handles cases where a media item might not have a configured MetaTube ID. In such scenarios, the external link is not displayed, and no errors are thrown, allowing other provider links to function correctly. ```csharp var movie = /* Movie with no MetaTube ID */; var urls = externalUrlProvider.GetExternalUrls(movie); // Returns empty enumerable for MetaTube ``` -------------------------------- ### Normalize Logging with ILogger Extensions Source: https://github.com/metatube-community/jellyfin-plugin-metatube/blob/main/_autodocs/extensions-and-helpers.md Provides simple wrappers to normalize logging output between Jellyfin and Emby using ILogger. Supports Debug, Info, Warn, and Error levels. ```csharp public static void Debug(this ILogger logger, string message, params object[] args) public static void Info(this ILogger logger, string message, params object[] args) public static void Warn(this ILogger logger, string message, params object[] args) public static void Error(this ILogger logger, string message, params object[] args) ``` ```csharp logger.Info("Loading metadata for {0}", movieName); // Jellyfin: LogInformation logger.Warn("Metadata not found for {0}", id); // Jellyfin: LogWarning ``` -------------------------------- ### MovieProvider Translation Integration Source: https://github.com/metatube-community/jellyfin-plugin-metatube/blob/main/_autodocs/translation.md Demonstrates how MovieProvider calls TranslateAsync after fetching metadata and logs any translation errors. ```csharp // In MovieProvider.GetMetadata() if (Configuration.TranslationMode != TranslationMode.Disabled) await TranslateMovieInfo(m, info.MetadataLanguage, cancellationToken); ``` ```csharp try { await TranslationHelper.TranslateAsync(m, language, cancellationToken); } catch (Exception e) { logger.Error("Translate error: {0}", e.Message); } ``` -------------------------------- ### Get Thumbnail Image URL (Advanced) Source: https://github.com/metatube-community/jellyfin-plugin-metatube/blob/main/_autodocs/api-reference-apiclient.md Generates a URL for a thumbnail image, allowing direct image URL processing with options for face detection and centering. ```csharp public static string GetThumbImageApiUrl( string provider, string id, string url, double position = -1, bool auto = false) ``` -------------------------------- ### Get valid Jellyfin DateTime Source: https://github.com/metatube-community/jellyfin-plugin-metatube/blob/main/_autodocs/extensions-and-helpers.md Converts a DateTime to a valid Jellyfin date format. Returns null if the year is 0001, indicating an invalid or default date. ```csharp public static DateTime? GetValidDateTime(this DateTime dt) ``` ```csharp var date = new DateTime(2023, 12, 25); var valid = date.GetValidDateTime(); // 2023-12-25 var invalid = new DateTime(1, 1, 1); // Invalid default var result = invalid.GetValidDateTime(); // null ``` -------------------------------- ### MovieImageProvider GetSupportedImages Source: https://github.com/metatube-community/jellyfin-plugin-metatube/blob/main/_autodocs/api-reference-providers.md Returns the supported image types for movies. This includes Primary, Thumb, and Backdrop. ```csharp public IEnumerable GetSupportedImages(BaseItem item) { // ... implementation details ... } ``` -------------------------------- ### MovieExternalId Class Source: https://github.com/metatube-community/jellyfin-plugin-metatube/blob/main/_autodocs/external-ids.md Registers MetaTube as an external ID provider specifically for movies. Jellyfin automatically discovers and registers this class. ```csharp public class MovieExternalId : BaseExternalId ``` -------------------------------- ### Get Actor Info (Lazy Loading) Source: https://github.com/metatube-community/jellyfin-plugin-metatube/blob/main/_autodocs/api-reference-apiclient.md Fetches actor information, utilizing cached or lazy loading when the 'lazy' parameter is set to true. This can be more efficient for repeated access. ```csharp public static async Task GetActorInfoAsync( string provider, string id, bool lazy, CancellationToken cancellationToken) ``` -------------------------------- ### C# Code for Title Substitution Source: https://github.com/metatube-community/jellyfin-plugin-metatube/blob/main/_autodocs/configuration.md Demonstrates how to retrieve and use the title substitution table in C# code. ```csharp var table = configuration.GetTitleSubstitutionTable(); var newTitle = table.Substitute(movie.Title); ``` -------------------------------- ### ApiClient Static API Source: https://github.com/metatube-community/jellyfin-plugin-metatube/blob/main/_autodocs/README.md The ApiClient static class provides methods for interacting with the MetaTube backend API to fetch metadata, search for content, retrieve images, and perform translations. ```APIDOC ## Static API: Jellyfin.Plugin.MetaTube.ApiClient ### Description This static class serves as the primary interface for interacting with the MetaTube backend services. It exposes methods for retrieving detailed movie and actor information, searching for content, obtaining image URLs, and translating text. ### Methods - **GetMovieInfoAsync(string id)** - Fetches detailed metadata for a specific movie. - **GetActorInfoAsync(string id)** - Fetches detailed metadata for a specific actor. - **SearchMovieAsync(string query)** - Searches for movies based on a query string. - **SearchActorAsync(string query)** - Searches for actors based on a query string. - **GetPrimaryImageApiUrl(string id)** - Retrieves the API URL for a movie's primary image (poster). - **GetThumbImageApiUrl(string id)** - Retrieves the API URL for a movie's thumbnail image. - **GetBackdropImageApiUrl(string id)** - Retrieves the API URL for a movie's backdrop image. - **TranslateAsync(string text, TranslationMode mode, TranslationEngine engine, string apiKey = null)** - Translates the provided text using the specified translation mode and engine. An optional API key can be provided for authenticated services. ``` -------------------------------- ### JellyfinExtensions Source: https://github.com/metatube-community/jellyfin-plugin-metatube/blob/main/_autodocs/extensions-and-helpers.md Compatibility extensions for Jellyfin, including logger wrappers and methods for managing movie collections. ```APIDOC ## Logger Extensions ### Description Simple wrappers to normalize logging between Jellyfin and Emby. ### Methods - `public static void Debug(this ILogger logger, string message, params object[] args)` - `public static void Info(this ILogger logger, string message, params object[] args)` - `public static void Warn(this ILogger logger, string message, params object[] args)` - `public static void Error(this ILogger logger, string message, params object[] args)` ### Example ```csharp logger.Info("Loading metadata for {0}", movieName); // Jellyfin: LogInformation logger.Warn("Metadata not found for {0}", id); // Jellyfin: LogWarning ``` ``` ```APIDOC ## AddCollection ### Description Adds a movie to a named collection. ### Method `public static void AddCollection(this Movie movie, string name)` ### Parameters #### Path Parameters - **movie** (Movie) - Required - The movie item - **name** (string) - Required - Collection name (e.g., series name) ### Example ```csharp movie.AddCollection("My Series"); // Jellyfin recognizes this as a series collection ``` ``` -------------------------------- ### MovieImageProvider Supports Source: https://github.com/metatube-community/jellyfin-plugin-metatube/blob/main/_autodocs/api-reference-providers.md Checks if the provider supports the given item type. Returns true if the item is a Movie. ```csharp public bool Supports(BaseItem item) { // ... implementation details ... } ``` -------------------------------- ### Get Primary Image URL (Advanced) Source: https://github.com/metatube-community/jellyfin-plugin-metatube/blob/main/_autodocs/api-reference-apiclient.md Generates a URL to fetch a primary image, allowing direct image URL processing with options for face detection and centering. Supports optional badge overlays. ```csharp public static string GetPrimaryImageApiUrl( string provider, string id, string url, double position = -1, bool auto = false, string badge = default) ``` ```csharp var processedUrl = ApiClient.GetPrimaryImageApiUrl( "FANZA", "movie123", "https://example.com/image.jpg", position: 0.5, auto: true, badge: "zimu.png"); ``` -------------------------------- ### GenerateTrailersTask ExecuteAsync Source: https://github.com/metatube-community/jellyfin-plugin-metatube/blob/main/_autodocs/scheduled-tasks.md The main execution method for the GenerateTrailersTask. It handles trailer file generation and cleanup, reporting progress and respecting cancellation tokens. ```csharp public async Task ExecuteAsync(IProgress progress, CancellationToken cancellationToken) ``` -------------------------------- ### GetImageResponse Signature (Jellyfin) Source: https://github.com/metatube-community/jellyfin-plugin-metatube/blob/main/_autodocs/api-reference-apiclient.md This is the signature for fetching raw image data from a URL with appropriate headers in Jellyfin. ```csharp public static async Task GetImageResponse( string url, CancellationToken cancellationToken) ``` -------------------------------- ### Fetch Movie Metadata Source: https://github.com/metatube-community/jellyfin-plugin-metatube/blob/main/_autodocs/README.md Retrieves detailed information for a specific movie using its provider and ID. Useful for populating movie details in Jellyfin. ```csharp var movieInfo = await ApiClient.GetMovieInfoAsync("FANZA", "abcd123", cancellationToken); Console.WriteLine($"Title: {movieInfo.Title}"); Console.WriteLine($"Director: {movieInfo.Director}"); Console.WriteLine($"Genres: {string.Join(", ", movieInfo.Genres)}"); Console.WriteLine($"Actors: {string.Join(", ", movieInfo.Actors)}"); ``` -------------------------------- ### GenerateTrailersTask Constructor Source: https://github.com/metatube-community/jellyfin-plugin-metatube/blob/main/_autodocs/scheduled-tasks.md Constructor for the GenerateTrailersTask. Requires an ILogger for logging and an ILibraryManager for accessing library data. ```csharp public GenerateTrailersTask( ILogger logger, ILibraryManager libraryManager) ``` -------------------------------- ### GetActorInfoAsync Source: https://github.com/metatube-community/jellyfin-plugin-metatube/blob/main/_autodocs/api-reference-apiclient.md Fetches detailed actor information from the MetaTube server. Supports fetching full details or using lazy loading. ```APIDOC ## GetActorInfoAsync (variant 1) ### Description Fetches detailed actor information from the MetaTube server using the provided provider and ID. ### Method `public static async Task GetActorInfoAsync(string provider, string id, CancellationToken cancellationToken)` ### Parameters #### Path Parameters - **provider** (string) - Yes - Actor provider (e.g., "Gfriends", "AVBASE") - **id** (string) - Yes - Actor ID from the provider - **cancellationToken** (CancellationToken) - Yes - Cancellation token for async operations ### Response #### Success Response (`Task`) - **ActorInfo** - Complete actor information ### Throws - `Exception` if API request fails or returns error ### Example ```csharp var actor = await ApiClient.GetActorInfoAsync("AVBASE", "abc123", cancellationToken); Console.WriteLine($"Actor: {actor.Name}, Height: {actor.Height}cm"); ``` --- ## GetActorInfoAsync (variant 2) ### Description Fetches actor information from the MetaTube server, with an option for lazy loading. ### Method `public static async Task GetActorInfoAsync(string provider, string id, bool lazy, CancellationToken cancellationToken)` ### Parameters #### Path Parameters - **provider** (string) - Yes - Actor provider - **id** (string) - Yes - Actor ID - **lazy** (bool) - Yes - If false, fetch full details; if true, use cached/lazy loading - **cancellationToken** (CancellationToken) - Yes - Cancellation token ### Response #### Success Response (`Task`) - **ActorInfo** - Resolved actor information ### Example ```csharp // Example usage for variant 2 would be similar, specifying the lazy parameter ``` ``` -------------------------------- ### ActorProvider Constructor Source: https://github.com/metatube-community/jellyfin-plugin-metatube/blob/main/_autodocs/api-reference-providers.md Constructor for the ActorProvider. Accepts either an ILogger for Jellyfin or an ILogManager for Emby. ```csharp public ActorProvider(ILogger logger) // Jellyfin public ActorProvider(ILogManager logManager) // Emby ``` -------------------------------- ### Search for Movies Source: https://github.com/metatube-community/jellyfin-plugin-metatube/blob/main/_autodocs/README.md Searches for movies based on a query, provider, and a flag for exact matching. Returns a list of movies with provider, number, and title. ```csharp var results = await ApiClient.SearchMovieAsync("FANZA", "abcd", true, cancellationToken); foreach (var movie in results) { Console.WriteLine($"[{movie.Provider}] {movie.Number} - {movie.Title}"); } ``` -------------------------------- ### OrganizeMetadataTask GetDefaultTriggers Source: https://github.com/metatube-community/jellyfin-plugin-metatube/blob/main/_autodocs/scheduled-tasks.md Retrieves the default trigger configuration for the OrganizeMetadataTask, which is set to run daily at 3:00 AM. ```csharp public IEnumerable GetDefaultTriggers() { // Daily trigger at 3:00 AM (3600 ticks in a day = 1 hour). } ``` -------------------------------- ### BaseProvider - GetImageResponse Source: https://github.com/metatube-community/jellyfin-plugin-metatube/blob/main/_autodocs/api-reference-providers.md Fetches image data from a URL, including authentication headers if necessary. This is a utility method used by other providers. ```APIDOC ## GetImageResponse ### Description Fetches image data from a URL with authentication headers. ### Method `Task` (Jellyfin) or `Task` (Emby) ### Endpoint N/A (Internal method) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters - **url** (string) - Required - Image URL to fetch - **cancellationToken** (CancellationToken) - Required - Cancellation token ### Response #### Success Response - **HttpResponseMessage** (Jellyfin) or **HttpResponseInfo** (Emby) - The HTTP response containing image data. ``` -------------------------------- ### ResponseInfo Class Definition Source: https://github.com/metatube-community/jellyfin-plugin-metatube/blob/main/_autodocs/types.md A generic wrapper for API responses from the MetaTube server, containing either data or error information. ```csharp public class ResponseInfo { [JsonPropertyName("data")] public T Data { get; set; } [JsonPropertyName("error")] public ErrorInfo Error { get; set; } } ```