mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-03-15 14:46:19 +00:00
support dvd without video_ts folder
This commit is contained in:
@@ -18,17 +18,17 @@ namespace MediaBrowser.Server.Implementations.Drawing
|
||||
/// <param name="image">The image.</param>
|
||||
/// <param name="toStream">To stream.</param>
|
||||
/// <param name="quality">The quality.</param>
|
||||
public static void Save(this Image image, System.Drawing.Imaging.ImageFormat outputFormat, Stream toStream, int quality)
|
||||
public static void Save(this Image image, ImageFormat outputFormat, Stream toStream, int quality)
|
||||
{
|
||||
// Use special save methods for jpeg and png that will result in a much higher quality image
|
||||
// All other formats use the generic Image.Save
|
||||
if (System.Drawing.Imaging.ImageFormat.Jpeg.Equals(outputFormat))
|
||||
if (ImageFormat.Jpeg.Equals(outputFormat))
|
||||
{
|
||||
SaveAsJpeg(image, toStream, quality);
|
||||
}
|
||||
else if (System.Drawing.Imaging.ImageFormat.Png.Equals(outputFormat))
|
||||
else if (ImageFormat.Png.Equals(outputFormat))
|
||||
{
|
||||
image.Save(toStream, System.Drawing.Imaging.ImageFormat.Png);
|
||||
image.Save(toStream, ImageFormat.Png);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
using MediaBrowser.Common.IO;
|
||||
using MediaBrowser.Model.Drawing;
|
||||
using MediaBrowser.Model.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace MediaBrowser.Server.Implementations.Drawing
|
||||
/// <summary>
|
||||
/// The image format decoders
|
||||
/// </summary>
|
||||
private static readonly KeyValuePair<byte[], Func<BinaryReader, Size>>[] ImageFormatDecoders = new Dictionary<byte[], Func<BinaryReader, Size>>
|
||||
private static readonly KeyValuePair<byte[], Func<BinaryReader, ImageSize>>[] ImageFormatDecoders = new Dictionary<byte[], Func<BinaryReader, ImageSize>>
|
||||
{
|
||||
{ new byte[] { 0x42, 0x4D }, DecodeBitmap },
|
||||
{ new byte[] { 0x47, 0x49, 0x46, 0x38, 0x37, 0x61 }, DecodeGif },
|
||||
@@ -44,7 +44,7 @@ namespace MediaBrowser.Server.Implementations.Drawing
|
||||
/// <param name="fileSystem">The file system.</param>
|
||||
/// <returns>The dimensions of the specified image.</returns>
|
||||
/// <exception cref="ArgumentException">The image was of an unrecognised format.</exception>
|
||||
public static Size GetDimensions(string path, ILogger logger, IFileSystem fileSystem)
|
||||
public static ImageSize GetDimensions(string path, ILogger logger, IFileSystem fileSystem)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -71,9 +71,15 @@ namespace MediaBrowser.Server.Implementations.Drawing
|
||||
memoryStream.Position = 0;
|
||||
|
||||
// Co it the old fashioned way
|
||||
using (var b = Image.FromStream(memoryStream, true, false))
|
||||
using (var b = System.Drawing.Image.FromStream(memoryStream, true, false))
|
||||
{
|
||||
return b.Size;
|
||||
var size = b.Size;
|
||||
|
||||
return new ImageSize
|
||||
{
|
||||
Width = size.Width,
|
||||
Height = size.Height
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -86,7 +92,7 @@ namespace MediaBrowser.Server.Implementations.Drawing
|
||||
/// <returns>Size.</returns>
|
||||
/// <exception cref="System.ArgumentException">binaryReader</exception>
|
||||
/// <exception cref="ArgumentException">The image was of an unrecognized format.</exception>
|
||||
private static Size GetDimensions(BinaryReader binaryReader)
|
||||
private static ImageSize GetDimensions(BinaryReader binaryReader)
|
||||
{
|
||||
var magicBytes = new byte[MaxMagicBytesLength];
|
||||
|
||||
@@ -161,12 +167,16 @@ namespace MediaBrowser.Server.Implementations.Drawing
|
||||
/// </summary>
|
||||
/// <param name="binaryReader">The binary reader.</param>
|
||||
/// <returns>Size.</returns>
|
||||
private static Size DecodeBitmap(BinaryReader binaryReader)
|
||||
private static ImageSize DecodeBitmap(BinaryReader binaryReader)
|
||||
{
|
||||
binaryReader.ReadBytes(16);
|
||||
int width = binaryReader.ReadInt32();
|
||||
int height = binaryReader.ReadInt32();
|
||||
return new Size(width, height);
|
||||
return new ImageSize
|
||||
{
|
||||
Width = width,
|
||||
Height = height
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -174,11 +184,15 @@ namespace MediaBrowser.Server.Implementations.Drawing
|
||||
/// </summary>
|
||||
/// <param name="binaryReader">The binary reader.</param>
|
||||
/// <returns>Size.</returns>
|
||||
private static Size DecodeGif(BinaryReader binaryReader)
|
||||
private static ImageSize DecodeGif(BinaryReader binaryReader)
|
||||
{
|
||||
int width = binaryReader.ReadInt16();
|
||||
int height = binaryReader.ReadInt16();
|
||||
return new Size(width, height);
|
||||
return new ImageSize
|
||||
{
|
||||
Width = width,
|
||||
Height = height
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -186,12 +200,16 @@ namespace MediaBrowser.Server.Implementations.Drawing
|
||||
/// </summary>
|
||||
/// <param name="binaryReader">The binary reader.</param>
|
||||
/// <returns>Size.</returns>
|
||||
private static Size DecodePng(BinaryReader binaryReader)
|
||||
private static ImageSize DecodePng(BinaryReader binaryReader)
|
||||
{
|
||||
binaryReader.ReadBytes(8);
|
||||
int width = ReadLittleEndianInt32(binaryReader);
|
||||
int height = ReadLittleEndianInt32(binaryReader);
|
||||
return new Size(width, height);
|
||||
return new ImageSize
|
||||
{
|
||||
Width = width,
|
||||
Height = height
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -200,7 +218,7 @@ namespace MediaBrowser.Server.Implementations.Drawing
|
||||
/// <param name="binaryReader">The binary reader.</param>
|
||||
/// <returns>Size.</returns>
|
||||
/// <exception cref="System.ArgumentException"></exception>
|
||||
private static Size DecodeJfif(BinaryReader binaryReader)
|
||||
private static ImageSize DecodeJfif(BinaryReader binaryReader)
|
||||
{
|
||||
while (binaryReader.ReadByte() == 0xff)
|
||||
{
|
||||
@@ -211,7 +229,11 @@ namespace MediaBrowser.Server.Implementations.Drawing
|
||||
binaryReader.ReadByte();
|
||||
int height = ReadLittleEndianInt16(binaryReader);
|
||||
int width = ReadLittleEndianInt16(binaryReader);
|
||||
return new Size(width, height);
|
||||
return new ImageSize
|
||||
{
|
||||
Width = width,
|
||||
Height = height
|
||||
};
|
||||
}
|
||||
|
||||
if (chunkLength < 0)
|
||||
|
||||
@@ -515,7 +515,7 @@ namespace MediaBrowser.Server.Implementations.Drawing
|
||||
filename += "b=" + backgroundColor;
|
||||
}
|
||||
|
||||
return GetCachePath(ResizedImageCachePath, filename, Path.GetExtension(originalPath));
|
||||
return GetCachePath(ResizedImageCachePath, filename, "." + format.ToString().ToLower());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -94,6 +94,23 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (IsDvdFile(filename))
|
||||
{
|
||||
videoInfo = parser.ResolveDirectory(args.Path);
|
||||
|
||||
if (videoInfo == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
video = new TVideoType
|
||||
{
|
||||
Path = args.Path,
|
||||
VideoType = VideoType.Dvd,
|
||||
ProductionYear = videoInfo.Year
|
||||
};
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (video != null)
|
||||
@@ -228,6 +245,16 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers
|
||||
return string.Equals(directoryName, "video_ts", StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether [is DVD file] [the specified name].
|
||||
/// </summary>
|
||||
/// <param name="name">The name.</param>
|
||||
/// <returns><c>true</c> if [is DVD file] [the specified name]; otherwise, <c>false</c>.</returns>
|
||||
protected bool IsDvdFile(string name)
|
||||
{
|
||||
return string.Equals(name, "video_ts.ifo", StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether [is blu ray directory] [the specified directory name].
|
||||
/// </summary>
|
||||
@@ -237,15 +264,5 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers
|
||||
{
|
||||
return string.Equals(directoryName, "bdmv", StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
protected bool IsBluRayContainer(string path, IDirectoryService directoryService)
|
||||
{
|
||||
return directoryService.GetDirectories(path).Any(i => IsBluRayDirectory(i.Name));
|
||||
}
|
||||
|
||||
protected bool IsDvdContainer(string path, IDirectoryService directoryService)
|
||||
{
|
||||
return directoryService.GetDirectories(path).Any(i => IsDvdDirectory(i.Name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -117,7 +117,7 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Movies
|
||||
FullName = i.FullName,
|
||||
Type = FileInfoType.File
|
||||
|
||||
}).ToList());
|
||||
}).ToList()).ToList();
|
||||
|
||||
var result = new MultiItemResolverResult
|
||||
{
|
||||
@@ -125,6 +125,8 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Movies
|
||||
Items = videos
|
||||
};
|
||||
|
||||
var isInMixedFolder = resolverResult.Count > 0;
|
||||
|
||||
foreach (var video in resolverResult)
|
||||
{
|
||||
var firstVideo = video.Files.First();
|
||||
@@ -132,7 +134,7 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Movies
|
||||
var videoItem = new T
|
||||
{
|
||||
Path = video.Files[0].Path,
|
||||
IsInMixedFolder = true,
|
||||
IsInMixedFolder = isInMixedFolder,
|
||||
ProductionYear = video.Year,
|
||||
Name = video.Name,
|
||||
AdditionalParts = video.Files.Skip(1).Select(i => i.Path).ToList()
|
||||
@@ -171,7 +173,7 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Movies
|
||||
|
||||
if (string.Equals(collectionType, CollectionType.HomeVideos, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return FindMovie<Video>(args.Path, args.Parent, args.FileSystemChildren.ToList(), args.DirectoryService, collectionType);
|
||||
return FindMovie<Video>(args.Path, args.Parent, args.FileSystemChildren.ToList(), args.DirectoryService, collectionType, false);
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(collectionType))
|
||||
@@ -275,8 +277,9 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Movies
|
||||
/// <param name="fileSystemEntries">The file system entries.</param>
|
||||
/// <param name="directoryService">The directory service.</param>
|
||||
/// <param name="collectionType">Type of the collection.</param>
|
||||
/// <param name="supportMultiVersion">if set to <c>true</c> [support multi version].</param>
|
||||
/// <returns>Movie.</returns>
|
||||
private T FindMovie<T>(string path, Folder parent, List<FileSystemInfo> fileSystemEntries, IDirectoryService directoryService, string collectionType)
|
||||
private T FindMovie<T>(string path, Folder parent, List<FileSystemInfo> fileSystemEntries, IDirectoryService directoryService, string collectionType, bool supportMultiVersion = true)
|
||||
where T : Video, new()
|
||||
{
|
||||
var multiDiscFolders = new List<FileSystemInfo>();
|
||||
@@ -311,12 +314,22 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Movies
|
||||
|
||||
multiDiscFolders.Add(child);
|
||||
}
|
||||
else if (IsDvdFile(filename))
|
||||
{
|
||||
var movie = new T
|
||||
{
|
||||
Path = path,
|
||||
VideoType = VideoType.Dvd
|
||||
};
|
||||
Set3DFormat(movie);
|
||||
return movie;
|
||||
}
|
||||
}
|
||||
|
||||
var result = ResolveVideos<T>(parent, fileSystemEntries, directoryService, collectionType);
|
||||
|
||||
// Test for multi-editions
|
||||
if (result.Items.Count > 1)
|
||||
if (result.Items.Count > 1 && supportMultiVersion)
|
||||
{
|
||||
var filenamePrefix = Path.GetFileName(path);
|
||||
|
||||
@@ -327,6 +340,7 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Movies
|
||||
var movie = (T)result.Items[0];
|
||||
movie.Name = filenamePrefix;
|
||||
movie.LocalAlternateVersions = result.Items.Skip(1).Select(i => i.Path).ToList();
|
||||
movie.IsInMixedFolder = false;
|
||||
|
||||
_logger.Debug("Multi-version video found: " + movie.Path);
|
||||
|
||||
@@ -364,7 +378,11 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Movies
|
||||
|
||||
var folderPaths = multiDiscFolders.Select(i => i.FullName).Where(i =>
|
||||
{
|
||||
var subfolders = directoryService.GetDirectories(i)
|
||||
var subFileEntries = directoryService.GetFileSystemEntries(i)
|
||||
.ToList();
|
||||
|
||||
var subfolders = subFileEntries
|
||||
.Where(e => (e.Attributes & FileAttributes.Directory) == FileAttributes.Directory)
|
||||
.Select(d => d.Name)
|
||||
.ToList();
|
||||
|
||||
@@ -379,6 +397,16 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Movies
|
||||
return true;
|
||||
}
|
||||
|
||||
var subFiles = subFileEntries
|
||||
.Where(e => (e.Attributes & FileAttributes.Directory) != FileAttributes.Directory)
|
||||
.Select(d => d.Name);
|
||||
|
||||
if (subFiles.Any(IsDvdFile))
|
||||
{
|
||||
videoTypes.Add(VideoType.Dvd);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}).OrderBy(i => i).ToList();
|
||||
|
||||
@@ -220,19 +220,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv
|
||||
}
|
||||
|
||||
return 2;
|
||||
})
|
||||
.ThenBy(i =>
|
||||
{
|
||||
double number = 0;
|
||||
|
||||
if (!string.IsNullOrEmpty(i.Number))
|
||||
{
|
||||
double.TryParse(i.Number, out number);
|
||||
}
|
||||
|
||||
return number;
|
||||
|
||||
}).ThenBy(i => i.Name);
|
||||
});
|
||||
|
||||
var allChannels = channels.ToList();
|
||||
IEnumerable<LiveTvChannel> allEnumerable = allChannels;
|
||||
|
||||
@@ -51,7 +51,7 @@
|
||||
</Reference>
|
||||
<Reference Include="MediaBrowser.Naming, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\MediaBrowser.Naming.1.0.0.15\lib\portable-net45+sl4+wp71+win8+wpa81\MediaBrowser.Naming.dll</HintPath>
|
||||
<HintPath>..\packages\MediaBrowser.Naming.1.0.0.16\lib\portable-net45+sl4+wp71+win8+wpa81\MediaBrowser.Naming.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Mono.Nat, Version=1.2.21.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="MediaBrowser.Naming" version="1.0.0.15" targetFramework="net45" />
|
||||
<package id="MediaBrowser.Naming" version="1.0.0.16" targetFramework="net45" />
|
||||
<package id="Mono.Nat" version="1.2.21.0" targetFramework="net45" />
|
||||
<package id="morelinq" version="1.1.0" targetFramework="net45" />
|
||||
</packages>
|
||||
Reference in New Issue
Block a user