Merge branch 'master' into userdb-efcore

# Conflicts:
#	Emby.Server.Implementations/Data/SqliteUserDataRepository.cs
#	Emby.Server.Implementations/Library/UserManager.cs
#	Jellyfin.Data/Entities/User.cs
#	Jellyfin.Data/ISavingChanges.cs
#	Jellyfin.Server.Implementations/Jellyfin.Server.Implementations.csproj
#	Jellyfin.Server.Implementations/JellyfinDb.cs
#	Jellyfin.Server/Migrations/MigrationRunner.cs
#	MediaBrowser.Model/Notifications/NotificationOptions.cs
#	MediaBrowser.sln
This commit is contained in:
Patrick Barron
2020-05-12 22:22:20 -04:00
116 changed files with 1763 additions and 883 deletions

View File

@@ -1,8 +1,8 @@
#pragma warning disable CS1591
using System;
using System.Linq;
using System.Xml.Serialization;
using MediaBrowser.Model.Extensions;
namespace MediaBrowser.Model.Dlna
{
@@ -57,7 +57,7 @@ namespace MediaBrowser.Model.Dlna
foreach (var val in codec)
{
if (ListHelper.ContainsIgnoreCase(codecs, val))
if (codecs.Contains(val, StringComparer.OrdinalIgnoreCase))
{
return true;
}

View File

@@ -1,8 +1,8 @@
#pragma warning disable CS1591
using System;
using System.Linq;
using System.Globalization;
using MediaBrowser.Model.Extensions;
using MediaBrowser.Model.MediaInfo;
namespace MediaBrowser.Model.Dlna
@@ -167,9 +167,7 @@ namespace MediaBrowser.Model.Dlna
switch (condition.Condition)
{
case ProfileConditionType.EqualsAny:
{
return ListHelper.ContainsIgnoreCase(expected.Split('|'), currentValue);
}
return expected.Split('|').Contains(currentValue, StringComparer.OrdinalIgnoreCase);
case ProfileConditionType.Equals:
return string.Equals(currentValue, expected, StringComparison.OrdinalIgnoreCase);
case ProfileConditionType.NotEquals:

View File

@@ -1,8 +1,8 @@
#pragma warning disable CS1591
using System;
using System.Linq;
using System.Xml.Serialization;
using MediaBrowser.Model.Extensions;
namespace MediaBrowser.Model.Dlna
{
@@ -45,7 +45,7 @@ namespace MediaBrowser.Model.Dlna
public static bool ContainsContainer(string profileContainers, string inputContainer)
{
var isNegativeList = false;
if (profileContainers != null && profileContainers.StartsWith("-"))
if (profileContainers != null && profileContainers.StartsWith("-", StringComparison.Ordinal))
{
isNegativeList = true;
profileContainers = profileContainers.Substring(1);
@@ -72,7 +72,7 @@ namespace MediaBrowser.Model.Dlna
foreach (var container in allInputContainers)
{
if (ListHelper.ContainsIgnoreCase(profileContainers, container))
if (profileContainers.Contains(container, StringComparer.OrdinalIgnoreCase))
{
return false;
}
@@ -86,7 +86,7 @@ namespace MediaBrowser.Model.Dlna
foreach (var container in allInputContainers)
{
if (ListHelper.ContainsIgnoreCase(profileContainers, container))
if (profileContainers.Contains(container, StringComparer.OrdinalIgnoreCase))
{
return true;
}

View File

@@ -1,8 +1,8 @@
#pragma warning disable CS1591
using System;
using System.Linq;
using System.Xml.Serialization;
using MediaBrowser.Model.Extensions;
using MediaBrowser.Model.MediaInfo;
namespace MediaBrowser.Model.Dlna
@@ -93,14 +93,14 @@ namespace MediaBrowser.Model.Dlna
public DeviceProfile()
{
DirectPlayProfiles = new DirectPlayProfile[] { };
TranscodingProfiles = new TranscodingProfile[] { };
ResponseProfiles = new ResponseProfile[] { };
CodecProfiles = new CodecProfile[] { };
ContainerProfiles = new ContainerProfile[] { };
DirectPlayProfiles = Array.Empty<DirectPlayProfile>();
TranscodingProfiles = Array.Empty<TranscodingProfile>();
ResponseProfiles = Array.Empty<ResponseProfile>();
CodecProfiles = Array.Empty<CodecProfile>();
ContainerProfiles = Array.Empty<ContainerProfile>();
SubtitleProfiles = Array.Empty<SubtitleProfile>();
XmlRootAttributes = new XmlAttribute[] { };
XmlRootAttributes = Array.Empty<XmlAttribute>();
SupportedMediaTypes = "Audio,Photo,Video";
MaxStreamingBitrate = 8000000;
@@ -129,13 +129,14 @@ namespace MediaBrowser.Model.Dlna
continue;
}
if (!ListHelper.ContainsIgnoreCase(i.GetAudioCodecs(), audioCodec ?? string.Empty))
if (!i.GetAudioCodecs().Contains(audioCodec ?? string.Empty, StringComparer.OrdinalIgnoreCase))
{
continue;
}
return i;
}
return null;
}
@@ -155,7 +156,7 @@ namespace MediaBrowser.Model.Dlna
continue;
}
if (!ListHelper.ContainsIgnoreCase(i.GetAudioCodecs(), audioCodec ?? string.Empty))
if (!i.GetAudioCodecs().Contains(audioCodec ?? string.Empty, StringComparer.OrdinalIgnoreCase))
{
continue;
}
@@ -185,7 +186,7 @@ namespace MediaBrowser.Model.Dlna
}
var audioCodecs = i.GetAudioCodecs();
if (audioCodecs.Length > 0 && !ListHelper.ContainsIgnoreCase(audioCodecs, audioCodec ?? string.Empty))
if (audioCodecs.Length > 0 && !audioCodecs.Contains(audioCodec ?? string.Empty, StringComparer.OrdinalIgnoreCase))
{
continue;
}
@@ -288,13 +289,13 @@ namespace MediaBrowser.Model.Dlna
}
var audioCodecs = i.GetAudioCodecs();
if (audioCodecs.Length > 0 && !ListHelper.ContainsIgnoreCase(audioCodecs, audioCodec ?? string.Empty))
if (audioCodecs.Length > 0 && !audioCodecs.Contains(audioCodec ?? string.Empty, StringComparer.OrdinalIgnoreCase))
{
continue;
}
var videoCodecs = i.GetVideoCodecs();
if (videoCodecs.Length > 0 && !ListHelper.ContainsIgnoreCase(videoCodecs, videoCodec ?? string.Empty))
if (videoCodecs.Length > 0 && !videoCodecs.Contains(videoCodec ?? string.Empty, StringComparer.OrdinalIgnoreCase))
{
continue;
}

View File

@@ -1,7 +1,8 @@
#pragma warning disable CS1591
using System;
using System.Linq;
using System.Xml.Serialization;
using MediaBrowser.Model.Extensions;
namespace MediaBrowser.Model.Dlna
{
@@ -40,7 +41,7 @@ namespace MediaBrowser.Model.Dlna
}
var languages = GetLanguages();
return languages.Length == 0 || ListHelper.ContainsIgnoreCase(languages, subLanguage);
return languages.Length == 0 || languages.Contains(subLanguage, StringComparer.OrdinalIgnoreCase);
}
}
}

