mirror of
https://github.com/Sonarr/Sonarr.git
synced 2025-01-17 10:45:49 +02:00
Default to filename if there is no SceneName. And added Opus and MPEG-4 Visual.
This commit is contained in:
parent
f91e1a3576
commit
432666b2da
@ -242,13 +242,15 @@ public override MetadataFileResult EpisodeMetadata(Series series, EpisodeFile ep
|
||||
|
||||
if (episodeFile.MediaInfo != null)
|
||||
{
|
||||
var sceneName = episodeFile.GetSceneOrFileName();
|
||||
|
||||
var fileInfo = new XElement("fileinfo");
|
||||
var streamDetails = new XElement("streamdetails");
|
||||
|
||||
var video = new XElement("video");
|
||||
video.Add(new XElement("aspect", (float)episodeFile.MediaInfo.Width / (float)episodeFile.MediaInfo.Height));
|
||||
video.Add(new XElement("bitrate", episodeFile.MediaInfo.VideoBitrate));
|
||||
video.Add(new XElement("codec", MediaInfoFormatter.FormatVideoCodec(episodeFile.MediaInfo, episodeFile.SceneName)));
|
||||
video.Add(new XElement("codec", MediaInfoFormatter.FormatVideoCodec(episodeFile.MediaInfo, sceneName)));
|
||||
video.Add(new XElement("framerate", episodeFile.MediaInfo.VideoFps));
|
||||
video.Add(new XElement("height", episodeFile.MediaInfo.Height));
|
||||
video.Add(new XElement("scantype", episodeFile.MediaInfo.ScanType));
|
||||
@ -265,7 +267,7 @@ public override MetadataFileResult EpisodeMetadata(Series series, EpisodeFile ep
|
||||
var audio = new XElement("audio");
|
||||
audio.Add(new XElement("bitrate", episodeFile.MediaInfo.AudioBitrate));
|
||||
audio.Add(new XElement("channels", episodeFile.MediaInfo.AudioChannels));
|
||||
audio.Add(new XElement("codec", MediaInfoFormatter.FormatAudioCodec(episodeFile.MediaInfo, episodeFile.SceneName)));
|
||||
audio.Add(new XElement("codec", MediaInfoFormatter.FormatAudioCodec(episodeFile.MediaInfo, sceneName)));
|
||||
audio.Add(new XElement("language", episodeFile.MediaInfo.AudioLanguages));
|
||||
streamDetails.Add(audio);
|
||||
|
||||
|
@ -5,6 +5,7 @@
|
||||
using NzbDrone.Core.Qualities;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.MediaFiles.MediaInfo;
|
||||
using NzbDrone.Common.Extensions;
|
||||
|
||||
namespace NzbDrone.Core.MediaFiles
|
||||
{
|
||||
@ -27,5 +28,20 @@ public override string ToString()
|
||||
{
|
||||
return string.Format("[{0}] {1}", Id, RelativePath);
|
||||
}
|
||||
|
||||
public string GetSceneOrFileName()
|
||||
{
|
||||
if (SceneName.IsNotNullOrWhiteSpace())
|
||||
{
|
||||
return SceneName;
|
||||
}
|
||||
|
||||
if (RelativePath.IsNotNullOrWhiteSpace())
|
||||
{
|
||||
return System.IO.Path.GetFileName(RelativePath);
|
||||
}
|
||||
|
||||
return string.Empty;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -84,6 +84,11 @@ public static string FormatAudioCodec(MediaInfoModel mediaInfo, string sceneName
|
||||
return "Vorbis";
|
||||
}
|
||||
|
||||
if (audioFormat.Equals("Opus", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return "Opus";
|
||||
}
|
||||
|
||||
Logger.Error(new UnknownCodecException(audioFormat, sceneName), "Unknown audio format: {0} in '{1}'. Please notify Sonarr developers.", audioFormat, sceneName);
|
||||
return audioFormat;
|
||||
}
|
||||
@ -106,7 +111,7 @@ public static string FormatVideoCodec(MediaInfoModel mediaInfo, string sceneName
|
||||
|
||||
if (videoCodec == "V_MPEGH/ISO/HEVC" || videoCodec == "HEVC")
|
||||
{
|
||||
return sceneName.IsNotNullOrWhiteSpace() && Path.GetFileNameWithoutExtension(sceneName).Contains("h265")
|
||||
return sceneName.IsNotNullOrWhiteSpace() && Path.GetFileNameWithoutExtension(sceneName).ContainsIgnoreCase("h265")
|
||||
? "h265"
|
||||
: "x265";
|
||||
}
|
||||
@ -116,6 +121,13 @@ public static string FormatVideoCodec(MediaInfoModel mediaInfo, string sceneName
|
||||
return "MPEG2";
|
||||
}
|
||||
|
||||
if (videoCodec == "MPEG-4 Visual")
|
||||
{
|
||||
return sceneName.IsNotNullOrWhiteSpace() && Path.GetFileNameWithoutExtension(sceneName).ContainsIgnoreCase("DivX")
|
||||
? "DivX"
|
||||
: "XviD";
|
||||
}
|
||||
|
||||
if (videoCodec.StartsWith("XviD", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return "XviD";
|
||||
|
@ -454,8 +454,10 @@ private void AddMediaInfoTokens(Dictionary<string, Func<TokenMatch, string>> tok
|
||||
{
|
||||
if (episodeFile.MediaInfo == null) return;
|
||||
|
||||
var videoCodec = MediaInfoFormatter.FormatVideoCodec(episodeFile.MediaInfo, episodeFile.SceneName);
|
||||
var audioCodec = MediaInfoFormatter.FormatAudioCodec(episodeFile.MediaInfo, episodeFile.SceneName);
|
||||
var sceneName = episodeFile.GetSceneOrFileName();
|
||||
|
||||
var videoCodec = MediaInfoFormatter.FormatVideoCodec(episodeFile.MediaInfo, sceneName);
|
||||
var audioCodec = MediaInfoFormatter.FormatAudioCodec(episodeFile.MediaInfo, sceneName);
|
||||
var audioChannels = MediaInfoFormatter.FormatAudioChannels(episodeFile.MediaInfo);
|
||||
|
||||
var mediaInfoAudioLanguages = GetLanguagesToken(episodeFile.MediaInfo.AudioLanguages);
|
||||
|
Loading…
Reference in New Issue
Block a user