Default to filename if there is no SceneName. And added Opus and MPEG-4 Visual.

This commit is contained in:
Taloth Saldono 2017-07-29 18:28:17 +02:00
parent f91e1a3576
commit 432666b2da
4 changed files with 38 additions and 6 deletions

View File

@ -242,13 +242,15 @@ namespace NzbDrone.Core.Extras.Metadata.Consumers.Xbmc
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 @@ namespace NzbDrone.Core.Extras.Metadata.Consumers.Xbmc
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);

View File

@ -5,6 +5,7 @@ using NzbDrone.Core.Datastore;
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 @@ namespace NzbDrone.Core.MediaFiles
{
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;
}
}
}
}

View File

@ -84,6 +84,11 @@ namespace NzbDrone.Core.MediaFiles.MediaInfo
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 @@ namespace NzbDrone.Core.MediaFiles.MediaInfo
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 @@ namespace NzbDrone.Core.MediaFiles.MediaInfo
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";

View File

@ -454,8 +454,10 @@ namespace NzbDrone.Core.Organizer
{
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);