View File

@@ -0,0 +1,48 @@
using System;
namespace MediaBrowser.Model.Dto
{
/// <summary>
/// Class PublicUserDto. Its goal is to show only public information about a user
/// </summary>
public class PublicUserDto : IItemDto
{
/// <summary>
/// Gets or sets the name.
/// </summary>
/// <value>The name.</value>
public string Name { get; set; }
/// <summary>
/// Gets or sets the primary image tag.
/// </summary>
/// <value>The primary image tag.</value>
public string PrimaryImageTag { get; set; }
/// <summary>
/// Gets or sets a value indicating whether this instance has password.
/// </summary>
/// <value><c>true</c> if this instance has password; otherwise, <c>false</c>.</value>
public bool HasPassword { get; set; }
/// <summary>
/// Gets or sets a value indicating whether this instance has configured password.
/// Note that in this case this method should not be here, but it is necessary when changing password at the
/// first login.
/// </summary>
/// <value><c>true</c> if this instance has configured password; otherwise, <c>false</c>.</value>
public bool HasConfiguredPassword { get; set; }
/// <summary>
/// Gets or sets the primary image aspect ratio.
/// </summary>
/// <value>The primary image aspect ratio.</value>
public double? PrimaryImageAspectRatio { get; set; }
/// <inheritdoc />
public override string ToString()
{
return Name ?? base.ToString();
}
}
}

