mirror of
https://github.com/Radarr/Radarr.git
synced 2026-04-22 22:15:17 -04:00
New: MediaInfo -> FFProbe
* New: MediaInfo -> FFProbe * Detect HDR format * Fix migration for users that tested early ffmpeg
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
@@ -69,6 +70,31 @@ namespace NzbDrone.Core.Organizer
|
||||
|
||||
private static readonly Regex ReservedDeviceNamesRegex = new Regex(@"^(?:aux|com[1-9]|con|lpt[1-9]|nul|prn)\.", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||
|
||||
// generated from https://www.loc.gov/standards/iso639-2/ISO-639-2_utf-8.txt
|
||||
public static readonly ImmutableDictionary<string, string> Iso639BTMap = new Dictionary<string, string>
|
||||
{
|
||||
{ "alb", "sqi" },
|
||||
{ "arm", "hye" },
|
||||
{ "baq", "eus" },
|
||||
{ "bur", "mya" },
|
||||
{ "chi", "zho" },
|
||||
{ "cze", "ces" },
|
||||
{ "dut", "nld" },
|
||||
{ "fre", "fra" },
|
||||
{ "geo", "kat" },
|
||||
{ "ger", "deu" },
|
||||
{ "gre", "ell" },
|
||||
{ "ice", "isl" },
|
||||
{ "mac", "mkd" },
|
||||
{ "mao", "mri" },
|
||||
{ "may", "msa" },
|
||||
{ "per", "fas" },
|
||||
{ "rum", "ron" },
|
||||
{ "slo", "slk" },
|
||||
{ "tib", "bod" },
|
||||
{ "wel", "cym" }
|
||||
}.ToImmutableDictionary();
|
||||
|
||||
public FileNameBuilder(INamingConfigService namingConfigService,
|
||||
IQualityDefinitionService qualityDefinitionService,
|
||||
IUpdateMediaInfo mediaInfoUpdater,
|
||||
@@ -344,8 +370,8 @@ namespace NzbDrone.Core.Organizer
|
||||
var videoCodec = MediaInfoFormatter.FormatVideoCodec(movieFile.MediaInfo, sceneName);
|
||||
var audioCodec = MediaInfoFormatter.FormatAudioCodec(movieFile.MediaInfo, sceneName);
|
||||
var audioChannels = MediaInfoFormatter.FormatAudioChannels(movieFile.MediaInfo);
|
||||
var audioLanguages = movieFile.MediaInfo.AudioLanguages ?? string.Empty;
|
||||
var subtitles = movieFile.MediaInfo.Subtitles ?? string.Empty;
|
||||
var audioLanguages = movieFile.MediaInfo.AudioLanguages ?? new List<string>();
|
||||
var subtitles = movieFile.MediaInfo.Subtitles ?? new List<string>();
|
||||
|
||||
var mediaInfoAudioLanguages = GetLanguagesToken(audioLanguages);
|
||||
if (!mediaInfoAudioLanguages.IsNullOrWhiteSpace())
|
||||
@@ -365,7 +391,7 @@ namespace NzbDrone.Core.Organizer
|
||||
mediaInfoSubtitleLanguages = $"[{mediaInfoSubtitleLanguages}]";
|
||||
}
|
||||
|
||||
var videoBitDepth = movieFile.MediaInfo.VideoBitDepth > 0 ? movieFile.MediaInfo.VideoBitDepth.ToString() : string.Empty;
|
||||
var videoBitDepth = movieFile.MediaInfo.VideoBitDepth > 0 ? movieFile.MediaInfo.VideoBitDepth.ToString() : 8.ToString();
|
||||
var audioChannelsFormatted = audioChannels > 0 ?
|
||||
audioChannels.ToString("F1", CultureInfo.InvariantCulture) :
|
||||
string.Empty;
|
||||
@@ -405,42 +431,29 @@ namespace NzbDrone.Core.Organizer
|
||||
tokenHandlers["{Custom Formats}"] = m => string.Join(" ", customFormats.Where(x => x.IncludeCustomFormatWhenRenaming));
|
||||
}
|
||||
|
||||
private string GetLanguagesToken(string mediaInfoLanguages)
|
||||
private string GetLanguagesToken(List<string> mediaInfoLanguages)
|
||||
{
|
||||
List<string> tokens = new List<string>();
|
||||
foreach (var item in mediaInfoLanguages.Split('/'))
|
||||
var tokens = new List<string>();
|
||||
foreach (var item in mediaInfoLanguages)
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(item))
|
||||
if (!string.IsNullOrWhiteSpace(item) && item != "und")
|
||||
{
|
||||
tokens.Add(item.Trim());
|
||||
}
|
||||
}
|
||||
|
||||
var cultures = CultureInfo.GetCultures(CultureTypes.NeutralCultures);
|
||||
for (int i = 0; i < tokens.Count; i++)
|
||||
{
|
||||
if (tokens[i] == "Swedis")
|
||||
{
|
||||
// Probably typo in mediainfo (should be 'Swedish')
|
||||
tokens[i] = "SV";
|
||||
continue;
|
||||
}
|
||||
|
||||
if (tokens[i] == "Chinese" && OsInfo.IsNotWindows)
|
||||
{
|
||||
// Mono only has 'Chinese (Simplified)' & 'Chinese (Traditional)'
|
||||
tokens[i] = "ZH";
|
||||
continue;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
var cultureInfo = cultures.FirstOrDefault(p => p.EnglishName.RemoveAccent() == tokens[i]);
|
||||
|
||||
if (cultureInfo != null)
|
||||
var token = tokens[i].ToLowerInvariant();
|
||||
if (Iso639BTMap.TryGetValue(token, out var mapped))
|
||||
{
|
||||
tokens[i] = cultureInfo.TwoLetterISOLanguageName.ToUpper();
|
||||
token = mapped;
|
||||
}
|
||||
|
||||
var cultureInfo = new CultureInfo(token);
|
||||
tokens[i] = cultureInfo.TwoLetterISOLanguageName.ToUpper();
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user