Skip to main content

parse_quality_name

Function parse_quality_name 

Source
pub fn parse_quality_name(name: &str) -> QualityModel
Expand description

Quality-cascade entry-point. Ported from QualityParser.cs:100-598 (ParseQualityName).

Duties.

  1. Normalise: name.Replace('_', ' ').Trim() and name.Trim() for the raw side, mirroring C#’s twin Trim() calls at QualityParser.cs:77 and QualityParser.cs:102.

  2. Run parse_quality_modifiers against both raw and normalised name to populate Revision. Modifiers that fire also set revision_detection_source = Name.

  3. RawHD short-circuit (C# line 105): return Quality::RawHd with source_detection_source = resolution_detection_source = Name.

  4. Source-to-quality cascade (C# lines 114-318): take the LAST source match, pair with the parsed resolution + codec + remux signals, and route to a concrete Quality variant. Branches:

    • bluray: codec(xvid|divx) -> 480p, else by-resolution (2160 / 1080 / 576 / {360, 480, 540}); remux+resolution!=720 -> 1080pRemux; else 720p.
    • webdl: by-resolution (2160 / 1080 / 720); raw-name [WEBDL] -> 720p; else 480p.
    • webrip: by-resolution (2160 / 1080 / 720); else 480p.
    • hdtv: MPEG2 -> RawHD; else by-resolution; raw-name [HDTV] -> 720p; else SDTV.
    • bdrip / brrip: by-resolution (720 / 1080 / 2160); else 480p.
    • dvd: DVD always.
    • pdtv / sdtv / dsr / tvrip: 1080p match -> Hdtv1080p; 720p match -> Hdtv720p; HighDefPdtv (hr-ws) -> Hdtv720p; else SDTV.

    Provenance flags (source_detection_source, resolution_detection_source) are populated according to the C# rules: source_detection_source is set to Name whenever a sourceMatch fires; resolution_detection_source is set to Name when the resolution-regex hit (line 122) or, in the pdtv-cluster branch, when the ContainsIgnoreCase substring fallback fires (line 308’s HighDefPdtvRegex path).

Fallthrough cascade (T8). When no source match fires, the following fallbacks run in C# order, each returning on a hit:

  • Sourceless remux (C# 320-347): remuxMatch && resolution != Unknown, dispatched per resolution. SourceDetectionSource is explicitly Unknown here per C# line 322.
  • Anime-bluray (C# 349-390): AnimeBlurayRegex hits, resolution-routed (480/1080/2160/720 defaults). 480p in this branch maps to Quality::Dvd per C# line 359.
  • Anime-webdl (C# 392-424): AnimeWebDlRegex hits, resolution-routed.
  • Resolution-only (C# 426-497): resolution != Unknown. Derives a QualitySource from remuxMatch (BlurayRaw) OR from the file extension via [quality_for_extension] + [quality_source], then dispatches via find_by_source_and_resolution. Unknown source falls back to Television-class defaults (Hdtv2160p / Hdtv1080p / Hdtv720p / Sdtv).
  • x264-SDTV (C# 499-504): bare x264 with no other signal -> Sdtv.
  • Pixel-tag fallbacks (C# 506-560): literal 848x480, 1280x720, 1920x1080 substrings, optionally combined with dvd / bluray markers.
  • Bare-bluray-resolution (C# 562-587): literal bluray720p / bluray1080p / bluray2160p -> Bluray720p / Bluray1080p / Bluray2160p.
  • OtherSourceMatch (C# 589-595, 653-672): OTHER_SOURCE_REGEX hit (HD-TV / SD-TV alternative form) -> Hdtv720p / Sdtv.

Most callers want parse_quality instead. That wrapper adds the extension-fallback behaviour from QualityParser.cs:81-95 on top of parse_quality_name’s output. Use parse_quality_name directly only when you specifically want to bypass the extension lookup (e.g., text-only parsing, no file path implied). This split mirrors C#’s ParseQuality (public) vs ParseQualityName (test-seam) shape.