View File

@@ -1,27 +0,0 @@
#pragma warning disable CS1591
using System;
namespace MediaBrowser.Model.Extensions
{
// TODO: @bond remove
public static class ListHelper
{
public static bool ContainsIgnoreCase(string[] list, string value)
{
if (value == null)
{
throw new ArgumentNullException(nameof(value));
}
foreach (var item in list)
{
if (string.Equals(item, value, StringComparison.OrdinalIgnoreCase))
{
return true;
}
}
return false;
}
}
}

View File

@@ -17,115 +17,132 @@ namespace MediaBrowser.Model.Net
/// </summary>
private static readonly HashSet<string> _videoFileExtensions = new HashSet<string>(StringComparer.OrdinalIgnoreCase)
{
".mkv",
".m2t",
".m2ts",
".img",
".iso",
".mk3d",
".ts",
".rmvb",
".mov",
".3gp",
".asf",
".avi",
".mpg",
".mpeg",
".wmv",
".mp4",
".divx",
".dvr-ms",
".wtv",
".f4v",
".flv",
".img",
".iso",
".m2t",
".m2ts",
".m2v",
".m4v",
".mk3d",
".mkv",
".mov",
".mp4",
".mpg",
".mpeg",
".mts",
".ogg",
".ogm",
".ogv",
".asf",
".m4v",
".flv",
".f4v",
".3gp",
".rec",
".ts",
".rmvb",
".webm",
".mts",
".m2v",
".rec"
".wmv",
".wtv",
};
// http://en.wikipedia.org/wiki/Internet_media_type
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types
// http://www.iana.org/assignments/media-types/media-types.xhtml
// Add more as needed
private static readonly Dictionary<string, string> _mimeTypeLookup = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase)
{
// Type application
{ ".7z", "application/x-7z-compressed" },
{ ".azw", "application/vnd.amazon.ebook" },
{ ".azw3", "application/vnd.amazon.ebook" },
{ ".cbz", "application/x-cbz" },
{ ".cbr", "application/epub+zip" },
{ ".eot", "application/vnd.ms-fontobject" },
{ ".epub", "application/epub+zip" },
{ ".js", "application/x-javascript" },
{ ".json", "application/json" },
{ ".map", "application/x-javascript" },
{ ".pdf", "application/pdf" },
{ ".ttml", "application/ttml+xml" },
{ ".m3u8", "application/x-mpegURL" },
{ ".map", "application/x-javascript" },
{ ".mobi", "application/x-mobipocket-ebook" },
{ ".xml", "application/xml" },
{ ".pdf", "application/pdf" },
{ ".rar", "application/vnd.rar" },
{ ".srt", "application/x-subrip" },
{ ".ttml", "application/ttml+xml" },
{ ".wasm", "application/wasm" },
{ ".xml", "application/xml" },
{ ".zip", "application/zip" },
// Type image
{ ".bmp", "image/bmp" },
{ ".gif", "image/gif" },
{ ".ico", "image/vnd.microsoft.icon" },
{ ".jpg", "image/jpeg" },
{ ".jpeg", "image/jpeg" },
{ ".tbn", "image/jpeg" },
{ ".png", "image/png" },
{ ".gif", "image/gif" },
{ ".tiff", "image/tiff" },
{ ".webp", "image/webp" },
{ ".ico", "image/vnd.microsoft.icon" },
{ ".svg", "image/svg+xml" },
{ ".svgz", "image/svg+xml" },
{ ".tbn", "image/jpeg" },
{ ".tif", "image/tiff" },
{ ".tiff", "image/tiff" },
{ ".webp", "image/webp" },
// Type font
{ ".ttf" , "font/ttf" },
{ ".woff" , "font/woff" },
{ ".woff2" , "font/woff2" },
// Type text
{ ".ass", "text/x-ssa" },
{ ".ssa", "text/x-ssa" },
{ ".css", "text/css" },
{ ".csv", "text/csv" },
{ ".rtf", "text/rtf" },
{ ".txt", "text/plain" },
{ ".vtt", "text/vtt" },
// Type video
{ ".mpg", "video/mpeg" },
{ ".ogv", "video/ogg" },
{ ".mov", "video/quicktime" },
{ ".webm", "video/webm" },
{ ".mkv", "video/x-matroska" },
{ ".wmv", "video/x-ms-wmv" },
{ ".flv", "video/x-flv" },
{ ".avi", "video/x-msvideo" },
{ ".asf", "video/x-ms-asf" },
{ ".m4v", "video/x-m4v" },
{ ".m4s", "video/mp4" },
{ ".3gp", "video/3gpp" },
{ ".3g2", "video/3gpp2" },
{ ".mpd", "video/vnd.mpeg.dash.mpd" },
{ ".ts", "video/mp2t" },
{ ".asf", "video/x-ms-asf" },
{ ".avi", "video/x-msvideo" },
{ ".flv", "video/x-flv" },
{ ".mp4", "video/mp4" },
{ ".m4s", "video/mp4" },
{ ".m4v", "video/x-m4v" },
{ ".mpegts", "video/mp2t" },
{ ".mpg", "video/mpeg" },
{ ".mkv", "video/x-matroska" },
{ ".mov", "video/quicktime" },
{ ".mpd", "video/vnd.mpeg.dash.mpd" },
{ ".ogv", "video/ogg" },
{ ".ts", "video/mp2t" },
{ ".webm", "video/webm" },
{ ".wmv", "video/x-ms-wmv" },
// Type audio
{ ".mp3", "audio/mpeg" },
{ ".m4a", "audio/mp4" },
{ ".aac", "audio/mp4" },
{ ".webma", "audio/webm" },
{ ".wav", "audio/wav" },
{ ".wma", "audio/x-ms-wma" },
{ ".ogg", "audio/ogg" },
{ ".oga", "audio/ogg" },
{ ".opus", "audio/ogg" },
{ ".ac3", "audio/ac3" },
{ ".ape", "audio/x-ape" },
{ ".dsf", "audio/dsf" },
{ ".m4b", "audio/m4b" },
{ ".xsp", "audio/xsp" },
{ ".dsp", "audio/dsp" },
{ ".flac", "audio/flac" },
{ ".ape", "audio/x-ape" },
{ ".m4a", "audio/mp4" },
{ ".m4b", "audio/m4b" },
{ ".mid", "audio/midi" },
{ ".midi", "audio/midi" },
{ ".mp3", "audio/mpeg" },
{ ".oga", "audio/ogg" },
{ ".ogg", "audio/ogg" },
{ ".opus", "audio/ogg" },
{ ".vorbis", "audio/vorbis" },
{ ".wav", "audio/wav" },
{ ".webma", "audio/webm" },
{ ".wma", "audio/x-ms-wma" },
{ ".wv", "audio/x-wavpack" },
{ ".xsp", "audio/xsp" },
};
private static readonly Dictionary<string, string> _extensionLookup = CreateExtensionLookup();

