mirror of
https://github.com/lidarr/Lidarr
synced 2025-03-17 09:05:30 +00:00
Fixed: MediaInfo now also works on linux with unicode filenames.
This commit is contained in:
parent
20e40f73b3
commit
d4532c3856
1 changed files with 20 additions and 2 deletions
|
@ -1,9 +1,11 @@
|
||||||
using System;
|
using System;
|
||||||
|
using System.Globalization;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Text;
|
||||||
using MediaInfoLib;
|
using MediaInfoLib;
|
||||||
using NLog;
|
using NLog;
|
||||||
using NzbDrone.Common.Disk;
|
using NzbDrone.Common.Disk;
|
||||||
using System.Globalization;
|
using NzbDrone.Common.EnvironmentInfo;
|
||||||
|
|
||||||
namespace NzbDrone.Core.MediaFiles.MediaInfo
|
namespace NzbDrone.Core.MediaFiles.MediaInfo
|
||||||
{
|
{
|
||||||
|
@ -39,7 +41,19 @@ namespace NzbDrone.Core.MediaFiles.MediaInfo
|
||||||
_logger.Debug("Getting media info from {0}", filename);
|
_logger.Debug("Getting media info from {0}", filename);
|
||||||
|
|
||||||
mediaInfo.Option("ParseSpeed", "0.2");
|
mediaInfo.Option("ParseSpeed", "0.2");
|
||||||
int open = mediaInfo.Open(filename);
|
|
||||||
|
int open;
|
||||||
|
if (OsInfo.IsWindows)
|
||||||
|
{
|
||||||
|
open = mediaInfo.Open(filename);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// On non-Windows the wrapper uses the ansi library methods, which libmediainfo converts internally to unicode from multibyte (utf8).
|
||||||
|
// To avoid building MediaInfoDotNet ourselves we simply trick the wrapper to send utf8 strings instead of ansi.
|
||||||
|
var utf8filename = Encoding.Default.GetString(Encoding.UTF8.GetBytes(filename));
|
||||||
|
open = mediaInfo.Open(utf8filename);
|
||||||
|
}
|
||||||
|
|
||||||
if (open != 0)
|
if (open != 0)
|
||||||
{
|
{
|
||||||
|
@ -108,6 +122,10 @@ namespace NzbDrone.Core.MediaFiles.MediaInfo
|
||||||
|
|
||||||
return mediaInfoModel;
|
return mediaInfoModel;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_logger.Warn("Unable to open media info from file: " + filename);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (DllNotFoundException ex)
|
catch (DllNotFoundException ex)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Reference in a new issue