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

Taloth Saldono 7 years ago
parent f91e1a3576
commit 432666b2da

@ -242,13 +242,15 @@ namespace NzbDrone.Core.Extras.Metadata.Consumers.Xbmc
if (episodeFile.MediaInfo != null) if (episodeFile.MediaInfo != null)
{ {
var sceneName = episodeFile.GetSceneOrFileName();
var fileInfo = new XElement("fileinfo"); var fileInfo = new XElement("fileinfo");
var streamDetails = new XElement("streamdetails"); var streamDetails = new XElement("streamdetails");
var video = new XElement("video"); var video = new XElement("video");
video.Add(new XElement("aspect", (float)episodeFile.MediaInfo.Width / (float)episodeFile.MediaInfo.Height)); 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("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("framerate", episodeFile.MediaInfo.VideoFps));
video.Add(new XElement("height", episodeFile.MediaInfo.Height)); video.Add(new XElement("height", episodeFile.MediaInfo.Height));
video.Add(new XElement("scantype", episodeFile.MediaInfo.ScanType)); video.Add(new XElement("scantype", episodeFile.MediaInfo.ScanType));
@ -265,7 +267,7 @@ namespace NzbDrone.Core.Extras.Metadata.Consumers.Xbmc
var audio = new XElement("audio"); var audio = new XElement("audio");
audio.Add(new XElement("bitrate", episodeFile.MediaInfo.AudioBitrate)); audio.Add(new XElement("bitrate", episodeFile.MediaInfo.AudioBitrate));
audio.Add(new XElement("channels", episodeFile.MediaInfo.AudioChannels)); 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)); audio.Add(new XElement("language", episodeFile.MediaInfo.AudioLanguages));
streamDetails.Add(audio); streamDetails.Add(audio);

@ -5,6 +5,7 @@ using NzbDrone.Core.Datastore;
using NzbDrone.Core.Qualities; using NzbDrone.Core.Qualities;
using NzbDrone.Core.Tv; using NzbDrone.Core.Tv;
using NzbDrone.Core.MediaFiles.MediaInfo; using NzbDrone.Core.MediaFiles.MediaInfo;
using NzbDrone.Common.Extensions;
namespace NzbDrone.Core.MediaFiles namespace NzbDrone.Core.MediaFiles
{ {
@ -27,5 +28,20 @@ namespace NzbDrone.Core.MediaFiles
{ {
return string.Format("[{0}] {1}", Id, RelativePath); 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 @@ namespace NzbDrone.Core.MediaFiles.MediaInfo
return "Vorbis"; 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); Logger.Error(new UnknownCodecException(audioFormat, sceneName), "Unknown audio format: {0} in '{1}'. Please notify Sonarr developers.", audioFormat, sceneName);
return audioFormat; return audioFormat;
} }
@ -106,7 +111,7 @@ namespace NzbDrone.Core.MediaFiles.MediaInfo
if (videoCodec == "V_MPEGH/ISO/HEVC" || videoCodec == "HEVC") 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" ? "h265"
: "x265"; : "x265";
} }
@ -116,6 +121,13 @@ namespace NzbDrone.Core.MediaFiles.MediaInfo
return "MPEG2"; return "MPEG2";
} }
if (videoCodec == "MPEG-4 Visual")
{
return sceneName.IsNotNullOrWhiteSpace() && Path.GetFileNameWithoutExtension(sceneName).ContainsIgnoreCase("DivX")
? "DivX"
: "XviD";
}
if (videoCodec.StartsWith("XviD", StringComparison.OrdinalIgnoreCase)) if (videoCodec.StartsWith("XviD", StringComparison.OrdinalIgnoreCase))
{ {
return "XviD"; return "XviD";

@ -454,8 +454,10 @@ namespace NzbDrone.Core.Organizer
{ {
if (episodeFile.MediaInfo == null) return; if (episodeFile.MediaInfo == null) return;
var videoCodec = MediaInfoFormatter.FormatVideoCodec(episodeFile.MediaInfo, episodeFile.SceneName); var sceneName = episodeFile.GetSceneOrFileName();
var audioCodec = MediaInfoFormatter.FormatAudioCodec(episodeFile.MediaInfo, episodeFile.SceneName);
var videoCodec = MediaInfoFormatter.FormatVideoCodec(episodeFile.MediaInfo, sceneName);
var audioCodec = MediaInfoFormatter.FormatAudioCodec(episodeFile.MediaInfo, sceneName);
var audioChannels = MediaInfoFormatter.FormatAudioChannels(episodeFile.MediaInfo); var audioChannels = MediaInfoFormatter.FormatAudioChannels(episodeFile.MediaInfo);
var mediaInfoAudioLanguages = GetLanguagesToken(episodeFile.MediaInfo.AudioLanguages); var mediaInfoAudioLanguages = GetLanguagesToken(episodeFile.MediaInfo.AudioLanguages);

Loading…
Cancel
Save