View File

@@ -3,6 +3,7 @@
using System;
using Jellyfin.Data.Enums;
using MediaBrowser.Model.Extensions;
using System.Linq;
using MediaBrowser.Model.Users;
namespace MediaBrowser.Model.Notifications
@@ -82,8 +83,12 @@ namespace MediaBrowser.Model.Notifications
{
foreach (NotificationOption i in Options)
{
if (string.Equals(type, i.Type, StringComparison.OrdinalIgnoreCase)) return i;
if (string.Equals(type, i.Type, StringComparison.OrdinalIgnoreCase))
{
return i;
}
}
return null;
}
@@ -99,7 +104,7 @@ namespace MediaBrowser.Model.Notifications
NotificationOption opt = GetOptions(notificationType);
return opt == null ||
!ListHelper.ContainsIgnoreCase(opt.DisabledServices, service);
!opt.DisabledServices.Contains(service, StringComparer.OrdinalIgnoreCase);
}
public bool IsEnabledToMonitorUser(string type, Guid userId)
@@ -107,7 +112,7 @@ namespace MediaBrowser.Model.Notifications
NotificationOption opt = GetOptions(type);
return opt != null && opt.Enabled &&
!ListHelper.ContainsIgnoreCase(opt.DisabledMonitorUsers, userId.ToString(""));
!opt.DisabledMonitorUsers.Contains(userId.ToString(""), StringComparer.OrdinalIgnoreCase);
}
public bool IsEnabledToSendToUser(string type, string userId, Jellyfin.Data.Entities.User user)
@@ -126,7 +131,7 @@ namespace MediaBrowser.Model.Notifications
return true;
}
return ListHelper.ContainsIgnoreCase(opt.SendToUsers, userId);
return opt.SendToUsers.Contains(userId, StringComparer.OrdinalIgnoreCase);
}
return false;