Satisfies JRay-public-server UR-007. Servers are tried in configured order and the first result clearing the configured tier wins; first-match rather than best-match because querying every server for every item multiplies egress and leaks the library to more parties, and the ordering already encodes which source the admin prefers. Every server is untrusted, including the pre-configured community one, so a fetched manifest is re-validated against the same rules the server applies on upload: envelope version refused if unknown, identifiers format-checked, windows bounds-checked against the *local* file's runtime, belief bounded to [0, 1], control and bidi characters refused in names. Responses are capped while streaming rather than after buffering, since a hostile server can declare any Content-Length it likes. HTTPS is required away from loopback. A failing server is skipped with exponential backoff so one dead server cannot stall a sweep. The audio-tier offset is applied once, at store time, so stored truth is always in the local file's own timebase and no read path needs offset awareness. Windows are shifted, never reshaped — merging adjacent ones would answer "was a face visible" rather than "was the actor present" (SR-002). Also records why there is no `exact` tier, which was missing and led me to re-add one. The file-hash tier is withdrawn on legal grounds: a TMDB id discloses "some copy of this film", but an OpenSubtitles hash discloses "this exact release", which turns a catalogue lookup into a release-identification service and a server's database into a mapping from file fingerprints to the instances holding them. The reason now lives on MatchTier and in SPEC.md §JR-036, `TitleQuery` has no VideoHash property so there is nothing to send, and a test asserts the enum has no Exact member — the spec had still listed `exact` as a configurable tier, which is what made the removal look like an oversight. 42 tests. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> TRACES: JR-025, JR-027, JR-028, JR-029, JR-030, JR-031, JR-036, JR-037 | PR-005, PR-006
58 lines
2.1 KiB
C#
58 lines
2.1 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Globalization;
|
|
using Jellyfin.Plugin.JRay.Configuration;
|
|
using Jellyfin.Plugin.JRay.Models;
|
|
|
|
namespace Jellyfin.Plugin.JRay.Services;
|
|
|
|
/// <summary>Identity and cut parameters for a fetch.</summary>
|
|
public class TitleQuery
|
|
{
|
|
/// <summary>Gets or sets the movie's TMDB id.</summary>
|
|
public string? TmdbId { get; set; }
|
|
|
|
/// <summary>Gets or sets the movie's IMDB id.</summary>
|
|
public string? ImdbId { get; set; }
|
|
|
|
/// <summary>Gets or sets the series TMDB id, for an episode.</summary>
|
|
public string? SeriesTmdbId { get; set; }
|
|
|
|
/// <summary>Gets or sets the season number, for an episode.</summary>
|
|
public int? Season { get; set; }
|
|
|
|
/// <summary>Gets or sets the episode number, for an episode.</summary>
|
|
public int? Episode { get; set; }
|
|
|
|
/// <summary>Gets or sets the local file's measured runtime, in seconds.</summary>
|
|
public double? RuntimeSec { get; set; }
|
|
|
|
/// <summary>Renders the query parameters the server expects.</summary>
|
|
/// <remarks>
|
|
/// There is deliberately no <c>video_hash</c> parameter. The file-hash tier
|
|
/// is withdrawn on legal grounds (see <see cref="MatchTier"/>), 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.
|
|
/// </remarks>
|
|
/// <returns>An escaped query string, without the leading '?'.</returns>
|
|
public string ToQueryString()
|
|
{
|
|
var parts = new List<string>();
|
|
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);
|
|
}
|
|
}
|