< Summary - Jellyfin

Information
Class: MediaBrowser.Providers.Plugins.Omdb.JsonOmdbNotAvailableStringConverter
Assembly: MediaBrowser.Providers
File(s): /srv/git/jellyfin/MediaBrowser.Providers/Plugins/Omdb/JsonOmdbNotAvailableStringConverter.cs
Line coverage
80%
Covered lines: 8
Uncovered lines: 2
Coverable lines: 10
Total lines: 45
Line coverage: 80%
Branch coverage
66%
Covered branches: 4
Total branches: 6
Branch coverage: 66.6%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Coverage history

Coverage history 0 25 50 75 100 5/16/2026 - 12:15:55 AM Line coverage: 80% (8/10) Branch coverage: 66.6% (4/6) Total lines: 4210/29/2026 - 12:17:11 AM Line coverage: 80% (8/10) Branch coverage: 66.6% (4/6) Total lines: 45 5/16/2026 - 12:15:55 AM Line coverage: 80% (8/10) Branch coverage: 66.6% (4/6) Total lines: 4210/29/2026 - 12:17:11 AM Line coverage: 80% (8/10) Branch coverage: 66.6% (4/6) Total lines: 45

Coverage delta

Coverage delta 1 -1

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
Read(...)66.66%7675%
Write(...)100%11100%

File(s)

/srv/git/jellyfin/MediaBrowser.Providers/Plugins/Omdb/JsonOmdbNotAvailableStringConverter.cs

#LineLine coverage
 1using System;
 2using System.Net;
 3using System.Text.Json;
 4using System.Text.Json.Serialization;
 5using Jellyfin.Extensions.Json;
 6
 7namespace MediaBrowser.Providers.Plugins.Omdb
 8{
 9    /// <summary>
 10    /// Converts a string <c>N/A</c> to <c>string.Empty</c> and decodes HTML entities in every other string.
 11    /// </summary>
 12    public class JsonOmdbNotAvailableStringConverter : JsonConverter<string?>
 13    {
 14        /// <inheritdoc />
 15        public override string? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
 16        {
 7917            if (reader.IsNull())
 18            {
 019                return null;
 20            }
 21
 7922            if (reader.TokenType == JsonTokenType.String)
 23            {
 24                // GetString can't return null here because we already handled it above
 7925                var str = reader.GetString()!;
 7926                if (str.Equals("N/A", StringComparison.OrdinalIgnoreCase))
 27                {
 628                    return null;
 29                }
 30
 31                // Some OMDb records are HTML encoded, e.g. the cast of tt0093058 lists "Vincent D&apos;Onofrio".
 32                // Stored verbatim that name is a second person next to the correctly spelled one.
 7333                return WebUtility.HtmlDecode(str);
 34            }
 35
 036            return JsonSerializer.Deserialize<string?>(ref reader, options);
 37        }
 38
 39        /// <inheritdoc />
 40        public override void Write(Utf8JsonWriter writer, string? value, JsonSerializerOptions options)
 41        {
 2042            writer.WriteStringValue(value);
 2043        }
 44    }
 45}