using System; using System.Collections.Generic; using System.Globalization; using Jellyfin.Plugin.JRay.Configuration; using Jellyfin.Plugin.JRay.Models; namespace Jellyfin.Plugin.JRay.Services; /// Identity and cut parameters for a fetch. public class TitleQuery { /// Gets or sets the movie's TMDB id. public string? TmdbId { get; set; } /// Gets or sets the movie's IMDB id. public string? ImdbId { get; set; } /// Gets or sets the series TMDB id, for an episode. public string? SeriesTmdbId { get; set; } /// Gets or sets the season number, for an episode. public int? Season { get; set; } /// Gets or sets the episode number, for an episode. public int? Episode { get; set; } /// Gets or sets the local file's measured runtime, in seconds. public double? RuntimeSec { get; set; } /// Renders the query parameters the server expects. /// /// There is deliberately no video_hash parameter. The file-hash tier /// is withdrawn on legal grounds (see ), and omitting /// the field here is what makes that structural: there is nothing to send, /// so no future caller can start sending one by setting a property. /// /// An escaped query string, without the leading '?'. public string ToQueryString() { var parts = new List(); void Add(string key, string? value) { if (!string.IsNullOrEmpty(value)) { parts.Add($"{key}={Uri.EscapeDataString(value)}"); } } Add("tmdb_id", TmdbId); Add("imdb_id", ImdbId); Add("series_tmdb_id", SeriesTmdbId); Add("season", Season?.ToString(CultureInfo.InvariantCulture)); Add("episode", Episode?.ToString(CultureInfo.InvariantCulture)); Add("runtime_sec", RuntimeSec?.ToString("0.###", CultureInfo.InvariantCulture)); return string.Join('&', parts); } }