Merge pull request #15437 from allmazz/feat/more_file_metadata_tags

Add support for more embedded metadata tags
This commit is contained in:
Niels van Velzen 2025-11-27 16:31:42 +01:00 committed by GitHub
commit 45669c9b30
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 11 additions and 29 deletions

View file

@ -154,11 +154,12 @@ namespace MediaBrowser.MediaEncoding.Probing
info.Name = tags.GetFirstNotNullNorWhiteSpaceValue("title", "title-eng"); info.Name = tags.GetFirstNotNullNorWhiteSpaceValue("title", "title-eng");
info.ForcedSortName = tags.GetFirstNotNullNorWhiteSpaceValue("sort_name", "title-sort", "titlesort"); info.ForcedSortName = tags.GetFirstNotNullNorWhiteSpaceValue("sort_name", "title-sort", "titlesort");
info.Overview = tags.GetFirstNotNullNorWhiteSpaceValue("synopsis", "description", "desc"); info.Overview = tags.GetFirstNotNullNorWhiteSpaceValue("synopsis", "description", "desc", "comment");
info.IndexNumber = FFProbeHelpers.GetDictionaryNumericValue(tags, "episode_sort");
info.ParentIndexNumber = FFProbeHelpers.GetDictionaryNumericValue(tags, "season_number"); info.ParentIndexNumber = FFProbeHelpers.GetDictionaryNumericValue(tags, "season_number");
info.ShowName = tags.GetValueOrDefault("show_name"); info.IndexNumber = FFProbeHelpers.GetDictionaryNumericValue(tags, "episode_sort") ??
FFProbeHelpers.GetDictionaryNumericValue(tags, "episode_id");
info.ShowName = tags.GetValueOrDefault("show_name", "show");
info.ProductionYear = FFProbeHelpers.GetDictionaryNumericValue(tags, "date"); info.ProductionYear = FFProbeHelpers.GetDictionaryNumericValue(tags, "date");
// Several different forms of retail/premiere date // Several different forms of retail/premiere date

View file

@ -7,31 +7,6 @@ namespace Jellyfin.Extensions
/// </summary> /// </summary>
public static class DictionaryExtensions public static class DictionaryExtensions
{ {
/// <summary>
/// Gets a string from a string dictionary, checking all keys sequentially,
/// stopping at the first key that returns a result that's neither null nor blank.
/// </summary>
/// <param name="dictionary">The dictionary.</param>
/// <param name="key1">The first checked key.</param>
/// <returns>System.String.</returns>
public static string? GetFirstNotNullNorWhiteSpaceValue(this IReadOnlyDictionary<string, string> dictionary, string key1)
{
return dictionary.GetFirstNotNullNorWhiteSpaceValue(key1, string.Empty, string.Empty);
}
/// <summary>
/// Gets a string from a string dictionary, checking all keys sequentially,
/// stopping at the first key that returns a result that's neither null nor blank.
/// </summary>
/// <param name="dictionary">The dictionary.</param>
/// <param name="key1">The first checked key.</param>
/// <param name="key2">The second checked key.</param>
/// <returns>System.String.</returns>
public static string? GetFirstNotNullNorWhiteSpaceValue(this IReadOnlyDictionary<string, string> dictionary, string key1, string key2)
{
return dictionary.GetFirstNotNullNorWhiteSpaceValue(key1, key2, string.Empty);
}
/// <summary> /// <summary>
/// Gets a string from a string dictionary, checking all keys sequentially, /// Gets a string from a string dictionary, checking all keys sequentially,
/// stopping at the first key that returns a result that's neither null nor blank. /// stopping at the first key that returns a result that's neither null nor blank.
@ -40,8 +15,9 @@ namespace Jellyfin.Extensions
/// <param name="key1">The first checked key.</param> /// <param name="key1">The first checked key.</param>
/// <param name="key2">The second checked key.</param> /// <param name="key2">The second checked key.</param>
/// <param name="key3">The third checked key.</param> /// <param name="key3">The third checked key.</param>
/// <param name="key4">The fourth checked key.</param>
/// <returns>System.String.</returns> /// <returns>System.String.</returns>
public static string? GetFirstNotNullNorWhiteSpaceValue(this IReadOnlyDictionary<string, string> dictionary, string key1, string key2, string key3) public static string? GetFirstNotNullNorWhiteSpaceValue(this IReadOnlyDictionary<string, string> dictionary, string key1, string? key2 = null, string? key3 = null, string? key4 = null)
{ {
if (dictionary.TryGetValue(key1, out var val) && !string.IsNullOrWhiteSpace(val)) if (dictionary.TryGetValue(key1, out var val) && !string.IsNullOrWhiteSpace(val))
{ {
@ -58,6 +34,11 @@ namespace Jellyfin.Extensions
return val; return val;
} }
if (!string.IsNullOrEmpty(key4) && dictionary.TryGetValue(key4, out val) && !string.IsNullOrWhiteSpace(val))
{
return val;
}
return null; return null;
} }
} }