mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-07-09 03:04:24 -04:00
Use Uri.TryCreate and ImageType helper method
This commit is contained in:
parent
16694b0cfc
commit
6f898145af
@ -803,25 +803,11 @@ namespace MediaBrowser.XbmcMetadata.Parsers
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
ImageType imageType = artType switch
|
ImageType imageType = GetImageType(artType);
|
||||||
{
|
|
||||||
"banner" => ImageType.Banner,
|
|
||||||
"clearlogo" => ImageType.Logo,
|
|
||||||
"discart" => ImageType.Disc,
|
|
||||||
"landscape" => ImageType.Thumb,
|
|
||||||
"clearart" => ImageType.Art,
|
|
||||||
// unknown type (including "poster") --> primary
|
|
||||||
_ => ImageType.Primary,
|
|
||||||
};
|
|
||||||
|
|
||||||
Uri uri;
|
if (!Uri.TryCreate(val, UriKind.Absolute, out var uri) || uri == null)
|
||||||
try
|
|
||||||
{
|
{
|
||||||
uri = new Uri(val);
|
Logger.LogError("Image location {Path} specified in nfo file for {ItemName} is not a valid URL or file path.", val, item.Name);
|
||||||
}
|
|
||||||
catch (UriFormatException ex)
|
|
||||||
{
|
|
||||||
Logger.LogError(ex, "Image location {Path} specified in nfo file for {ItemName} is not a valid URL or file path.", val, item.Name);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1256,5 +1242,24 @@ namespace MediaBrowser.XbmcMetadata.Parsers
|
|||||||
|
|
||||||
return string.IsNullOrWhiteSpace(value) ? Array.Empty<string>() : value.Split(separator, StringSplitOptions.RemoveEmptyEntries);
|
return string.IsNullOrWhiteSpace(value) ? Array.Empty<string>() : value.Split(separator, StringSplitOptions.RemoveEmptyEntries);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Parses the ImageType from the nfo aspect property.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="aspect">The nfo aspect property.</param>
|
||||||
|
/// <returns>The image type.</returns>
|
||||||
|
private static ImageType GetImageType(string aspect)
|
||||||
|
{
|
||||||
|
return aspect switch
|
||||||
|
{
|
||||||
|
"banner" => ImageType.Banner,
|
||||||
|
"clearlogo" => ImageType.Logo,
|
||||||
|
"discart" => ImageType.Disc,
|
||||||
|
"landscape" => ImageType.Thumb,
|
||||||
|
"clearart" => ImageType.Art,
|
||||||
|
// unknown type (including "poster") --> primary
|
||||||
|
_ => ImageType.Primary,
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user