diff --git a/.dockerignore b/.dockerignore index fc4d8ed26d..54b0aa3a7e 100644 --- a/.dockerignore +++ b/.dockerignore @@ -3,3 +3,6 @@ Dockerfile CONTRIBUTORS.md README.md +deployment/*/dist +deployment/*/pkg-dist +deployment/collect-dist/ diff --git a/.drone.yml b/.drone.yml index c6d41b5554..98db4884bd 100644 --- a/.drone.yml +++ b/.drone.yml @@ -9,4 +9,4 @@ steps: - name: build image: microsoft/dotnet:2-sdk commands: - - dotnet publish --configuration release --output /release + - dotnet publish --configuration release --output /release Jellyfin.Server diff --git a/.editorconfig b/.editorconfig index a3b72c9af5..d3a988abc0 100644 --- a/.editorconfig +++ b/.editorconfig @@ -3,11 +3,11 @@ # For emacs, vim, np++ and other editors, see here: https://github.com/editorconfig ############################### # Core EditorConfig Options # -############################### +############################### +root = true # All files [*] indent_style = space -root = true indent_size = 4 charset = utf-8 trim_trailing_whitespace = true diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 0000000000..4abd39cfc5 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,35 @@ +--- +name: Bug report +about: Create a bug report +title: '' +labels: bug +assignees: '' + +--- + +**Describe the bug** +A clear and concise description of what the bug is. + +**To Reproduce** +Steps to reproduce the behavior: +1. Go to '...' +2. Click on '....' +3. Scroll down to '....' +4. See error + +**Expected behavior** +A clear and concise description of what you expected to happen. + +**Logs** +Please paste any log errors. + +**Screenshots** +If applicable, add screenshots to help explain your problem. + +**System (please complete the following information):** + - OS: [e.g. Docker, Debian, Windows] + - Browser: [e.g. Firefox, Chrome, Safari] + - Jellyfin Version: [e.g. 10.0.1] + +**Additional context** +Add any other context about the problem here. diff --git a/.github/ISSUE_TEMPLATE/enhancement-request.md b/.github/ISSUE_TEMPLATE/enhancement-request.md new file mode 100644 index 0000000000..57c0d4cae2 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/enhancement-request.md @@ -0,0 +1,20 @@ +--- +name: Enhancement request +about: Suggest an modification to an existing feature +title: '' +labels: enhancement +assignees: '' + +--- + +**Is your feature request related to a problem? Please describe.** +A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] + +**Describe the solution you'd like** +A clear and concise description of what you want to happen. + +**Describe alternatives you've considered** +A clear and concise description of any alternative solutions or features you've considered. + +**Additional context** +Add any other context or screenshots about the feature request here. diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 0000000000..a2ce072452 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,14 @@ +--- +name: Feature request +about: Suggest a new feature +title: '' +labels: feature +assignees: '' + +--- + +**Describe the feature you'd like** +A clear and concise description of what you want to happen. + +**Additional context** +Add any other context or screenshots about the feature request here. diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 0000000000..b2b3cf241e --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,9 @@ +Ensure your title is short, descriptive, and in the imperative mood (Fix X, Change Y, instead of Fixed X, Changed Y). +For a good inspiration of what to write in commit messages and PRs please review https://chris.beams.io/posts/git-commit/ and our https://jellyfin.readthedocs.io/en/latest/developer-docs/contributing/ page. + +**Changes** +Describe your changes here in 1-5 sentences. + +**Issues** +Tag any issues that this PR solves here. +Fixes # diff --git a/.gitignore b/.gitignore index 9309d315ae..ec683f38f6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,3 @@ -!* - .directory ################# @@ -49,6 +47,8 @@ ProgramData-UI*/ ## Ignore Visual Studio temporary files, build results, and ## files generated by popular Visual Studio add-ons. +.vs/ + # User-specific files *.suo *.user @@ -204,7 +204,6 @@ $RECYCLE.BIN/ # Mac crap .DS_Store - ############# ## Python ############# @@ -234,23 +233,33 @@ pip-log.txt #Mr Developer .mr.developer.cfg -.vs/ ########## # Rider ########## .idea/ +########## +# Visual Studio Code +########## +.vscode/ + ######################### -# Debian build artifacts +# Build artifacts ######################### -debian/.debhelper/ -debian/*.debhelper -debian/debhelper-build-stamp -debian/files -debian/jellyfin.substvars -debian/jellyfin/ - +# Artifacts for debian-x64 +deployment/debian-package-x64/pkg-src/.debhelper/ +deployment/debian-package-x64/pkg-src/*.debhelper +deployment/debian-package-x64/pkg-src/debhelper-build-stamp +deployment/debian-package-x64/pkg-src/files +deployment/debian-package-x64/pkg-src/jellyfin.substvars +deployment/debian-package-x64/pkg-src/jellyfin/ # Don't ignore the debian/bin folder -!debian/bin/ +!deployment/debian-package-x64/pkg-src/bin/ + +deployment/**/dist/ +deployment/**/pkg-dist/ +deployment/**/pkg-dist-tmp/ +deployment/collect-dist/ + diff --git a/BDInfo/BDInfo.csproj b/BDInfo/BDInfo.csproj index 403ecec4e8..b64f5e7a77 100644 --- a/BDInfo/BDInfo.csproj +++ b/BDInfo/BDInfo.csproj @@ -1,5 +1,9 @@  + + + + diff --git a/BDInfo/BDROM.cs b/BDInfo/BDROM.cs index f00d9825a8..7d8268222d 100644 --- a/BDInfo/BDROM.cs +++ b/BDInfo/BDROM.cs @@ -77,7 +77,7 @@ namespace BDInfo { if (string.IsNullOrEmpty(path)) { - throw new ArgumentNullException("path"); + throw new ArgumentNullException(nameof(path)); } _fileSystem = fileSystem; @@ -235,7 +235,7 @@ namespace BDInfo break; } } - else throw ex; + else throw; } } @@ -273,7 +273,7 @@ namespace BDInfo break; } } - else throw ex; + else throw; } } @@ -310,7 +310,7 @@ namespace BDInfo break; } } - else throw ex; + else throw; } } @@ -336,7 +336,7 @@ namespace BDInfo { if (string.IsNullOrEmpty(path)) { - throw new ArgumentNullException("path"); + throw new ArgumentNullException(nameof(path)); } FileSystemMetadata dir = _fileSystem.GetDirectoryInfo(path); diff --git a/BDInfo/Properties/AssemblyInfo.cs b/BDInfo/Properties/AssemblyInfo.cs index aa44da1909..77bd9df2ad 100644 --- a/BDInfo/Properties/AssemblyInfo.cs +++ b/BDInfo/Properties/AssemblyInfo.cs @@ -1,29 +1,21 @@ -using System.Resources; using System.Reflection; -using System.Runtime.CompilerServices; +using System.Resources; using System.Runtime.InteropServices; -// General Information about an assembly is controlled through the following +// General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyTitle("BDInfo")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("BDInfo")] -[assembly: AssemblyCopyright("Copyright © 2016")] +[assembly: AssemblyCompany("Jellyfin Project")] +[assembly: AssemblyProduct("Jellyfin: The Free Software Media System")] +[assembly: AssemblyCopyright("Copyright © 2016 CinemaSquid. Copyright © 2019 Jellyfin Contributors. Code released under the GNU General Public License Version 2")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] [assembly: NeutralResourcesLanguage("en")] -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.1")] \ No newline at end of file +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] diff --git a/BDInfo/TSCodecDTS.cs b/BDInfo/TSCodecDTS.cs index 58eb60fc59..904dcd986c 100644 --- a/BDInfo/TSCodecDTS.cs +++ b/BDInfo/TSCodecDTS.cs @@ -148,7 +148,7 @@ namespace BDInfo stream.IsVBR = true; stream.IsInitialized = true; break; - + default: stream.IsVBR = false; stream.IsInitialized = true; diff --git a/BDInfo/TSCodecDTSHD.cs b/BDInfo/TSCodecDTSHD.cs index 169a8077f2..3c5ad85cc5 100644 --- a/BDInfo/TSCodecDTSHD.cs +++ b/BDInfo/TSCodecDTSHD.cs @@ -22,9 +22,9 @@ namespace BDInfo { public abstract class TSCodecDTSHD { - private static int[] SampleRates = new int[] + private static int[] SampleRates = new int[] { 0x1F40, 0x3E80, 0x7D00, 0x0FA00, 0x1F400, 0x5622, 0x0AC44, 0x15888, 0x2B110, 0x56220, 0x2EE0, 0x5DC0, 0x0BB80, 0x17700, 0x2EE00, 0x5DC00 }; - + public static void Scan( TSAudioStream stream, TSStreamBuffer buffer, @@ -131,7 +131,7 @@ namespace BDInfo else { AssetSizes[i] = buffer.ReadBits(16) + 1; - } + } } for (int i = 0; i < nuNumAssets; i++) { @@ -189,7 +189,7 @@ namespace BDInfo } stream.SampleRate = SampleRates[nuMaxSampleRate]; stream.BitDepth = nuBitResolution; - + stream.LFE = 0; if ((nuSpkrActivityMask & 0x8) == 0x8) { @@ -240,7 +240,7 @@ namespace BDInfo stream.IsInitialized = true; } stream.IsInitialized = (stream.BitRate > 0 ? true : false); - } + } } } } diff --git a/BDInfo/TSCodecMPEG2.cs b/BDInfo/TSCodecMPEG2.cs index 3413a06e92..1d523528e0 100644 --- a/BDInfo/TSCodecMPEG2.cs +++ b/BDInfo/TSCodecMPEG2.cs @@ -33,7 +33,7 @@ namespace BDInfo int pictureParse = 0; int sequenceHeaderParse = 0; int extensionParse = 0; - int sequenceExtensionParse = 0; + int sequenceExtensionParse = 0; for (int i = 0; i < buffer.Length; i++) { @@ -189,7 +189,7 @@ namespace BDInfo #if DEBUG if (sequenceExtensionParse == 0) { - uint sequenceExtension = + uint sequenceExtension = ((parse & 0x8) >> 3); if (sequenceExtension == 0) { diff --git a/BDInfo/TSCodecTrueHD.cs b/BDInfo/TSCodecTrueHD.cs index baf4fa3dfe..6ea78614cf 100644 --- a/BDInfo/TSCodecTrueHD.cs +++ b/BDInfo/TSCodecTrueHD.cs @@ -36,7 +36,7 @@ namespace BDInfo for (int i = 0; i < buffer.Length; i++) { sync = (sync << 8) + buffer.ReadByte(); - if (sync == 0xF8726FBA) + if (sync == 0xF8726FBA) { syncFound = true; break; @@ -63,7 +63,7 @@ namespace BDInfo int ratebits = buffer.ReadBits(4); if (ratebits != 0xF) { - stream.SampleRate = + stream.SampleRate = (((ratebits & 8) > 0 ? 44100 : 48000) << (ratebits & 7)); } int temp1 = buffer.ReadBits(8); @@ -149,9 +149,9 @@ namespace BDInfo int peak_bitrate = buffer.ReadBits(15); peak_bitrate = (peak_bitrate * stream.SampleRate) >> 4; - double peak_bitdepth = - (double)peak_bitrate / - (stream.ChannelCount + stream.LFE) / + double peak_bitdepth = + (double)peak_bitrate / + (stream.ChannelCount + stream.LFE) / stream.SampleRate; if (peak_bitdepth > 14) { @@ -164,7 +164,7 @@ namespace BDInfo #if DEBUG System.Diagnostics.Debug.WriteLine(string.Format( - "{0}\t{1}\t{2:F2}", + "{0}\t{1}\t{2:F2}", stream.PID, peak_bitrate, peak_bitdepth)); #endif /* diff --git a/BDInfo/TSCodecVC1.cs b/BDInfo/TSCodecVC1.cs index 164ef8c47e..ce9eabdb91 100644 --- a/BDInfo/TSCodecVC1.cs +++ b/BDInfo/TSCodecVC1.cs @@ -50,18 +50,18 @@ namespace BDInfo { if ((parse & 0x80000000) == 0) { - pictureType = + pictureType = (uint)((parse & 0x78000000) >> 13); } else { - pictureType = + pictureType = (uint)((parse & 0x3c000000) >> 12); } } else { - pictureType = + pictureType = (uint)((parse & 0xf0000000) >> 14); } diff --git a/BDInfo/TSPlaylistFile.cs b/BDInfo/TSPlaylistFile.cs index da6fd37cc0..c4e8d62ec3 100644 --- a/BDInfo/TSPlaylistFile.cs +++ b/BDInfo/TSPlaylistFile.cs @@ -42,7 +42,7 @@ namespace BDInfo public List Chapters = new List(); - public Dictionary Streams = + public Dictionary Streams = new Dictionary(); public Dictionary PlaylistStreams = new Dictionary(); @@ -50,19 +50,19 @@ namespace BDInfo new List(); public List> AngleStreams = new List>(); - public List> AngleClips = + public List> AngleClips = new List>(); public int AngleCount = 0; - public List SortedStreams = + public List SortedStreams = new List(); - public List VideoStreams = + public List VideoStreams = new List(); - public List AudioStreams = + public List AudioStreams = new List(); - public List TextStreams = + public List TextStreams = new List(); - public List GraphicsStreams = + public List GraphicsStreams = new List(); public TSPlaylistFile( @@ -388,8 +388,8 @@ namespace BDInfo #if DEBUG Debug.WriteLine(string.Format( - "{0} : {1} -> V:{2} A:{3} PG:{4} IG:{5} 2A:{6} 2V:{7} PIP:{8}", - Name, streamFileName, streamCountVideo, streamCountAudio, streamCountPG, streamCountIG, + "{0} : {1} -> V:{2} A:{3} PG:{4} IG:{5} 2A:{6} 2V:{7} PIP:{8}", + Name, streamFileName, streamCountVideo, streamCountAudio, streamCountPG, streamCountIG, streamCountSecondaryAudio, streamCountSecondaryVideo, streamCountPIP)); #endif @@ -427,7 +427,7 @@ namespace BDInfo } /* * TODO - * + * for (int i = 0; i < streamCountPIP; i++) { TSStream stream = CreatePlaylistStream(data, ref pos); @@ -955,7 +955,7 @@ namespace BDInfo } public int CompareVideoStreams( - TSVideoStream x, + TSVideoStream x, TSVideoStream y) { if (x == null && y == null) @@ -996,7 +996,7 @@ namespace BDInfo } public int CompareAudioStreams( - TSAudioStream x, + TSAudioStream x, TSAudioStream y) { if (x == y) diff --git a/BDInfo/TSStream.cs b/BDInfo/TSStream.cs index 5afb81c5e4..250308b1a8 100644 --- a/BDInfo/TSStream.cs +++ b/BDInfo/TSStream.cs @@ -109,7 +109,7 @@ namespace BDInfo public TSDescriptor Clone() { - TSDescriptor descriptor = + TSDescriptor descriptor = new TSDescriptor(Name, (byte)Value.Length); Value.CopyTo(descriptor.Value, 0); return descriptor; @@ -153,15 +153,15 @@ namespace BDInfo private string _LanguageCode; public string LanguageCode { - get + get { - return _LanguageCode; + return _LanguageCode; } - set + set { _LanguageCode = value; LanguageName = LanguageCodes.GetName(value); - } + } } public bool IsVideoStream @@ -407,7 +407,7 @@ namespace BDInfo } public abstract TSStream Clone(); - + protected void CopyTo(TSStream stream) { stream.PID = PID; @@ -435,7 +435,7 @@ namespace BDInfo public int Width; public int Height; - public bool IsInterlaced; + public bool IsInterlaced; public int FrameRateEnumerator; public int FrameRateDenominator; public TSAspectRatio AspectRatio; @@ -581,7 +581,7 @@ namespace BDInfo stream.FrameRate = _FrameRate; stream.Width = Width; stream.Height = Height; - stream.IsInterlaced = IsInterlaced; + stream.IsInterlaced = IsInterlaced; stream.FrameRateEnumerator = FrameRateEnumerator; stream.FrameRateDenominator = FrameRateDenominator; stream.AspectRatio = AspectRatio; diff --git a/BDInfo/TSStreamClipFile.cs b/BDInfo/TSStreamClipFile.cs index f2accb88d8..f311dd8390 100644 --- a/BDInfo/TSStreamClipFile.cs +++ b/BDInfo/TSStreamClipFile.cs @@ -69,7 +69,7 @@ namespace BDInfo byte[] fileType = new byte[8]; Array.Copy(data, 0, fileType, 0, fileType.Length); - + FileType = _textEncoding.GetASCIIEncoding().GetString(fileType, 0, fileType.Length); if (FileType != "HDMV0100" && FileType != "HDMV0200") @@ -78,7 +78,7 @@ namespace BDInfo "Clip info file {0} has an unknown file type {1}.", FileInfo.Name, FileType)); } -#if DEBUG +#if DEBUG Debug.WriteLine(string.Format( "\tFileType: {0}", FileType)); #endif @@ -110,9 +110,9 @@ namespace BDInfo TSStream stream = null; ushort PID = (ushort) - ((clipData[streamOffset] << 8) + + ((clipData[streamOffset] << 8) + clipData[streamOffset + 1]); - + streamOffset += 2; TSStreamType streamType = (TSStreamType) @@ -240,7 +240,7 @@ namespace BDInfo } streamOffset += clipData[streamOffset] + 1; - } + } IsValid = true; } finally diff --git a/BDInfo/TSStreamFile.cs b/BDInfo/TSStreamFile.cs index cfd402434d..00e6b338e0 100644 --- a/BDInfo/TSStreamFile.cs +++ b/BDInfo/TSStreamFile.cs @@ -391,7 +391,7 @@ namespace BDInfo } Dictionary playlistStreams = playlist.Streams; - if (clip.AngleIndex > 0 && + if (clip.AngleIndex > 0 && clip.AngleIndex < playlist.AngleStreams.Count + 1) { playlistStreams = playlist.AngleStreams[clip.AngleIndex - 1]; @@ -428,7 +428,7 @@ namespace BDInfo TSStream stream = Streams[PID]; stream.PayloadBytes += streamState.WindowBytes; stream.PacketCount += streamState.WindowPackets; - + if (stream.IsVideoStream) { TSStreamDiagnostics diag = new TSStreamDiagnostics(); @@ -457,7 +457,7 @@ namespace BDInfo int dataSize = 16384; Stream fileStream = null; try - { + { string fileName; if (BDInfoSettings.EnableSSIF && InterleavedFile != null) @@ -482,13 +482,13 @@ namespace BDInfo StreamStates.Clear(); StreamDiagnostics.Clear(); - TSPacketParser parser = + TSPacketParser parser = new TSPacketParser(); - + long fileLength = (uint)fileStream.Length; byte[] buffer = new byte[dataSize]; int bufferLength = 0; - while ((bufferLength = + while ((bufferLength = fileStream.Read(buffer, 0, buffer.Length)) > 0) { int offset = 0; @@ -598,8 +598,8 @@ namespace BDInfo parser.StreamState.TransferCount++; bool isFinished = ScanStream( - parser.Stream, - parser.StreamState, + parser.Stream, + parser.StreamState, parser.StreamState.StreamBuffer); if (!isFullScan && isFinished) @@ -680,10 +680,10 @@ namespace BDInfo for (int k = 0; k < (parser.PATOffset - 4); k += 4) { uint programNumber = (uint) - ((parser.PAT[k] << 8) + + ((parser.PAT[k] << 8) + parser.PAT[k + 1]); - ushort programPID = (ushort) + ushort programPID = (ushort) (((parser.PAT[k + 2] & 0x1F) << 8) + parser.PAT[k + 3]); @@ -985,7 +985,7 @@ namespace BDInfo parser.PMTProgramDescriptorLength = buffer[i]; parser.PMTProgramDescriptors.Add( new TSDescriptor( - parser.PMTProgramDescriptor, + parser.PMTProgramDescriptor, parser.PMTProgramDescriptorLength)); break; } @@ -998,7 +998,7 @@ namespace BDInfo parser.PMTProgramDescriptors.Count - 1]; int valueIndex = - descriptor.Value.Length - + descriptor.Value.Length - parser.PMTProgramDescriptorLength - 1; descriptor.Value[valueIndex] = buffer[i]; @@ -1020,8 +1020,8 @@ namespace BDInfo parser.SyncState = false; } } - else if (parser.Stream != null && - parser.StreamState != null && + else if (parser.Stream != null && + parser.StreamState != null && parser.TransportScramblingControl == 0) { TSStream stream = parser.Stream; @@ -1032,7 +1032,7 @@ namespace BDInfo if (streamState.TransferState) { - if ((bufferLength - i) >= streamState.PacketLength && + if ((bufferLength - i) >= streamState.PacketLength && streamState.PacketLength > 0) { offset = streamState.PacketLength; @@ -1085,7 +1085,7 @@ namespace BDInfo --parser.PacketLength; bool headerFound = false; - if (stream.IsVideoStream && + if (stream.IsVideoStream && streamState.Parse == 0x000001FD) { headerFound = true; @@ -1170,18 +1170,18 @@ namespace BDInfo (byte)(streamState.Parse & 0xFF); #endif break; - + case 1: - streamState.PESHeaderFlags = + streamState.PESHeaderFlags = (byte)(streamState.Parse & 0xFF); #if DEBUG streamState.PESHeader[streamState.PESHeaderIndex++] = (byte)(streamState.Parse & 0xFF); #endif break; - + case 0: - streamState.PESHeaderLength = + streamState.PESHeaderLength = (byte)(streamState.Parse & 0xFF); #if DEBUG streamState.PESHeader[streamState.PESHeaderIndex++] = @@ -1211,48 +1211,48 @@ namespace BDInfo switch (streamState.PTSParse) { case 4: - streamState.PTSTemp = + streamState.PTSTemp = ((streamState.Parse & 0xE) << 29); #if DEBUG - streamState.PESHeader[streamState.PESHeaderIndex++] = + streamState.PESHeader[streamState.PESHeaderIndex++] = (byte)(streamState.Parse & 0xff); #endif break; - + case 3: - streamState.PTSTemp |= + streamState.PTSTemp |= ((streamState.Parse & 0xFF) << 22); #if DEBUG - streamState.PESHeader[streamState.PESHeaderIndex++] = + streamState.PESHeader[streamState.PESHeaderIndex++] = (byte)(streamState.Parse & 0xFF); #endif break; - + case 2: - streamState.PTSTemp |= + streamState.PTSTemp |= ((streamState.Parse & 0xFE) << 14); #if DEBUG - streamState.PESHeader[streamState.PESHeaderIndex++] = + streamState.PESHeader[streamState.PESHeaderIndex++] = (byte)(streamState.Parse & 0xFF); #endif break; - + case 1: - streamState.PTSTemp |= + streamState.PTSTemp |= ((streamState.Parse & 0xFF) << 7); #if DEBUG - streamState.PESHeader[streamState.PESHeaderIndex++] = + streamState.PESHeader[streamState.PESHeaderIndex++] = (byte)(streamState.Parse & 0xFF); #endif break; - + case 0: - streamState.PTSTemp |= + streamState.PTSTemp |= ((streamState.Parse & 0xFE) >> 1); #if DEBUG - streamState.PESHeader[streamState.PESHeaderIndex++] = + streamState.PESHeader[streamState.PESHeaderIndex++] = (byte)(streamState.Parse & 0xff); -#endif +#endif streamState.PTS = streamState.PTSTemp; if (streamState.PTS > streamState.PTSLast) @@ -1260,13 +1260,13 @@ namespace BDInfo if (streamState.PTSLast > 0) { streamState.PTSTransfer = (streamState.PTS - streamState.PTSLast); - } + } streamState.PTSLast = streamState.PTS; } streamState.PTSDiff = streamState.PTS - streamState.DTSPrev; - if (streamState.PTSCount > 0 && + if (streamState.PTSCount > 0 && stream.IsVideoStream) { UpdateStreamBitrates(stream.PID, streamState.PTS, streamState.PTSDiff); @@ -1280,7 +1280,7 @@ namespace BDInfo } Length = (double)(parser.PTSLast - parser.PTSFirst) / 90000; } - + streamState.DTSPrev = streamState.PTS; streamState.PTSCount++; if (streamState.PESHeaderLength == 0) @@ -1299,46 +1299,46 @@ namespace BDInfo switch (streamState.DTSParse) { case 9: - streamState.PTSTemp = + streamState.PTSTemp = ((streamState.Parse & 0xE) << 29); #if DEBUG - streamState.PESHeader[streamState.PESHeaderIndex++] = + streamState.PESHeader[streamState.PESHeaderIndex++] = (byte)(streamState.Parse & 0xFF); #endif break; - + case 8: - streamState.PTSTemp |= + streamState.PTSTemp |= ((streamState.Parse & 0xFF) << 22); #if DEBUG - streamState.PESHeader[streamState.PESHeaderIndex++] = + streamState.PESHeader[streamState.PESHeaderIndex++] = (byte)(streamState.Parse & 0xFF); #endif break; - + case 7: - streamState.PTSTemp |= + streamState.PTSTemp |= ((streamState.Parse & 0xFE) << 14); #if DEBUG - streamState.PESHeader[streamState.PESHeaderIndex++] = + streamState.PESHeader[streamState.PESHeaderIndex++] = (byte)(streamState.Parse & 0xff); #endif break; - + case 6: - streamState.PTSTemp |= + streamState.PTSTemp |= ((streamState.Parse & 0xFF) << 7); #if DEBUG - streamState.PESHeader[streamState.PESHeaderIndex++] = + streamState.PESHeader[streamState.PESHeaderIndex++] = (byte)(streamState.Parse & 0xFF); #endif break; - + case 5: - streamState.PTSTemp |= + streamState.PTSTemp |= ((streamState.Parse & 0xFE) >> 1); #if DEBUG - streamState.PESHeader[streamState.PESHeaderIndex++] = + streamState.PESHeader[streamState.PESHeaderIndex++] = (byte)(streamState.Parse & 0xff); #endif streamState.PTS = streamState.PTSTemp; @@ -1347,48 +1347,48 @@ namespace BDInfo streamState.PTSLast = streamState.PTS; } break; - + case 4: - streamState.DTSTemp = + streamState.DTSTemp = ((streamState.Parse & 0xE) << 29); #if DEBUG - streamState.PESHeader[streamState.PESHeaderIndex++] = + streamState.PESHeader[streamState.PESHeaderIndex++] = (byte)(streamState.Parse & 0xff); #endif break; - + case 3: - streamState.DTSTemp |= + streamState.DTSTemp |= ((streamState.Parse & 0xFF) << 22); #if DEBUG - streamState.PESHeader[streamState.PESHeaderIndex++] = + streamState.PESHeader[streamState.PESHeaderIndex++] = (byte)(streamState.Parse & 0xff); #endif break; - + case 2: - streamState.DTSTemp |= + streamState.DTSTemp |= ((streamState.Parse & 0xFE) << 14); #if DEBUG - streamState.PESHeader[streamState.PESHeaderIndex++] = + streamState.PESHeader[streamState.PESHeaderIndex++] = (byte)(streamState.Parse & 0xff); #endif break; - + case 1: - streamState.DTSTemp |= + streamState.DTSTemp |= ((streamState.Parse & 0xFF) << 7); #if DEBUG - streamState.PESHeader[streamState.PESHeaderIndex++] = + streamState.PESHeader[streamState.PESHeaderIndex++] = (byte)(streamState.Parse & 0xFF); #endif break; - + case 0: - streamState.DTSTemp |= + streamState.DTSTemp |= ((streamState.Parse & 0xFE) >> 1); #if DEBUG - streamState.PESHeader[streamState.PESHeaderIndex++] = + streamState.PESHeader[streamState.PESHeaderIndex++] = (byte)(streamState.Parse & 0xff); #endif streamState.PTSDiff = streamState.DTSTemp - streamState.DTSPrev; @@ -1482,8 +1482,8 @@ namespace BDInfo } private TSStream CreateStream( - ushort streamPID, - byte streamType, + ushort streamPID, + byte streamType, List streamDescriptors) { TSStream stream = null; @@ -1548,6 +1548,6 @@ namespace BDInfo } return stream; - } + } } } diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 80c1723091..f33f48fb33 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -11,7 +11,9 @@ - [AnthonyLavado](https://github.com/anthonylavado) - [sparky8251](https://github.com/sparky8251) - [LeoVerto](https://github.com/LeoVerto) - + - [grafixeyehero](https://github.com/grafixeyehero) + - [cvium](https://github.com/cvium) + # Emby Contributors - [LukePulverenti](https://github.com/LukePulverenti) diff --git a/Dockerfile b/Dockerfile index 75700e6f52..02332d40b4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -15,7 +15,10 @@ WORKDIR /repo COPY . . RUN export DOTNET_CLI_TELEMETRY_OPTOUT=1 \ && dotnet clean \ - && dotnet publish --configuration release --output /jellyfin + && dotnet publish \ + --configuration release \ + --output /jellyfin \ + Jellyfin.Server FROM microsoft/dotnet:${DOTNET_VERSION}-runtime @@ -23,6 +26,6 @@ COPY --from=builder /jellyfin /jellyfin COPY --from=ffmpeg /ffmpeg-bin/* /usr/bin/ EXPOSE 8096 VOLUME /config /media -RUN apt update \ - && apt install -y libfontconfig1 # needed for Skia +RUN apt-get update \ + && apt-get install -y libfontconfig1 --no-install-recommends # needed for Skia ENTRYPOINT dotnet /jellyfin/jellyfin.dll -programdata /config diff --git a/Dockerfile.aarch64 b/Dockerfile.arm similarity index 66% rename from Dockerfile.aarch64 rename to Dockerfile.arm index da4acc8412..a0b3d0e1da 100644 --- a/Dockerfile.aarch64 +++ b/Dockerfile.arm @@ -3,15 +3,19 @@ ARG DOTNET_VERSION=3.0 FROM microsoft/dotnet:${DOTNET_VERSION}-sdk as builder WORKDIR /repo COPY . . +#TODO Remove or update the sed line when we update dotnet version. RUN export DOTNET_CLI_TELEMETRY_OPTOUT=1 \ && find . -type f -exec sed -i 's/netcoreapp2.1/netcoreapp3.0/g' {} \; \ && dotnet clean \ - && dotnet publish --configuration release --output /jellyfin + && dotnet publish \ + --configuration release \ + --output /jellyfin \ + Jellyfin.Server FROM microsoft/dotnet:${DOTNET_VERSION}-runtime COPY --from=builder /jellyfin /jellyfin EXPOSE 8096 -RUN apt update \ - && apt install -y ffmpeg +RUN apt-get update \ + && apt-get install -y ffmpeg VOLUME /config /media ENTRYPOINT dotnet /jellyfin/jellyfin.dll -programdata /config diff --git a/DvdLib/DvdLib.csproj b/DvdLib/DvdLib.csproj index 403ecec4e8..b64f5e7a77 100644 --- a/DvdLib/DvdLib.csproj +++ b/DvdLib/DvdLib.csproj @@ -1,5 +1,9 @@  + + + + diff --git a/DvdLib/Ifo/Dvd.cs b/DvdLib/Ifo/Dvd.cs index 508c23db45..b43f0e8326 100644 --- a/DvdLib/Ifo/Dvd.cs +++ b/DvdLib/Ifo/Dvd.cs @@ -81,7 +81,7 @@ namespace DvdLib.Ifo private void ReadVTS(ushort vtsNum, List allFiles) { - var filename = String.Format("VTS_{0:00}_0.IFO", vtsNum); + var filename = string.Format("VTS_{0:00}_0.IFO", vtsNum); var vtsPath = allFiles.FirstOrDefault(i => string.Equals(i.Name, filename, StringComparison.OrdinalIgnoreCase)) ?? allFiles.FirstOrDefault(i => string.Equals(i.Name, Path.ChangeExtension(filename, ".bup"), StringComparison.OrdinalIgnoreCase)); diff --git a/DvdLib/Ifo/DvdTime.cs b/DvdLib/Ifo/DvdTime.cs index f565f5fdf7..072cd8d880 100644 --- a/DvdLib/Ifo/DvdTime.cs +++ b/DvdLib/Ifo/DvdTime.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -20,7 +20,7 @@ namespace DvdLib.Ifo else if ((data[3] & 0x40) != 0) FrameRate = 25; } - private byte GetBCDValue(byte data) + private static byte GetBCDValue(byte data) { return (byte)((((data & 0xF0) >> 4) * 10) + (data & 0x0F)); } diff --git a/DvdLib/Ifo/ProgramChain.cs b/DvdLib/Ifo/ProgramChain.cs index 6b4e5fa32f..85dfcea057 100644 --- a/DvdLib/Ifo/ProgramChain.cs +++ b/DvdLib/Ifo/ProgramChain.cs @@ -68,7 +68,7 @@ namespace DvdLib.Ifo ProhibitedUserOperations = (UserOperation)br.ReadUInt32(); AudioStreamControl = br.ReadBytes(16); SubpictureStreamControl = br.ReadBytes(128); - + _nextProgramNumber = br.ReadUInt16(); _prevProgramNumber = br.ReadUInt16(); _goupProgramNumber = br.ReadUInt16(); diff --git a/DvdLib/Ifo/Title.cs b/DvdLib/Ifo/Title.cs index 70deb45bfa..6ef83b4fb1 100644 --- a/DvdLib/Ifo/Title.cs +++ b/DvdLib/Ifo/Title.cs @@ -20,7 +20,7 @@ namespace DvdLib.Ifo public ProgramChain EntryProgramChain { get; private set; } public readonly List ProgramChains; - public readonly List Chapters; + public readonly List Chapters; public Title(uint titleNum) { diff --git a/DvdLib/Properties/AssemblyInfo.cs b/DvdLib/Properties/AssemblyInfo.cs index cca792684f..54e2c6b447 100644 --- a/DvdLib/Properties/AssemblyInfo.cs +++ b/DvdLib/Properties/AssemblyInfo.cs @@ -1,29 +1,21 @@ -using System.Resources; using System.Reflection; -using System.Runtime.CompilerServices; +using System.Resources; using System.Runtime.InteropServices; -// General Information about an assembly is controlled through the following +// General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyTitle("DvdLib")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("DvdLib")] -[assembly: AssemblyCopyright("Copyright © 2016")] +[assembly: AssemblyCompany("Jellyfin Project")] +[assembly: AssemblyProduct("Jellyfin: The Free Software Media System")] +[assembly: AssemblyCopyright("Copyright © 2019 Jellyfin Contributors. Code released under the GNU General Public License Version 2")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] [assembly: NeutralResourcesLanguage("en")] -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.1")] \ No newline at end of file +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] diff --git a/Emby.Dlna/Common/Argument.cs b/Emby.Dlna/Common/Argument.cs index 7e61c3d6d5..e6a220a7f4 100644 --- a/Emby.Dlna/Common/Argument.cs +++ b/Emby.Dlna/Common/Argument.cs @@ -1,6 +1,6 @@  namespace Emby.Dlna.Common -{ +{ public class Argument { public string Name { get; set; } diff --git a/Emby.Dlna/ConnectionManager/ConnectionManagerXmlBuilder.cs b/Emby.Dlna/ConnectionManager/ConnectionManagerXmlBuilder.cs index 0666eda229..db18025e65 100644 --- a/Emby.Dlna/ConnectionManager/ConnectionManagerXmlBuilder.cs +++ b/Emby.Dlna/ConnectionManager/ConnectionManagerXmlBuilder.cs @@ -1,4 +1,4 @@ -using Emby.Dlna.Common; +using Emby.Dlna.Common; using Emby.Dlna.Service; using System.Collections.Generic; @@ -11,7 +11,7 @@ namespace Emby.Dlna.ConnectionManager return new ServiceXmlBuilder().GetXml(new ServiceActionListBuilder().GetActions(), GetStateVariables()); } - private IEnumerable GetStateVariables() + private static IEnumerable GetStateVariables() { var list = new List(); diff --git a/Emby.Dlna/ConnectionManager/ServiceActionListBuilder.cs b/Emby.Dlna/ConnectionManager/ServiceActionListBuilder.cs index 9b22b77734..674bc4c8ee 100644 --- a/Emby.Dlna/ConnectionManager/ServiceActionListBuilder.cs +++ b/Emby.Dlna/ConnectionManager/ServiceActionListBuilder.cs @@ -1,4 +1,4 @@ -using Emby.Dlna.Common; +using Emby.Dlna.Common; using System.Collections.Generic; namespace Emby.Dlna.ConnectionManager @@ -19,7 +19,7 @@ namespace Emby.Dlna.ConnectionManager return list; } - private ServiceAction PrepareForConnection() + private static ServiceAction PrepareForConnection() { var action = new ServiceAction { @@ -77,8 +77,8 @@ namespace Emby.Dlna.ConnectionManager return action; } - - private ServiceAction GetCurrentConnectionInfo() + + private static ServiceAction GetCurrentConnectionInfo() { var action = new ServiceAction { diff --git a/Emby.Dlna/ContentDirectory/ContentDirectoryXmlBuilder.cs b/Emby.Dlna/ContentDirectory/ContentDirectoryXmlBuilder.cs index facc252146..2695a54332 100644 --- a/Emby.Dlna/ContentDirectory/ContentDirectoryXmlBuilder.cs +++ b/Emby.Dlna/ContentDirectory/ContentDirectoryXmlBuilder.cs @@ -1,4 +1,4 @@ -using Emby.Dlna.Common; +using Emby.Dlna.Common; using Emby.Dlna.Service; using System.Collections.Generic; @@ -8,11 +8,11 @@ namespace Emby.Dlna.ContentDirectory { public string GetXml() { - return new ServiceXmlBuilder().GetXml(new ServiceActionListBuilder().GetActions(), + return new ServiceXmlBuilder().GetXml(new ServiceActionListBuilder().GetActions(), GetStateVariables()); } - private IEnumerable GetStateVariables() + private static IEnumerable GetStateVariables() { var list = new List(); diff --git a/Emby.Dlna/ContentDirectory/ServiceActionListBuilder.cs b/Emby.Dlna/ContentDirectory/ServiceActionListBuilder.cs index 8e5c07ce2f..7749a39af8 100644 --- a/Emby.Dlna/ContentDirectory/ServiceActionListBuilder.cs +++ b/Emby.Dlna/ContentDirectory/ServiceActionListBuilder.cs @@ -1,4 +1,4 @@ -using Emby.Dlna.Common; +using Emby.Dlna.Common; using System.Collections.Generic; namespace Emby.Dlna.ContentDirectory @@ -20,7 +20,7 @@ namespace Emby.Dlna.ContentDirectory }; } - private ServiceAction GetGetSystemUpdateIDAction() + private static ServiceAction GetGetSystemUpdateIDAction() { var action = new ServiceAction { @@ -37,7 +37,7 @@ namespace Emby.Dlna.ContentDirectory return action; } - private ServiceAction GetSearchCapabilitiesAction() + private static ServiceAction GetSearchCapabilitiesAction() { var action = new ServiceAction { @@ -54,7 +54,7 @@ namespace Emby.Dlna.ContentDirectory return action; } - private ServiceAction GetSortCapabilitiesAction() + private static ServiceAction GetSortCapabilitiesAction() { var action = new ServiceAction { @@ -71,7 +71,7 @@ namespace Emby.Dlna.ContentDirectory return action; } - private ServiceAction GetX_GetFeatureListAction() + private static ServiceAction GetX_GetFeatureListAction() { var action = new ServiceAction { @@ -88,7 +88,7 @@ namespace Emby.Dlna.ContentDirectory return action; } - private ServiceAction GetSearchAction() + private static ServiceAction GetSearchAction() { var action = new ServiceAction { @@ -334,7 +334,7 @@ namespace Emby.Dlna.ContentDirectory return action; } - + private ServiceAction GetXSetBookmarkAction() { var action = new ServiceAction diff --git a/Emby.Dlna/Didl/DidlBuilder.cs b/Emby.Dlna/Didl/DidlBuilder.cs index 7af48ae17e..a8217c0d41 100644 --- a/Emby.Dlna/Didl/DidlBuilder.cs +++ b/Emby.Dlna/Didl/DidlBuilder.cs @@ -375,7 +375,7 @@ namespace Emby.Dlna.Didl ? GetMimeType(filename) : mediaProfile.MimeType; - writer.WriteAttributeString("protocolInfo", String.Format( + writer.WriteAttributeString("protocolInfo", string.Format( "http-get:*:{0}:{1}", mimeType, contentFeatures @@ -573,7 +573,7 @@ namespace Emby.Dlna.Didl streamInfo.RunTimeTicks ?? 0, streamInfo.TranscodeSeekInfo); - writer.WriteAttributeString("protocolInfo", String.Format( + writer.WriteAttributeString("protocolInfo", string.Format( "http-get:*:{0}:{1}", mimeType, contentFeatures @@ -1017,7 +1017,7 @@ namespace Emby.Dlna.Didl var contentFeatures = new ContentFeatureBuilder(_profile) .BuildImageHeader(format, width, height, imageInfo.IsDirectStream, org_Pn); - writer.WriteAttributeString("protocolInfo", String.Format( + writer.WriteAttributeString("protocolInfo", string.Format( "http-get:*:{0}:{1}", GetMimeType("file." + format), contentFeatures diff --git a/Emby.Dlna/DlnaManager.cs b/Emby.Dlna/DlnaManager.cs index 48a33757be..a8777cbac5 100644 --- a/Emby.Dlna/DlnaManager.cs +++ b/Emby.Dlna/DlnaManager.cs @@ -95,7 +95,7 @@ namespace Emby.Dlna { if (deviceInfo == null) { - throw new ArgumentNullException("deviceInfo"); + throw new ArgumentNullException(nameof(deviceInfo)); } var profile = GetProfiles() @@ -207,7 +207,7 @@ namespace Emby.Dlna { if (headers == null) { - throw new ArgumentNullException("headers"); + throw new ArgumentNullException(nameof(headers)); } // Convert to case insensitive @@ -335,7 +335,7 @@ namespace Emby.Dlna { if (string.IsNullOrEmpty(id)) { - throw new ArgumentNullException("id"); + throw new ArgumentNullException(nameof(id)); } var info = GetProfileInfosInternal().First(i => string.Equals(i.Info.Id, id, StringComparison.OrdinalIgnoreCase)); diff --git a/Emby.Dlna/Emby.Dlna.csproj b/Emby.Dlna/Emby.Dlna.csproj index c58144e00b..f48816453b 100644 --- a/Emby.Dlna/Emby.Dlna.csproj +++ b/Emby.Dlna/Emby.Dlna.csproj @@ -1,5 +1,9 @@  + + + + diff --git a/Emby.Dlna/IUpnpService.cs b/Emby.Dlna/IUpnpService.cs index caae87ba36..0a52e9acfc 100644 --- a/Emby.Dlna/IUpnpService.cs +++ b/Emby.Dlna/IUpnpService.cs @@ -10,7 +10,7 @@ namespace Emby.Dlna /// The headers. /// System.String. string GetServiceXml(IDictionary headers); - + /// /// Processes the control request. /// diff --git a/Emby.Dlna/Main/DlnaEntryPoint.cs b/Emby.Dlna/Main/DlnaEntryPoint.cs index 6ab0767a5a..eae3f22de4 100644 --- a/Emby.Dlna/Main/DlnaEntryPoint.cs +++ b/Emby.Dlna/Main/DlnaEntryPoint.cs @@ -75,11 +75,11 @@ namespace Emby.Dlna.Main IUserDataManager userDataManager, ILocalizationManager localizationManager, IMediaSourceManager mediaSourceManager, - IDeviceDiscovery deviceDiscovery, - IMediaEncoder mediaEncoder, - ISocketFactory socketFactory, - ITimerFactory timerFactory, - IEnvironmentInfo environmentInfo, + IDeviceDiscovery deviceDiscovery, + IMediaEncoder mediaEncoder, + ISocketFactory socketFactory, + ITimerFactory timerFactory, + IEnvironmentInfo environmentInfo, INetworkManager networkManager, IUserViewManager userViewManager, IXmlReaderSettingsFactory xmlReaderSettingsFactory, @@ -104,19 +104,19 @@ namespace Emby.Dlna.Main _networkManager = networkManager; _logger = loggerFactory.CreateLogger("Dlna"); - ContentDirectory = new ContentDirectory.ContentDirectory(dlnaManager, - userDataManager, - imageProcessor, - libraryManager, - config, - userManager, - _logger, - httpClient, - localizationManager, - mediaSourceManager, + ContentDirectory = new ContentDirectory.ContentDirectory(dlnaManager, + userDataManager, + imageProcessor, + libraryManager, + config, + userManager, + _logger, + httpClient, + localizationManager, + mediaSourceManager, userViewManager, - mediaEncoder, - xmlReaderSettingsFactory, + mediaEncoder, + xmlReaderSettingsFactory, tvSeriesManager); ConnectionManager = new ConnectionManager.ConnectionManager(dlnaManager, config, _logger, httpClient, xmlReaderSettingsFactory); @@ -271,12 +271,12 @@ namespace Emby.Dlna.Main var device = new SsdpRootDevice { CacheLifetime = TimeSpan.FromSeconds(1800), //How long SSDP clients can cache this info. - Location = uri, // Must point to the URL that serves your devices UPnP description document. + Location = uri, // Must point to the URL that serves your devices UPnP description document. FriendlyName = "Jellyfin", Manufacturer = "Jellyfin", ModelName = "Jellyfin Server", Uuid = udn - // This must be a globally unique value that survives reboots etc. Get from storage or embedded hardware etc. + // This must be a globally unique value that survives reboots etc. Get from storage or embedded hardware etc. }; SetProperies(device, fullService); @@ -297,7 +297,7 @@ namespace Emby.Dlna.Main Manufacturer = device.Manufacturer, ModelName = device.ModelName, Uuid = udn - // This must be a globally unique value that survives reboots etc. Get from storage or embedded hardware etc. + // This must be a globally unique value that survives reboots etc. Get from storage or embedded hardware etc. }; SetProperies(embeddedDevice, subDevice); diff --git a/Emby.Dlna/MediaReceiverRegistrar/ControlHandler.cs b/Emby.Dlna/MediaReceiverRegistrar/ControlHandler.cs index d1a595de0e..5ffa30f685 100644 --- a/Emby.Dlna/MediaReceiverRegistrar/ControlHandler.cs +++ b/Emby.Dlna/MediaReceiverRegistrar/ControlHandler.cs @@ -1,4 +1,4 @@ -using MediaBrowser.Common.Extensions; +using MediaBrowser.Common.Extensions; using MediaBrowser.Controller.Configuration; using Emby.Dlna.Server; using Emby.Dlna.Service; @@ -21,7 +21,7 @@ namespace Emby.Dlna.MediaReceiverRegistrar throw new ResourceNotFoundException("Unexpected control request name: " + methodName); } - private IEnumerable> HandleIsAuthorized() + private static IEnumerable> HandleIsAuthorized() { return new Dictionary(StringComparer.OrdinalIgnoreCase) { @@ -29,7 +29,7 @@ namespace Emby.Dlna.MediaReceiverRegistrar }; } - private IEnumerable> HandleIsValidated() + private static IEnumerable> HandleIsValidated() { return new Dictionary(StringComparer.OrdinalIgnoreCase) { diff --git a/Emby.Dlna/MediaReceiverRegistrar/MediaReceiverRegistrarXmlBuilder.cs b/Emby.Dlna/MediaReceiverRegistrar/MediaReceiverRegistrarXmlBuilder.cs index bc4bee7c92..efddbc6705 100644 --- a/Emby.Dlna/MediaReceiverRegistrar/MediaReceiverRegistrarXmlBuilder.cs +++ b/Emby.Dlna/MediaReceiverRegistrar/MediaReceiverRegistrarXmlBuilder.cs @@ -1,4 +1,4 @@ -using Emby.Dlna.Common; +using Emby.Dlna.Common; using Emby.Dlna.Service; using System.Collections.Generic; @@ -12,7 +12,7 @@ namespace Emby.Dlna.MediaReceiverRegistrar GetStateVariables()); } - private IEnumerable GetStateVariables() + private static IEnumerable GetStateVariables() { var list = new List(); diff --git a/Emby.Dlna/MediaReceiverRegistrar/ServiceActionListBuilder.cs b/Emby.Dlna/MediaReceiverRegistrar/ServiceActionListBuilder.cs index bce8bfaef3..a1f3284111 100644 --- a/Emby.Dlna/MediaReceiverRegistrar/ServiceActionListBuilder.cs +++ b/Emby.Dlna/MediaReceiverRegistrar/ServiceActionListBuilder.cs @@ -1,4 +1,4 @@ -using Emby.Dlna.Common; +using Emby.Dlna.Common; using System.Collections.Generic; namespace Emby.Dlna.MediaReceiverRegistrar @@ -19,7 +19,7 @@ namespace Emby.Dlna.MediaReceiverRegistrar }; } - private ServiceAction GetIsValidated() + private static ServiceAction GetIsValidated() { var action = new ServiceAction { @@ -41,7 +41,7 @@ namespace Emby.Dlna.MediaReceiverRegistrar return action; } - private ServiceAction GetIsAuthorized() + private static ServiceAction GetIsAuthorized() { var action = new ServiceAction { @@ -63,7 +63,7 @@ namespace Emby.Dlna.MediaReceiverRegistrar return action; } - private ServiceAction GetRegisterDevice() + private static ServiceAction GetRegisterDevice() { var action = new ServiceAction { @@ -85,7 +85,7 @@ namespace Emby.Dlna.MediaReceiverRegistrar return action; } - private ServiceAction GetGetValidationSucceededUpdateID() + private static ServiceAction GetGetValidationSucceededUpdateID() { var action = new ServiceAction { diff --git a/Emby.Dlna/PlayTo/Device.cs b/Emby.Dlna/PlayTo/Device.cs index 13bed6b2fd..cf53bb861e 100644 --- a/Emby.Dlna/PlayTo/Device.cs +++ b/Emby.Dlna/PlayTo/Device.cs @@ -311,7 +311,7 @@ namespace Emby.Dlna.PlayTo throw new InvalidOperationException("Unable to find service"); } - await new SsdpHttpClient(_httpClient, _config).SendCommandAsync(Properties.BaseUrl, service, command.Name, avCommands.BuildPost(command, service.ServiceType, String.Format("{0:hh}:{0:mm}:{0:ss}", value), "REL_TIME")) + await new SsdpHttpClient(_httpClient, _config).SendCommandAsync(Properties.BaseUrl, service, command.Name, avCommands.BuildPost(command, service.ServiceType, string.Format("{0:hh}:{0:mm}:{0:ss}", value), "REL_TIME")) .ConfigureAwait(false); RestartTimer(true); @@ -364,7 +364,7 @@ namespace Emby.Dlna.PlayTo private string CreateDidlMeta(string value) { if (string.IsNullOrEmpty(value)) - return String.Empty; + return string.Empty; return DescriptionXmlBuilder.Escape(value); } @@ -739,7 +739,7 @@ namespace Emby.Dlna.PlayTo if (track == null) { - //If track is null, some vendors do this, use GetMediaInfo instead + //If track is null, some vendors do this, use GetMediaInfo instead return new Tuple(true, null); } @@ -783,7 +783,7 @@ namespace Emby.Dlna.PlayTo { if (container == null) { - throw new ArgumentNullException("container"); + throw new ArgumentNullException(nameof(container)); } var url = container.GetValue(uPnpNamespaces.Res); @@ -810,7 +810,7 @@ namespace Emby.Dlna.PlayTo { if (container == null) { - throw new ArgumentNullException("container"); + throw new ArgumentNullException(nameof(container)); } var resElement = container.Element(uPnpNamespaces.Res); @@ -979,7 +979,7 @@ namespace Emby.Dlna.PlayTo if (modelDescription != null) deviceProperties.ModelDescription = modelDescription.Value; - deviceProperties.BaseUrl = String.Format("http://{0}:{1}", url.Host, url.Port); + deviceProperties.BaseUrl = string.Format("http://{0}:{1}", url.Host, url.Port); var icon = document.Descendants(uPnpNamespaces.ud.GetName("icon")).FirstOrDefault(); @@ -1021,7 +1021,7 @@ namespace Emby.Dlna.PlayTo { if (element == null) { - throw new ArgumentNullException("element"); + throw new ArgumentNullException(nameof(element)); } var mimeType = element.GetDescendantValue(uPnpNamespaces.ud.GetName("mimetype")); @@ -1173,7 +1173,7 @@ namespace Emby.Dlna.PlayTo public override string ToString() { - return String.Format("{0} - {1}", Properties.Name, Properties.BaseUrl); + return string.Format("{0} - {1}", Properties.Name, Properties.BaseUrl); } } } diff --git a/Emby.Dlna/PlayTo/PlayToController.cs b/Emby.Dlna/PlayTo/PlayToController.cs index c51f220ef5..c7e45b8964 100644 --- a/Emby.Dlna/PlayTo/PlayToController.cs +++ b/Emby.Dlna/PlayTo/PlayToController.cs @@ -114,10 +114,10 @@ namespace Emby.Dlna.PlayTo info.Headers.TryGetValue("NTS", out nts); string usn; - if (!info.Headers.TryGetValue("USN", out usn)) usn = String.Empty; + if (!info.Headers.TryGetValue("USN", out usn)) usn = string.Empty; string nt; - if (!info.Headers.TryGetValue("NT", out nt)) nt = String.Empty; + if (!info.Headers.TryGetValue("NT", out nt)) nt = string.Empty; if (usn.IndexOf(_device.Properties.UUID, StringComparison.OrdinalIgnoreCase) != -1 && !_disposed) @@ -829,7 +829,7 @@ namespace Emby.Dlna.PlayTo { if (string.IsNullOrEmpty(url)) { - throw new ArgumentNullException("url"); + throw new ArgumentNullException(nameof(url)); } var parts = url.Split('/'); @@ -855,7 +855,7 @@ namespace Emby.Dlna.PlayTo { if (string.IsNullOrEmpty(url)) { - throw new ArgumentNullException("url"); + throw new ArgumentNullException(nameof(url)); } var request = new StreamParams diff --git a/Emby.Dlna/PlayTo/PlaylistItemFactory.cs b/Emby.Dlna/PlayTo/PlaylistItemFactory.cs index e2d6e43c04..1080320e0c 100644 --- a/Emby.Dlna/PlayTo/PlaylistItemFactory.cs +++ b/Emby.Dlna/PlayTo/PlaylistItemFactory.cs @@ -1,4 +1,4 @@ -using MediaBrowser.Controller.Entities; +using MediaBrowser.Controller.Entities; using MediaBrowser.Model.Dlna; using MediaBrowser.Model.Session; using System; @@ -49,7 +49,7 @@ namespace Emby.Dlna.PlayTo return playlistItem; } - private bool IsSupported(DirectPlayProfile profile, Photo item) + private static bool IsSupported(DirectPlayProfile profile, Photo item) { var mediaPath = item.Path; diff --git a/Emby.Dlna/PlayTo/SsdpHttpClient.cs b/Emby.Dlna/PlayTo/SsdpHttpClient.cs index bfd163bf16..963577169b 100644 --- a/Emby.Dlna/PlayTo/SsdpHttpClient.cs +++ b/Emby.Dlna/PlayTo/SsdpHttpClient.cs @@ -1,4 +1,4 @@ -using MediaBrowser.Common.Net; +using MediaBrowser.Common.Net; using MediaBrowser.Controller.Configuration; using Emby.Dlna.Common; using System; @@ -25,10 +25,10 @@ namespace Emby.Dlna.PlayTo _config = config; } - public async Task SendCommandAsync(string baseUrl, - DeviceService service, - string command, - string postData, + public async Task SendCommandAsync(string baseUrl, + DeviceService service, + string command, + string postData, bool logRequest = true, string header = null) { @@ -47,7 +47,7 @@ namespace Emby.Dlna.PlayTo } } - private string NormalizeServiceUrl(string baseUrl, string serviceUrl) + private static string NormalizeServiceUrl(string baseUrl, string serviceUrl) { // If it's already a complete url, don't stick anything onto the front of it if (serviceUrl.StartsWith("http", StringComparison.OrdinalIgnoreCase)) @@ -62,12 +62,12 @@ namespace Emby.Dlna.PlayTo } private readonly CultureInfo _usCulture = new CultureInfo("en-US"); - - public async Task SubscribeAsync(string url, - string ip, - int port, - string localIp, - int eventport, + + public async Task SubscribeAsync(string url, + string ip, + int port, + string localIp, + int eventport, int timeOut = 3600) { var options = new HttpRequestOptions @@ -121,9 +121,9 @@ namespace Emby.Dlna.PlayTo } } - private Task PostSoapDataAsync(string url, - string soapAction, - string postData, + private Task PostSoapDataAsync(string url, + string soapAction, + string postData, string header, bool logRequest, CancellationToken cancellationToken) diff --git a/Emby.Dlna/PlayTo/TransportCommands.cs b/Emby.Dlna/PlayTo/TransportCommands.cs index 9e055f7921..e34ce87976 100644 --- a/Emby.Dlna/PlayTo/TransportCommands.cs +++ b/Emby.Dlna/PlayTo/TransportCommands.cs @@ -80,7 +80,7 @@ namespace Emby.Dlna.PlayTo { if (container == null) { - throw new ArgumentNullException("container"); + throw new ArgumentNullException(nameof(container)); } return new Argument @@ -171,7 +171,7 @@ namespace Emby.Dlna.PlayTo if (state != null) { var sendValue = state.AllowedValues.FirstOrDefault(a => string.Equals(a, commandParameter, StringComparison.OrdinalIgnoreCase)) ?? - state.AllowedValues.FirstOrDefault() ?? + state.AllowedValues.FirstOrDefault() ?? value; return string.Format("<{0} xmlns:dt=\"urn:schemas-microsoft-com:datatypes\" dt:dt=\"{1}\">{2}", argument.Name, state.DataType ?? "string", sendValue); diff --git a/Emby.Dlna/PlayTo/UpnpContainer.cs b/Emby.Dlna/PlayTo/UpnpContainer.cs index 5bfc56bff9..4c07f36053 100644 --- a/Emby.Dlna/PlayTo/UpnpContainer.cs +++ b/Emby.Dlna/PlayTo/UpnpContainer.cs @@ -10,7 +10,7 @@ namespace Emby.Dlna.PlayTo { if (container == null) { - throw new ArgumentNullException("container"); + throw new ArgumentNullException(nameof(container)); } return new uBaseObject diff --git a/Emby.Dlna/PlayTo/uBaseObject.cs b/Emby.Dlna/PlayTo/uBaseObject.cs index 1de46317eb..3d80d7ed04 100644 --- a/Emby.Dlna/PlayTo/uBaseObject.cs +++ b/Emby.Dlna/PlayTo/uBaseObject.cs @@ -2,7 +2,7 @@ namespace Emby.Dlna.PlayTo { - public class uBaseObject + public class uBaseObject { public string Id { get; set; } @@ -26,7 +26,7 @@ namespace Emby.Dlna.PlayTo { if (obj == null) { - throw new ArgumentNullException("obj"); + throw new ArgumentNullException(nameof(obj)); } return string.Equals(Id, obj.Id); diff --git a/Emby.Dlna/PlayTo/uParser.cs b/Emby.Dlna/PlayTo/uParser.cs index 5caf83a9a6..4d26ee6b37 100644 --- a/Emby.Dlna/PlayTo/uParser.cs +++ b/Emby.Dlna/PlayTo/uParser.cs @@ -20,13 +20,13 @@ namespace Emby.Dlna.PlayTo if (document == null) return list; - + var item = (from result in document.Descendants("Result") select result).FirstOrDefault(); if (item == null) return list; - var uPnpResponse = XElement.Parse((String)item); + var uPnpResponse = XElement.Parse((string)item); var uObjects = from container in uPnpResponse.Elements(uPnpNamespaces.containers) select new uParserObject { Element = container }; diff --git a/Emby.Dlna/Profiles/SonyBravia2010Profile.cs b/Emby.Dlna/Profiles/SonyBravia2010Profile.cs index 75382067ff..7b452c536c 100644 --- a/Emby.Dlna/Profiles/SonyBravia2010Profile.cs +++ b/Emby.Dlna/Profiles/SonyBravia2010Profile.cs @@ -41,7 +41,7 @@ namespace Emby.Dlna.Profiles EnableSingleAlbumArtLimit = true; EnableAlbumArtInDidl = true; - + TranscodingProfiles = new[] { new TranscodingProfile diff --git a/Emby.Dlna/Properties/AssemblyInfo.cs b/Emby.Dlna/Properties/AssemblyInfo.cs index 6f924f9e96..fd3b433699 100644 --- a/Emby.Dlna/Properties/AssemblyInfo.cs +++ b/Emby.Dlna/Properties/AssemblyInfo.cs @@ -1,17 +1,16 @@ -using System.Resources; +using System.Resources; using System.Reflection; -using System.Runtime.CompilerServices; using System.Runtime.InteropServices; -// General Information about an assembly is controlled through the following +// General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. -[assembly: AssemblyTitle("Emby.Dlna2")] +[assembly: AssemblyTitle("Emby.Dlna")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("Emby.Dlna2")] -[assembly: AssemblyCopyright("Copyright © 2016")] +[assembly: AssemblyCompany("Jellyfin Project")] +[assembly: AssemblyProduct("Jellyfin: The Free Software Media System")] +[assembly: AssemblyCopyright("Copyright © 2019 Jellyfin Contributors. Code released under the GNU General Public License Version 2")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] [assembly: NeutralResourcesLanguage("en")] @@ -19,12 +18,10 @@ using System.Runtime.InteropServices; // Version information for an assembly consists of the following four values: // // Major Version -// Minor Version +// Minor Version // Build Number // Revision // -// You can specify all the values or you can default the Build and Revision Numbers +// You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Emby.Dlna/Server/DescriptionXmlBuilder.cs b/Emby.Dlna/Server/DescriptionXmlBuilder.cs index 0c0c367e43..bd57f4c43f 100644 --- a/Emby.Dlna/Server/DescriptionXmlBuilder.cs +++ b/Emby.Dlna/Server/DescriptionXmlBuilder.cs @@ -1,4 +1,4 @@ -using Emby.Dlna.Common; +using Emby.Dlna.Common; using MediaBrowser.Model.Dlna; using MediaBrowser.Model.Extensions; using System; @@ -24,12 +24,12 @@ namespace Emby.Dlna.Server { if (string.IsNullOrEmpty(serverUdn)) { - throw new ArgumentNullException("serverUdn"); + throw new ArgumentNullException(nameof(serverUdn)); } if (string.IsNullOrEmpty(serverAddress)) { - throw new ArgumentNullException("serverAddress"); + throw new ArgumentNullException(nameof(serverAddress)); } _profile = profile; @@ -39,10 +39,7 @@ namespace Emby.Dlna.Server _serverId = serverId; } - private bool EnableAbsoluteUrls - { - get { return false; } - } + private static bool EnableAbsoluteUrls => false; public string GetXml() { diff --git a/Emby.Dlna/Service/BaseService.cs b/Emby.Dlna/Service/BaseService.cs index 92b81a7acc..10ef12c6c2 100644 --- a/Emby.Dlna/Service/BaseService.cs +++ b/Emby.Dlna/Service/BaseService.cs @@ -14,7 +14,7 @@ namespace Emby.Dlna.Service protected BaseService(ILogger logger, IHttpClient httpClient) { Logger = logger; - HttpClient = httpClient; + HttpClient = httpClient; EventManager = new EventManager(Logger, HttpClient); } diff --git a/Emby.Dlna/Service/ControlErrorHandler.cs b/Emby.Dlna/Service/ControlErrorHandler.cs index a3cd77f0fb..431dea9320 100644 --- a/Emby.Dlna/Service/ControlErrorHandler.cs +++ b/Emby.Dlna/Service/ControlErrorHandler.cs @@ -10,7 +10,7 @@ namespace Emby.Dlna.Service public class ControlErrorHandler { private const string NS_SOAPENV = "http://schemas.xmlsoap.org/soap/envelope/"; - + public ControlResponse GetResponse(Exception ex) { var settings = new XmlWriterSettings diff --git a/Emby.Dlna/Service/ServiceXmlBuilder.cs b/Emby.Dlna/Service/ServiceXmlBuilder.cs index c41f1b3bed..68782ffb76 100644 --- a/Emby.Dlna/Service/ServiceXmlBuilder.cs +++ b/Emby.Dlna/Service/ServiceXmlBuilder.cs @@ -1,4 +1,4 @@ -using Emby.Dlna.Common; +using Emby.Dlna.Common; using System.Collections.Generic; using System.Security; using System.Text; @@ -28,7 +28,7 @@ namespace Emby.Dlna.Service return builder.ToString(); } - private void AppendActionList(StringBuilder builder, IEnumerable actions) + private static void AppendActionList(StringBuilder builder, IEnumerable actions) { builder.Append(""); @@ -59,7 +59,7 @@ namespace Emby.Dlna.Service builder.Append(""); } - private void AppendServiceStateTable(StringBuilder builder, IEnumerable stateVariables) + private static void AppendServiceStateTable(StringBuilder builder, IEnumerable stateVariables) { builder.Append(""); diff --git a/Emby.Dlna/Ssdp/DeviceDiscovery.cs b/Emby.Dlna/Ssdp/DeviceDiscovery.cs index d91f711d2f..e01ff81497 100644 --- a/Emby.Dlna/Ssdp/DeviceDiscovery.cs +++ b/Emby.Dlna/Ssdp/DeviceDiscovery.cs @@ -83,8 +83,8 @@ namespace Emby.Dlna.Ssdp { _deviceLocator = new SsdpDeviceLocator(_commsServer, _timerFactory); - // (Optional) Set the filter so we only see notifications for devices we care about - // (can be any search target value i.e device type, uuid value etc - any value that appears in the + // (Optional) Set the filter so we only see notifications for devices we care about + // (can be any search target value i.e device type, uuid value etc - any value that appears in the // DiscoverdSsdpDevice.NotificationType property or that is used with the searchTarget parameter of the Search method). //_DeviceLocator.NotificationFilter = "upnp:rootdevice"; diff --git a/Emby.Drawing.Skia/Properties/AssemblyInfo.cs b/Emby.Drawing.Skia/Properties/AssemblyInfo.cs index c0dc7c5b4b..521010cdbd 100644 --- a/Emby.Drawing.Skia/Properties/AssemblyInfo.cs +++ b/Emby.Drawing.Skia/Properties/AssemblyInfo.cs @@ -1,25 +1,21 @@ -using System.Resources; using System.Reflection; -using System.Runtime.CompilerServices; +using System.Resources; using System.Runtime.InteropServices; -// General Information about an assembly is controlled through the following +// General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyTitle("Emby.Drawing.Skia")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("Emby.Drawing.Skia")] -[assembly: AssemblyCopyright("Copyright © 2017")] +[assembly: AssemblyCompany("Jellyfin Project")] +[assembly: AssemblyProduct("Jellyfin: The Free Software Media System")] +[assembly: AssemblyCopyright("Copyright © 2019 Jellyfin Contributors. Code released under the GNU General Public License Version 2")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] [assembly: NeutralResourcesLanguage("en")] -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// \ No newline at end of file +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] diff --git a/Emby.Drawing.Skia/SkiaEncoder.cs b/Emby.Drawing.Skia/SkiaEncoder.cs index 0467794dc9..dc5ae77ccc 100644 --- a/Emby.Drawing.Skia/SkiaEncoder.cs +++ b/Emby.Drawing.Skia/SkiaEncoder.cs @@ -197,7 +197,7 @@ namespace Emby.Drawing.Skia private static bool HasDiacritics(string text) { - return !String.Equals(text, text.RemoveDiacritics(), StringComparison.Ordinal); + return !string.Equals(text, text.RemoveDiacritics(), StringComparison.Ordinal); } private static bool RequiresSpecialCharacterHack(string path) @@ -509,11 +509,11 @@ namespace Emby.Drawing.Skia { if (string.IsNullOrWhiteSpace(inputPath)) { - throw new ArgumentNullException("inputPath"); + throw new ArgumentNullException(nameof(inputPath)); } if (string.IsNullOrWhiteSpace(inputPath)) { - throw new ArgumentNullException("outputPath"); + throw new ArgumentNullException(nameof(outputPath)); } var skiaOutputFormat = GetImageFormat(selectedOutputFormat); @@ -594,12 +594,12 @@ namespace Emby.Drawing.Skia // If foreground layer present then draw if (hasForegroundColor) { - if (!Double.TryParse(options.ForegroundLayer, out double opacity)) + if (!double.TryParse(options.ForegroundLayer, out double opacity)) { opacity = .4; } - canvas.DrawColor(new SKColor(0, 0, 0, (Byte)((1 - opacity) * 0xFF)), SKBlendMode.SrcOver); + canvas.DrawColor(new SKColor(0, 0, 0, (byte)((1 - opacity) * 0xFF)), SKBlendMode.SrcOver); } if (hasIndicator) diff --git a/Emby.Drawing.Skia/StripCollageBuilder.cs b/Emby.Drawing.Skia/StripCollageBuilder.cs index a98450e08b..b3e7dbb5fa 100644 --- a/Emby.Drawing.Skia/StripCollageBuilder.cs +++ b/Emby.Drawing.Skia/StripCollageBuilder.cs @@ -1,4 +1,4 @@ -using SkiaSharp; +using SkiaSharp; using MediaBrowser.Common.Configuration; using System; using System.IO; @@ -20,6 +20,11 @@ namespace Emby.Drawing.Skia public static SKEncodedImageFormat GetEncodedFormat(string outputPath) { + if (outputPath == null) + { + throw new ArgumentNullException(nameof(outputPath)); + } + var ext = Path.GetExtension(outputPath).ToLower(); if (ext == ".jpg" || ext == ".jpeg") diff --git a/Emby.Drawing/Common/ImageHeader.cs b/Emby.Drawing/Common/ImageHeader.cs index f37f396f59..3aa0cac257 100644 --- a/Emby.Drawing/Common/ImageHeader.cs +++ b/Emby.Drawing/Common/ImageHeader.cs @@ -50,12 +50,13 @@ namespace Emby.Drawing.Common /// The image was of an unrecognised format. public static ImageSize GetDimensions(string path, ILogger logger, IFileSystem fileSystem) { - var extension = Path.GetExtension(path); - - if (string.IsNullOrEmpty(extension)) + if (string.IsNullOrEmpty(path)) { - throw new ArgumentException("ImageHeader doesn't support image file"); + throw new ArgumentNullException(nameof(path)); } + + string extension = Path.GetExtension(path).ToLower(); + if (!SupportedExtensions.Contains(extension)) { throw new ArgumentException("ImageHeader doesn't support " + extension); @@ -94,7 +95,7 @@ namespace Emby.Drawing.Common } } - throw new ArgumentException(ErrorMessage, "binaryReader"); + throw new ArgumentException(ErrorMessage, nameof(binaryReader)); } /// diff --git a/Emby.Drawing/ImageProcessor.cs b/Emby.Drawing/ImageProcessor.cs index 6a67be56d1..4e4b36507a 100644 --- a/Emby.Drawing/ImageProcessor.cs +++ b/Emby.Drawing/ImageProcessor.cs @@ -80,7 +80,7 @@ namespace Emby.Drawing { if (value == null) { - throw new ArgumentNullException("value"); + throw new ArgumentNullException(nameof(value)); } _imageEncoder = value; @@ -103,7 +103,7 @@ namespace Emby.Drawing "crw", // Remove until supported - //"nef", + //"nef", "orf", "pef", "arw", @@ -179,7 +179,7 @@ namespace Emby.Drawing { if (options == null) { - throw new ArgumentNullException("options"); + throw new ArgumentNullException(nameof(options)); } var originalImage = options.Image; @@ -491,7 +491,7 @@ namespace Emby.Drawing { if (string.IsNullOrEmpty(path)) { - throw new ArgumentNullException("path"); + throw new ArgumentNullException(nameof(path)); } try @@ -691,12 +691,12 @@ namespace Emby.Drawing { if (string.IsNullOrEmpty(originalImagePath)) { - throw new ArgumentNullException("originalImagePath"); + throw new ArgumentNullException(nameof(originalImagePath)); } if (item == null) { - throw new ArgumentNullException("item"); + throw new ArgumentNullException(nameof(item)); } var treatmentRequiresTransparency = false; @@ -779,16 +779,16 @@ namespace Emby.Drawing { if (string.IsNullOrEmpty(path)) { - throw new ArgumentNullException("path"); + throw new ArgumentNullException(nameof(path)); } if (string.IsNullOrEmpty(uniqueName)) { - throw new ArgumentNullException("uniqueName"); + throw new ArgumentNullException(nameof(uniqueName)); } if (string.IsNullOrEmpty(fileExtension)) { - throw new ArgumentNullException("fileExtension"); + throw new ArgumentNullException(nameof(fileExtension)); } var filename = uniqueName.GetMD5() + fileExtension; @@ -811,11 +811,11 @@ namespace Emby.Drawing { if (string.IsNullOrEmpty(path)) { - throw new ArgumentNullException("path"); + throw new ArgumentNullException(nameof(path)); } if (string.IsNullOrEmpty(filename)) { - throw new ArgumentNullException("filename"); + throw new ArgumentNullException(nameof(filename)); } var prefix = filename.Substring(0, 1); diff --git a/Emby.Drawing/Properties/AssemblyInfo.cs b/Emby.Drawing/Properties/AssemblyInfo.cs index b9e9c2ff77..8dfefe0af8 100644 --- a/Emby.Drawing/Properties/AssemblyInfo.cs +++ b/Emby.Drawing/Properties/AssemblyInfo.cs @@ -1,20 +1,20 @@ -using System.Reflection; +using System.Reflection; using System.Runtime.InteropServices; -// General Information about an assembly is controlled through the following +// General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyTitle("Emby.Drawing")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("Emby.Drawing")] -[assembly: AssemblyCopyright("Copyright © 2015")] +[assembly: AssemblyCompany("Jellyfin Project")] +[assembly: AssemblyProduct("Jellyfin: The Free Software Media System")] +[assembly: AssemblyCopyright("Copyright © 2019 Jellyfin Contributors. Code released under the GNU General Public License Version 2")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from // COM, set the ComVisible attribute to true on that type. [assembly: ComVisible(false)] @@ -24,7 +24,7 @@ using System.Runtime.InteropServices; // Version information for an assembly consists of the following four values: // // Major Version -// Minor Version +// Minor Version // Build Number // Revision -// \ No newline at end of file +// diff --git a/Emby.IsoMounting/IsoMounter/IsoMounter.csproj b/Emby.IsoMounting/IsoMounter/IsoMounter.csproj index ee67a1d946..9274f9763a 100644 --- a/Emby.IsoMounting/IsoMounter/IsoMounter.csproj +++ b/Emby.IsoMounting/IsoMounter/IsoMounter.csproj @@ -1,5 +1,9 @@ + + + + diff --git a/Emby.IsoMounting/IsoMounter/LinuxIsoManager.cs b/Emby.IsoMounting/IsoMounter/LinuxIsoManager.cs index d82d2f2fb8..ab85cb721a 100644 --- a/Emby.IsoMounting/IsoMounter/LinuxIsoManager.cs +++ b/Emby.IsoMounting/IsoMounter/LinuxIsoManager.cs @@ -87,7 +87,7 @@ namespace IsoMounter UmountCommand ); - if (!String.IsNullOrEmpty(SudoCommand) && !String.IsNullOrEmpty(MountCommand) && !String.IsNullOrEmpty(UmountCommand)) { + if (!string.IsNullOrEmpty(SudoCommand) && !string.IsNullOrEmpty(MountCommand) && !string.IsNullOrEmpty(UmountCommand)) { ExecutablesAvailable = true; } else { ExecutablesAvailable = false; @@ -152,7 +152,7 @@ namespace IsoMounter return Task.FromResult(mountedISO); } else { - throw new IOException(String.Format( + throw new IOException(string.Format( "An error occurred trying to mount image [$0].", isoPath )); @@ -217,7 +217,7 @@ namespace IsoMounter { string path = test.Trim(); - if (!String.IsNullOrEmpty(path) && FileSystem.FileExists(path = Path.Combine(path, name))) { + if (!string.IsNullOrEmpty(path) && FileSystem.FileExists(path = Path.Combine(path, name))) { return FileSystem.GetFullPath(path); } } diff --git a/Emby.IsoMounting/IsoMounter/LinuxMount.cs b/Emby.IsoMounting/IsoMounter/LinuxMount.cs index edd26f08d4..da2eb19835 100644 --- a/Emby.IsoMounting/IsoMounter/LinuxMount.cs +++ b/Emby.IsoMounting/IsoMounter/LinuxMount.cs @@ -48,7 +48,7 @@ namespace IsoMounter if (disposed) { return; } - + if (disposing) { // diff --git a/Emby.IsoMounting/IsoMounter/Properties/AssemblyInfo.cs b/Emby.IsoMounting/IsoMounter/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000..8a26b12a2a --- /dev/null +++ b/Emby.IsoMounting/IsoMounter/Properties/AssemblyInfo.cs @@ -0,0 +1,21 @@ +using System.Reflection; +using System.Resources; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("IsoMounter")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Jellyfin Project")] +[assembly: AssemblyProduct("Jellyfin: The Free Software Media System")] +[assembly: AssemblyCopyright("Copyright © 2019 Jellyfin Contributors. Code released under the GNU General Public License Version 2")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] +[assembly: NeutralResourcesLanguage("en")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] diff --git a/Emby.Naming/AudioBook/AudioBookInfo.cs b/Emby.Naming/AudioBook/AudioBookInfo.cs index e039e5359a..d7af63d915 100644 --- a/Emby.Naming/AudioBook/AudioBookInfo.cs +++ b/Emby.Naming/AudioBook/AudioBookInfo.cs @@ -29,7 +29,7 @@ namespace Emby.Naming.AudioBook /// /// The alternate versions. public List AlternateVersions { get; set; } - + public AudioBookInfo() { Files = new List(); diff --git a/Emby.Naming/AudioBook/AudioBookResolver.cs b/Emby.Naming/AudioBook/AudioBookResolver.cs index a206ee30bf..7c658f43a8 100644 --- a/Emby.Naming/AudioBook/AudioBookResolver.cs +++ b/Emby.Naming/AudioBook/AudioBookResolver.cs @@ -30,7 +30,7 @@ namespace Emby.Naming.AudioBook { if (string.IsNullOrEmpty(path)) { - throw new ArgumentNullException("path"); + throw new ArgumentNullException(nameof(path)); } if (IsDirectory) return null; @@ -46,7 +46,7 @@ namespace Emby.Naming.AudioBook var parsingResult = new AudioBookFilePathParser(_options) .Parse(path, IsDirectory); - + return new AudioBookFileInfo { Path = path, diff --git a/Emby.Naming/Common/NamingOptions.cs b/Emby.Naming/Common/NamingOptions.cs index 9e65440d08..014f4ebde6 100644 --- a/Emby.Naming/Common/NamingOptions.cs +++ b/Emby.Naming/Common/NamingOptions.cs @@ -282,7 +282,7 @@ namespace Emby.Naming.Common new EpisodeExpression(@".*(\\|\/)(?((?![Ss]([0-9]+)[][ ._-]*[Ee]([0-9]+))[^\\\/])*)?[Ss](?[0-9]+)[][ ._-]*[Ee](?[0-9]+)([^\\/]*)$") { IsNamed = true - }, + }, // new EpisodeExpression(@"[\._ -]()[Ee][Pp]_?([0-9]+)([^\\/]*)$"), new EpisodeExpression("([0-9]{4})[\\.-]([0-9]{2})[\\.-]([0-9]{2})", true) diff --git a/Emby.Naming/Emby.Naming.csproj b/Emby.Naming/Emby.Naming.csproj index f1a736eccb..de40a39d20 100644 --- a/Emby.Naming/Emby.Naming.csproj +++ b/Emby.Naming/Emby.Naming.csproj @@ -4,9 +4,20 @@ netstandard2.0 false - + + + Jellyfin Contributors + Jellyfin.Naming + https://www.gnu.org/licenses/old-licenses/gpl-2.0.txt + https://github.com/jellyfin/jellyfin + + + + + + - + diff --git a/Emby.Naming/Properties/AssemblyInfo.cs b/Emby.Naming/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000..15311570b8 --- /dev/null +++ b/Emby.Naming/Properties/AssemblyInfo.cs @@ -0,0 +1,21 @@ +using System.Reflection; +using System.Resources; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Emby.Naming")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Jellyfin Project")] +[assembly: AssemblyProduct("Jellyfin: The Free Software Media System")] +[assembly: AssemblyCopyright("Copyright © 2019 Jellyfin Contributors. Code released under the GNU General Public License Version 2")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] +[assembly: NeutralResourcesLanguage("en")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] diff --git a/Emby.Naming/Subtitles/SubtitleParser.cs b/Emby.Naming/Subtitles/SubtitleParser.cs index fbf0f60cba..9c279cc096 100644 --- a/Emby.Naming/Subtitles/SubtitleParser.cs +++ b/Emby.Naming/Subtitles/SubtitleParser.cs @@ -18,7 +18,7 @@ namespace Emby.Naming.Subtitles { if (string.IsNullOrEmpty(path)) { - throw new ArgumentNullException("path"); + throw new ArgumentNullException(nameof(path)); } var extension = Path.GetExtension(path); @@ -52,7 +52,7 @@ namespace Emby.Naming.Subtitles { if (string.IsNullOrEmpty(path)) { - throw new ArgumentNullException("path"); + throw new ArgumentNullException(nameof(path)); } // Note: the tags need be be surrounded be either a space ( ), hyphen -, dot . or underscore _. diff --git a/Emby.Naming/TV/EpisodePathParser.cs b/Emby.Naming/TV/EpisodePathParser.cs index 7f8a6a70ec..813be3f7ae 100644 --- a/Emby.Naming/TV/EpisodePathParser.cs +++ b/Emby.Naming/TV/EpisodePathParser.cs @@ -1,4 +1,4 @@ -using Emby.Naming.Common; +using Emby.Naming.Common; using System; using System.Collections.Generic; using System.Globalization; @@ -74,7 +74,7 @@ namespace Emby.Naming.TV return result ?? new EpisodePathParserResult(); } - private EpisodePathParserResult Parse(string name, EpisodeExpression expression) + private static EpisodePathParserResult Parse(string name, EpisodeExpression expression) { var result = new EpisodePathParserResult(); diff --git a/Emby.Naming/TV/EpisodeResolver.cs b/Emby.Naming/TV/EpisodeResolver.cs index 2007d13077..ec5ae2fbfe 100644 --- a/Emby.Naming/TV/EpisodeResolver.cs +++ b/Emby.Naming/TV/EpisodeResolver.cs @@ -19,7 +19,7 @@ namespace Emby.Naming.TV { if (string.IsNullOrEmpty(path)) { - throw new ArgumentNullException("path"); + throw new ArgumentNullException(nameof(path)); } var isStub = false; @@ -53,7 +53,7 @@ namespace Emby.Naming.TV var parsingResult = new EpisodePathParser(_options) .Parse(path, IsDirectory, isNamed, isOptimistic, supportsAbsoluteNumbers, fillExtendedInfo); - + return new EpisodeInfo { Path = path, diff --git a/Emby.Naming/Video/CleanDateTimeParser.cs b/Emby.Naming/Video/CleanDateTimeParser.cs index 572dd1c600..ee6ec8ba07 100644 --- a/Emby.Naming/Video/CleanDateTimeParser.cs +++ b/Emby.Naming/Video/CleanDateTimeParser.cs @@ -1,4 +1,4 @@ -using System; +using System; using Emby.Naming.Common; using System.Globalization; using System.IO; @@ -38,7 +38,7 @@ namespace Emby.Naming.Video } catch (ArgumentException) { - + } var result = _options.CleanDateTimeRegexes.Select(i => Clean(name, i)) @@ -63,7 +63,7 @@ namespace Emby.Naming.Video result; } - private CleanDateTimeResult Clean(string name, Regex expression) + private static CleanDateTimeResult Clean(string name, Regex expression) { var result = new CleanDateTimeResult(); diff --git a/Emby.Naming/Video/CleanStringParser.cs b/Emby.Naming/Video/CleanStringParser.cs index bddf9589b6..02b90310d7 100644 --- a/Emby.Naming/Video/CleanStringParser.cs +++ b/Emby.Naming/Video/CleanStringParser.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; using System.Text.RegularExpressions; namespace Emby.Naming.Video @@ -30,7 +30,7 @@ namespace Emby.Naming.Video }; } - private CleanStringResult Clean(string name, Regex expression) + private static CleanStringResult Clean(string name, Regex expression) { var result = new CleanStringResult(); diff --git a/Emby.Naming/Video/FlagParser.cs b/Emby.Naming/Video/FlagParser.cs index a2c541eeb2..ef785ebf9d 100644 --- a/Emby.Naming/Video/FlagParser.cs +++ b/Emby.Naming/Video/FlagParser.cs @@ -22,7 +22,7 @@ namespace Emby.Naming.Video { if (string.IsNullOrEmpty(path)) { - throw new ArgumentNullException("path"); + throw new ArgumentNullException(nameof(path)); } // Note: the tags need be be surrounded be either a space ( ), hyphen -, dot . or underscore _. diff --git a/Emby.Naming/Video/Format3DParser.cs b/Emby.Naming/Video/Format3DParser.cs index 42737b4834..e335d10554 100644 --- a/Emby.Naming/Video/Format3DParser.cs +++ b/Emby.Naming/Video/Format3DParser.cs @@ -1,4 +1,4 @@ -using Emby.Naming.Common; +using Emby.Naming.Common; using System; using System.Linq; @@ -36,7 +36,7 @@ namespace Emby.Naming.Video return new Format3DResult(); } - private Format3DResult Parse(string[] videoFlags, Format3DRule rule) + private static Format3DResult Parse(string[] videoFlags, Format3DRule rule) { var result = new Format3DResult(); diff --git a/Emby.Naming/Video/StackResolver.cs b/Emby.Naming/Video/StackResolver.cs index 2a71255368..995e95d421 100644 --- a/Emby.Naming/Video/StackResolver.cs +++ b/Emby.Naming/Video/StackResolver.cs @@ -126,7 +126,7 @@ namespace Emby.Naming.Video } stack.Files.Add(file2.FullName); } - else + else { // Sequel offset = 0; diff --git a/Emby.Naming/Video/StubResolver.cs b/Emby.Naming/Video/StubResolver.cs index 69f1f50fa0..33d6baefd3 100644 --- a/Emby.Naming/Video/StubResolver.cs +++ b/Emby.Naming/Video/StubResolver.cs @@ -18,7 +18,7 @@ namespace Emby.Naming.Video { var result = new StubResult(); var extension = Path.GetExtension(path) ?? string.Empty; - + if (_options.StubFileExtensions.Contains(extension, StringComparer.OrdinalIgnoreCase)) { result.IsStub = true; diff --git a/Emby.Naming/Video/VideoFileInfo.cs b/Emby.Naming/Video/VideoFileInfo.cs index 96839c31ef..3cdc483ff3 100644 --- a/Emby.Naming/Video/VideoFileInfo.cs +++ b/Emby.Naming/Video/VideoFileInfo.cs @@ -55,7 +55,7 @@ namespace Emby.Naming.Video /// Gets or sets the type of the stub. /// /// The type of the stub. - public string StubType { get; set; } + public string StubType { get; set; } /// /// Gets or sets the type. /// diff --git a/Emby.Naming/Video/VideoInfo.cs b/Emby.Naming/Video/VideoInfo.cs index f4d311b975..033a8ae2d0 100644 --- a/Emby.Naming/Video/VideoInfo.cs +++ b/Emby.Naming/Video/VideoInfo.cs @@ -32,7 +32,7 @@ namespace Emby.Naming.Video /// /// The alternate versions. public List AlternateVersions { get; set; } - + public VideoInfo() { Files = new List(); diff --git a/Emby.Naming/Video/VideoListResolver.cs b/Emby.Naming/Video/VideoListResolver.cs index 47be28104d..45d4593de2 100644 --- a/Emby.Naming/Video/VideoListResolver.cs +++ b/Emby.Naming/Video/VideoListResolver.cs @@ -1,4 +1,4 @@ -using Emby.Naming.Common; +using Emby.Naming.Common; using System; using System.Collections.Generic; using System.IO; @@ -55,9 +55,9 @@ namespace Emby.Naming.Video info.Year = info.Files.First().Year; - var extraBaseNames = new List + var extraBaseNames = new List { - stack.Name, + stack.Name, Path.GetFileNameWithoutExtension(stack.Files[0]) }; @@ -236,7 +236,7 @@ namespace Emby.Naming.Video if (testFilename.StartsWith(folderName, StringComparison.OrdinalIgnoreCase)) { testFilename = testFilename.Substring(folderName.Length).Trim(); - return testFilename.StartsWith("-", StringComparison.OrdinalIgnoreCase)||Regex.Replace(testFilename, @"\[([^]]*)\]", "").Trim() == String.Empty; + return testFilename.StartsWith("-", StringComparison.OrdinalIgnoreCase) || Regex.Replace(testFilename, @"\[([^]]*)\]", "").Trim() == string.Empty; } return false; diff --git a/Emby.Naming/Video/VideoResolver.cs b/Emby.Naming/Video/VideoResolver.cs index c4951c728e..f6ab8cb87f 100644 --- a/Emby.Naming/Video/VideoResolver.cs +++ b/Emby.Naming/Video/VideoResolver.cs @@ -45,7 +45,7 @@ namespace Emby.Naming.Video { if (string.IsNullOrEmpty(path)) { - throw new ArgumentNullException("path"); + throw new ArgumentNullException(nameof(path)); } var isStub = false; diff --git a/Emby.Notifications/Emby.Notifications.csproj b/Emby.Notifications/Emby.Notifications.csproj index 881be692b8..5b5ae445e6 100644 --- a/Emby.Notifications/Emby.Notifications.csproj +++ b/Emby.Notifications/Emby.Notifications.csproj @@ -5,6 +5,10 @@ false + + + + diff --git a/Emby.Notifications/Properties/AssemblyInfo.cs b/Emby.Notifications/Properties/AssemblyInfo.cs index d35c8b2895..fd70375515 100644 --- a/Emby.Notifications/Properties/AssemblyInfo.cs +++ b/Emby.Notifications/Properties/AssemblyInfo.cs @@ -1,5 +1,5 @@ -using System.Reflection; -using System.Runtime.CompilerServices; +using System.Reflection; +using System.Resources; using System.Runtime.InteropServices; // General Information about an assembly is controlled through the following @@ -8,29 +8,14 @@ using System.Runtime.InteropServices; [assembly: AssemblyTitle("Emby.Notifications")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("Emby.Notifications")] -[assembly: AssemblyCopyright("Copyright © 2018")] +[assembly: AssemblyCompany("Jellyfin Project")] +[assembly: AssemblyProduct("Jellyfin: The Free Software Media System")] +[assembly: AssemblyCopyright("Copyright © 2019 Jellyfin Contributors. Code released under the GNU General Public License Version 2")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] +[assembly: NeutralResourcesLanguage("en")] // Setting ComVisible to false makes the types in this assembly not visible // to COM components. If you need to access a type in this assembly from // COM, set the ComVisible attribute to true on that type. [assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("4d1d313b-60bb-4e11-acf9-cda6745266ef")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Emby.Photos/Properties/AssemblyInfo.cs b/Emby.Photos/Properties/AssemblyInfo.cs index 49ac833457..262125d388 100644 --- a/Emby.Photos/Properties/AssemblyInfo.cs +++ b/Emby.Photos/Properties/AssemblyInfo.cs @@ -1,34 +1,21 @@ -using System.Reflection; -using System.Runtime.CompilerServices; +using System.Reflection; +using System.Resources; using System.Runtime.InteropServices; -// General Information about an assembly is controlled through the following +// General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyTitle("Emby.Photos")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("Emby.Photos")] -[assembly: AssemblyCopyright("Copyright © 2016")] +[assembly: AssemblyCompany("Jellyfin Project")] +[assembly: AssemblyProduct("Jellyfin: The Free Software Media System")] +[assembly: AssemblyCopyright("Copyright © 2019 Jellyfin Contributors. Code released under the GNU General Public License Version 2")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] +[assembly: NeutralResourcesLanguage("en")] -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from // COM, set the ComVisible attribute to true on that type. [assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("89ab4548-770d-41fd-a891-8daff44f452c")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] \ No newline at end of file diff --git a/Emby.Server.Implementations/Activity/ActivityLogEntryPoint.cs b/Emby.Server.Implementations/Activity/ActivityLogEntryPoint.cs index 3f7b907a9e..eca1ff0f50 100644 --- a/Emby.Server.Implementations/Activity/ActivityLogEntryPoint.cs +++ b/Emby.Server.Implementations/Activity/ActivityLogEntryPoint.cs @@ -202,7 +202,7 @@ namespace Emby.Server.Implementations.Activity return name; } - private string GetPlaybackNotificationType(string mediaType) + private static string GetPlaybackNotificationType(string mediaType) { if (string.Equals(mediaType, MediaType.Audio, StringComparison.OrdinalIgnoreCase)) { @@ -220,7 +220,7 @@ namespace Emby.Server.Implementations.Activity return null; } - private string GetPlaybackStoppedNotificationType(string mediaType) + private static string GetPlaybackStoppedNotificationType(string mediaType) { if (string.Equals(mediaType, MediaType.Audio, StringComparison.OrdinalIgnoreCase)) { @@ -577,8 +577,8 @@ namespace Emby.Server.Implementations.Activity /// The name of this item (singular form) private static string CreateValueString(int value, string description) { - return String.Format("{0:#,##0} {1}", - value, value == 1 ? description : String.Format("{0}s", description)); + return string.Format("{0:#,##0} {1}", + value, value == 1 ? description : string.Format("{0}s", description)); } } } diff --git a/Emby.Server.Implementations/Activity/ActivityRepository.cs b/Emby.Server.Implementations/Activity/ActivityRepository.cs index 91a4a5fd45..822219132e 100644 --- a/Emby.Server.Implementations/Activity/ActivityRepository.cs +++ b/Emby.Server.Implementations/Activity/ActivityRepository.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Globalization; using System.IO; @@ -83,7 +83,7 @@ namespace Emby.Server.Implementations.Activity { if (entry == null) { - throw new ArgumentNullException("entry"); + throw new ArgumentNullException(nameof(entry)); } using (WriteLock.Write()) @@ -122,7 +122,7 @@ namespace Emby.Server.Implementations.Activity { if (entry == null) { - throw new ArgumentNullException("entry"); + throw new ArgumentNullException(nameof(entry)); } using (WriteLock.Write()) @@ -251,7 +251,7 @@ namespace Emby.Server.Implementations.Activity } } - private ActivityLogEntry GetEntry(IReadOnlyList reader) + private static ActivityLogEntry GetEntry(IReadOnlyList reader) { var index = 0; diff --git a/Emby.Server.Implementations/AppBase/BaseApplicationPaths.cs b/Emby.Server.Implementations/AppBase/BaseApplicationPaths.cs index 3e12bc0b6e..3ad2d4b91f 100644 --- a/Emby.Server.Implementations/AppBase/BaseApplicationPaths.cs +++ b/Emby.Server.Implementations/AppBase/BaseApplicationPaths.cs @@ -55,61 +55,31 @@ namespace Emby.Server.Implementations.AppBase } private const string _virtualDataPath = "%AppDataPath%"; - public string VirtualDataPath - { - get - { - return _virtualDataPath; - } - } + public string VirtualDataPath => _virtualDataPath; /// /// Gets the image cache path. /// /// The image cache path. - public string ImageCachePath - { - get - { - return Path.Combine(CachePath, "images"); - } - } + public string ImageCachePath => Path.Combine(CachePath, "images"); /// /// Gets the path to the plugin directory /// /// The plugins path. - public string PluginsPath - { - get - { - return Path.Combine(ProgramDataPath, "plugins"); - } - } + public string PluginsPath => Path.Combine(ProgramDataPath, "plugins"); /// /// Gets the path to the plugin configurations directory /// /// The plugin configurations path. - public string PluginConfigurationsPath - { - get - { - return Path.Combine(PluginsPath, "configurations"); - } - } + public string PluginConfigurationsPath => Path.Combine(PluginsPath, "configurations"); /// /// Gets the path to where temporary update files will be stored /// /// The plugin configurations path. - public string TempUpdatePath - { - get - { - return Path.Combine(ProgramDataPath, "updates"); - } - } + public string TempUpdatePath => Path.Combine(ProgramDataPath, "updates"); /// /// The _log directory @@ -133,10 +103,7 @@ namespace Emby.Server.Implementations.AppBase return _logDirectoryPath; } - set - { - _logDirectoryPath = value; - } + set => _logDirectoryPath = value; } /// @@ -161,23 +128,14 @@ namespace Emby.Server.Implementations.AppBase return _configurationDirectoryPath; } - set - { - _configurationDirectoryPath = value; - } + set => _configurationDirectoryPath = value; } /// /// Gets the path to the system configuration file /// /// The system configuration file path. - public string SystemConfigurationFilePath - { - get - { - return Path.Combine(ConfigurationDirectoryPath, "system.xml"); - } - } + public string SystemConfigurationFilePath => Path.Combine(ConfigurationDirectoryPath, "system.xml"); /// /// The _cache directory @@ -200,22 +158,13 @@ namespace Emby.Server.Implementations.AppBase return _cachePath; } - set - { - _cachePath = value; - } + set => _cachePath = value; } /// /// Gets the folder path to the temp directory within the cache folder /// /// The temp directory. - public string TempDirectory - { - get - { - return Path.Combine(CachePath, "temp"); - } - } + public string TempDirectory => Path.Combine(CachePath, "temp"); } } diff --git a/Emby.Server.Implementations/AppBase/BaseConfigurationManager.cs b/Emby.Server.Implementations/AppBase/BaseConfigurationManager.cs index bc5168fe83..222a93a106 100644 --- a/Emby.Server.Implementations/AppBase/BaseConfigurationManager.cs +++ b/Emby.Server.Implementations/AppBase/BaseConfigurationManager.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Concurrent; using System.Collections.Generic; using System.IO; @@ -99,6 +99,7 @@ namespace Emby.Server.Implementations.AppBase /// The application paths. /// The logger factory. /// The XML serializer. + /// The file system protected BaseConfigurationManager(IApplicationPaths applicationPaths, ILoggerFactory loggerFactory, IXmlSerializer xmlSerializer, IFileSystem fileSystem) { CommonApplicationPaths = applicationPaths; @@ -155,7 +156,7 @@ namespace Emby.Server.Implementations.AppBase { if (newConfiguration == null) { - throw new ArgumentNullException("newConfiguration"); + throw new ArgumentNullException(nameof(newConfiguration)); } ValidateCachePath(newConfiguration); diff --git a/Emby.Server.Implementations/AppBase/ConfigurationHelper.cs b/Emby.Server.Implementations/AppBase/ConfigurationHelper.cs index d6a41dd67b..ee6da95fe1 100644 --- a/Emby.Server.Implementations/AppBase/ConfigurationHelper.cs +++ b/Emby.Server.Implementations/AppBase/ConfigurationHelper.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.IO; using System.Linq; using MediaBrowser.Model.IO; @@ -18,6 +18,7 @@ namespace Emby.Server.Implementations.AppBase /// The type. /// The path. /// The XML serializer. + /// The file system /// System.Object. public static object GetXmlConfiguration(Type type, string path, IXmlSerializer xmlSerializer, IFileSystem fileSystem) { diff --git a/Emby.Server.Implementations/ApplicationHost.cs b/Emby.Server.Implementations/ApplicationHost.cs index b020b33c31..283d6b6d71 100644 --- a/Emby.Server.Implementations/ApplicationHost.cs +++ b/Emby.Server.Implementations/ApplicationHost.cs @@ -1,4 +1,4 @@ -using Emby.Common.Implementations.Serialization; +using Emby.Common.Implementations.Serialization; using Emby.Drawing; using Emby.Photos; using Emby.Dlna; @@ -41,7 +41,6 @@ using MediaBrowser.Common.Extensions; using MediaBrowser.Common.Net; using MediaBrowser.Common.Plugins; using MediaBrowser.Model.Extensions; -using MediaBrowser.Common.Security; using MediaBrowser.Common.Updates; using MediaBrowser.Controller; using MediaBrowser.Controller.Channels; @@ -132,13 +131,7 @@ namespace Emby.Server.Implementations /// Gets or sets a value indicating whether this instance can self update. /// /// true if this instance can self update; otherwise, false. - public virtual bool CanSelfUpdate - { - get - { - return false; - } - } + public virtual bool CanSelfUpdate => false; public virtual bool CanLaunchWebBrowser { @@ -237,7 +230,6 @@ namespace Emby.Server.Implementations { get { - #if BETA return PackageVersionClass.Beta; #endif @@ -245,10 +237,7 @@ namespace Emby.Server.Implementations } } - public virtual string OperatingSystemDisplayName - { - get { return EnvironmentInfo.OperatingSystemName; } - } + public virtual string OperatingSystemDisplayName => EnvironmentInfo.OperatingSystemName; /// /// The container @@ -261,10 +250,7 @@ namespace Emby.Server.Implementations /// Gets the server configuration manager. /// /// The server configuration manager. - public IServerConfigurationManager ServerConfigurationManager - { - get { return (IServerConfigurationManager)ConfigurationManager; } - } + public IServerConfigurationManager ServerConfigurationManager => (IServerConfigurationManager)ConfigurationManager; /// /// Gets the configuration manager. @@ -352,11 +338,6 @@ namespace Emby.Server.Implementations /// /// The installation manager. protected IInstallationManager InstallationManager { get; private set; } - /// - /// Gets the security manager. - /// - /// The security manager. - protected ISecurityManager SecurityManager { get; private set; } /// /// Gets or sets the zip client. @@ -453,13 +434,7 @@ namespace Emby.Server.Implementations /// Gets the current application version /// /// The application version. - public Version ApplicationVersion - { - get - { - return _version ?? (_version = typeof(ApplicationHost).Assembly.GetName().Version); - } - } + public Version ApplicationVersion => _version ?? (_version = typeof(ApplicationHost).Assembly.GetName().Version); private DeviceId _deviceId; public string SystemId @@ -479,15 +454,9 @@ namespace Emby.Server.Implementations /// Gets the name. /// /// The name. - public string Name - { - get - { - return "Emby Server"; - } - } + public string Name => "Emby Server"; - private Tuple GetAssembly(Type type) + private static Tuple GetAssembly(Type type) { var assembly = type.GetTypeInfo().Assembly; string path = null; @@ -513,7 +482,7 @@ namespace Emby.Server.Implementations /// /// Creates the instance safe. /// - /// The type. + /// The type information. /// System.Object. protected object CreateInstanceSafe(Tuple typeInfo) { @@ -540,7 +509,7 @@ namespace Emby.Server.Implementations protected void RegisterSingleInstance(T obj, bool manageLifetime = true) where T : class { - Container.RegisterSingleton(obj); + Container.RegisterInstance(obj); if (manageLifetime) { @@ -605,7 +574,7 @@ namespace Emby.Server.Implementations } catch (Exception ex) { - Logger.LogError(ex, "Error loading assembly {file}", file); + Logger.LogError(ex, "Error loading assembly {File}", file); return null; } } @@ -828,10 +797,7 @@ namespace Emby.Server.Implementations SocketFactory = new SocketFactory(LoggerFactory.CreateLogger("SocketFactory")); RegisterSingleInstance(SocketFactory); - SecurityManager = new PluginSecurityManager(this, HttpClient, JsonSerializer, ApplicationPaths, LoggerFactory, FileSystemManager, CryptographyProvider); - RegisterSingleInstance(SecurityManager); - - InstallationManager = new InstallationManager(LoggerFactory.CreateLogger("InstallationManager"), this, ApplicationPaths, HttpClient, JsonSerializer, SecurityManager, ServerConfigurationManager, FileSystemManager, CryptographyProvider, PackageRuntime); + InstallationManager = new InstallationManager(LoggerFactory.CreateLogger("InstallationManager"), this, ApplicationPaths, HttpClient, JsonSerializer, ServerConfigurationManager, FileSystemManager, CryptographyProvider, PackageRuntime); RegisterSingleInstance(InstallationManager); ZipClient = new ZipClient(FileSystemManager); @@ -946,7 +912,7 @@ namespace Emby.Server.Implementations PlaylistManager = new PlaylistManager(LibraryManager, FileSystemManager, LibraryMonitor, LoggerFactory.CreateLogger("PlaylistManager"), UserManager, ProviderManager); RegisterSingleInstance(PlaylistManager); - LiveTvManager = new LiveTvManager(this, HttpClient, ServerConfigurationManager, Logger, ItemRepository, ImageProcessor, UserDataManager, DtoService, UserManager, LibraryManager, TaskManager, LocalizationManager, JsonSerializer, ProviderManager, FileSystemManager, SecurityManager, () => ChannelManager); + LiveTvManager = new LiveTvManager(this, HttpClient, ServerConfigurationManager, Logger, ItemRepository, ImageProcessor, UserDataManager, DtoService, UserManager, LibraryManager, TaskManager, LocalizationManager, JsonSerializer, ProviderManager, FileSystemManager, () => ChannelManager); RegisterSingleInstance(LiveTvManager); UserViewManager = new UserViewManager(LibraryManager, LocalizationManager, UserManager, ChannelManager, LiveTvManager, ServerConfigurationManager); @@ -1004,13 +970,7 @@ namespace Emby.Server.Implementations return s => JsvReader.GetParseFn(propertyType)(s); } - public virtual string PackageRuntime - { - get - { - return "netcore"; - } - } + public virtual string PackageRuntime => "netcore"; public static void LogEnvironmentInfo(ILogger logger, IApplicationPaths appPaths, EnvironmentInfo.EnvironmentInfo environmentInfo) { @@ -1049,7 +1009,7 @@ namespace Emby.Server.Implementations return name + "/" + ApplicationVersion; } - private string FormatAttribute(string str) + private static string FormatAttribute(string str) { var arr = str.ToCharArray(); @@ -1066,13 +1026,7 @@ namespace Emby.Server.Implementations return result; } - protected virtual bool SupportsDualModeSockets - { - get - { - return true; - } - } + protected virtual bool SupportsDualModeSockets => true; private X509Certificate GetCertificate(CertificateInfo info) { @@ -1927,18 +1881,9 @@ namespace Emby.Server.Implementations }; } - public bool EnableHttps - { - get - { - return SupportsHttps && ServerConfigurationManager.Configuration.EnableHttps; - } - } + public bool EnableHttps => SupportsHttps && ServerConfigurationManager.Configuration.EnableHttps; - public bool SupportsHttps - { - get { return Certificate != null || ServerConfigurationManager.Configuration.IsBehindProxy; } - } + public bool SupportsHttps => Certificate != null || ServerConfigurationManager.Configuration.IsBehindProxy; public async Task GetLocalApiUrl(CancellationToken cancellationToken) { @@ -2132,15 +2077,10 @@ namespace Emby.Server.Implementations } } - public string FriendlyName - { - get - { - return string.IsNullOrEmpty(ServerConfigurationManager.Configuration.ServerName) - ? Environment.MachineName - : ServerConfigurationManager.Configuration.ServerName; - } - } + public string FriendlyName => + string.IsNullOrEmpty(ServerConfigurationManager.Configuration.ServerName) + ? Environment.MachineName + : ServerConfigurationManager.Configuration.ServerName; public int HttpPort { get; private set; } @@ -2177,7 +2117,7 @@ namespace Emby.Server.Implementations private bool _hasUpdateAvailable; public bool HasUpdateAvailable { - get { return _hasUpdateAvailable; } + get => _hasUpdateAvailable; set { var fireEvent = value && !_hasUpdateAvailable; diff --git a/Emby.Server.Implementations/Archiving/ZipClient.cs b/Emby.Server.Implementations/Archiving/ZipClient.cs index fd61f2617e..169e7af0a3 100644 --- a/Emby.Server.Implementations/Archiving/ZipClient.cs +++ b/Emby.Server.Implementations/Archiving/ZipClient.cs @@ -15,14 +15,14 @@ namespace Emby.Server.Implementations.Archiving /// public class ZipClient : IZipClient { - private readonly IFileSystem _fileSystem; + private readonly IFileSystem _fileSystem; - public ZipClient(IFileSystem fileSystem) - { - _fileSystem = fileSystem; - } + public ZipClient(IFileSystem fileSystem) + { + _fileSystem = fileSystem; + } - /// + /// /// Extracts all. /// /// The source file. @@ -30,7 +30,7 @@ namespace Emby.Server.Implementations.Archiving /// if set to true [overwrite existing files]. public void ExtractAll(string sourceFile, string targetPath, bool overwriteExistingFiles) { - using (var fileStream = _fileSystem.OpenRead(sourceFile)) + using (var fileStream = _fileSystem.OpenRead(sourceFile)) { ExtractAll(fileStream, targetPath, overwriteExistingFiles); } @@ -116,7 +116,7 @@ namespace Emby.Server.Implementations.Archiving /// if set to true [overwrite existing files]. public void ExtractAllFrom7z(string sourceFile, string targetPath, bool overwriteExistingFiles) { - using (var fileStream = _fileSystem.OpenRead(sourceFile)) + using (var fileStream = _fileSystem.OpenRead(sourceFile)) { ExtractAllFrom7z(fileStream, targetPath, overwriteExistingFiles); } @@ -156,7 +156,7 @@ namespace Emby.Server.Implementations.Archiving /// if set to true [overwrite existing files]. public void ExtractAllFromTar(string sourceFile, string targetPath, bool overwriteExistingFiles) { - using (var fileStream = _fileSystem.OpenRead(sourceFile)) + using (var fileStream = _fileSystem.OpenRead(sourceFile)) { ExtractAllFromTar(fileStream, targetPath, overwriteExistingFiles); } diff --git a/Emby.Server.Implementations/Browser/BrowserLauncher.cs b/Emby.Server.Implementations/Browser/BrowserLauncher.cs index 007f60a9bb..4c9f442d19 100644 --- a/Emby.Server.Implementations/Browser/BrowserLauncher.cs +++ b/Emby.Server.Implementations/Browser/BrowserLauncher.cs @@ -41,7 +41,7 @@ namespace Emby.Server.Implementations.Browser } catch (NotSupportedException) { - + } catch (Exception) { diff --git a/Emby.Server.Implementations/Channels/ChannelImageProvider.cs b/Emby.Server.Implementations/Channels/ChannelImageProvider.cs index a6643e83ca..7eded70c02 100644 --- a/Emby.Server.Implementations/Channels/ChannelImageProvider.cs +++ b/Emby.Server.Implementations/Channels/ChannelImageProvider.cs @@ -30,10 +30,7 @@ namespace Emby.Server.Implementations.Channels return channel.GetChannelImage(type, cancellationToken); } - public string Name - { - get { return "Channel Image Provider"; } - } + public string Name => "Channel Image Provider"; public bool Supports(BaseItem item) { diff --git a/Emby.Server.Implementations/Channels/ChannelManager.cs b/Emby.Server.Implementations/Channels/ChannelManager.cs index c2160d3384..4cc3fd855b 100644 --- a/Emby.Server.Implementations/Channels/ChannelManager.cs +++ b/Emby.Server.Implementations/Channels/ChannelManager.cs @@ -1,4 +1,4 @@ -using MediaBrowser.Common.Extensions; +using MediaBrowser.Common.Extensions; using MediaBrowser.Common.Net; using MediaBrowser.Controller.Channels; using MediaBrowser.Controller.Configuration; @@ -67,13 +67,7 @@ namespace Emby.Server.Implementations.Channels _providerManager = providerManager; } - private TimeSpan CacheLength - { - get - { - return TimeSpan.FromHours(3); - } - } + private static TimeSpan CacheLength => TimeSpan.FromHours(3); public void AddParts(IEnumerable channels) { @@ -269,6 +263,7 @@ namespace Emby.Server.Implementations.Channels { }; + //TODO Fix The co-variant conversion (internalResult.Items) between Folder[] and BaseItem[], this can generate runtime issues. var returnItems = _dtoService.GetBaseItemDtos(internalResult.Items, dtoOptions, user); var result = new QueryResult @@ -419,7 +414,7 @@ namespace Emby.Server.Implementations.Channels return list; } - private MediaSourceInfo NormalizeMediaSource(BaseItem item, MediaSourceInfo info) + private static MediaSourceInfo NormalizeMediaSource(BaseItem item, MediaSourceInfo info) { info.RunTimeTicks = info.RunTimeTicks ?? item.RunTimeTicks; @@ -492,7 +487,7 @@ namespace Emby.Server.Implementations.Channels return item; } - private string GetOfficialRating(ChannelParentalRating rating) + private static string GetOfficialRating(ChannelParentalRating rating) { switch (rating) { @@ -533,7 +528,7 @@ namespace Emby.Server.Implementations.Channels { if (string.IsNullOrEmpty(id)) { - throw new ArgumentNullException("id"); + throw new ArgumentNullException(nameof(id)); } var channel = GetChannel(id); @@ -577,7 +572,7 @@ namespace Emby.Server.Implementations.Channels { if (string.IsNullOrEmpty(name)) { - throw new ArgumentNullException("name"); + throw new ArgumentNullException(nameof(name)); } return _libraryManager.GetNewItemId("Channel " + name, typeof(Channel)); } @@ -891,7 +886,7 @@ namespace Emby.Server.Implementations.Channels filename + ".json"); } - private string GetIdToHash(string externalId, string channelName) + private static string GetIdToHash(string externalId, string channelName) { // Increment this as needed to force new downloads // Incorporate Name because it's being used to convert channel entity to provider @@ -902,7 +897,7 @@ namespace Emby.Server.Implementations.Channels where T : BaseItem, new() { var id = _libraryManager.GetNewItemId(GetIdToHash(idString, channelName), typeof(T)); - + T item = null; try @@ -1187,7 +1182,7 @@ namespace Emby.Server.Implementations.Channels { if (channel == null) { - throw new ArgumentNullException("channel"); + throw new ArgumentNullException(nameof(channel)); } var result = GetAllChannels() diff --git a/Emby.Server.Implementations/Channels/RefreshChannelsScheduledTask.cs b/Emby.Server.Implementations/Channels/RefreshChannelsScheduledTask.cs index ab6acf3c57..c1e9fad8a6 100644 --- a/Emby.Server.Implementations/Channels/RefreshChannelsScheduledTask.cs +++ b/Emby.Server.Implementations/Channels/RefreshChannelsScheduledTask.cs @@ -25,35 +25,17 @@ namespace Emby.Server.Implementations.Channels _libraryManager = libraryManager; } - public string Name - { - get { return "Refresh Channels"; } - } + public string Name => "Refresh Channels"; - public string Description - { - get { return "Refreshes internet channel information."; } - } + public string Description => "Refreshes internet channel information."; - public string Category - { - get { return "Internet Channels"; } - } + public string Category => "Internet Channels"; - public bool IsHidden - { - get { return ((ChannelManager)_channelManager).Channels.Length == 0; } - } + public bool IsHidden => ((ChannelManager)_channelManager).Channels.Length == 0; - public bool IsEnabled - { - get { return true; } - } + public bool IsEnabled => true; - public bool IsLogged - { - get { return true; } - } + public bool IsLogged => true; public async Task Execute(CancellationToken cancellationToken, IProgress progress) { @@ -70,16 +52,13 @@ namespace Emby.Server.Implementations.Channels /// public IEnumerable GetDefaultTriggers() { - return new[] { - + return new[] { + // Every so often new TaskTriggerInfo { Type = TaskTriggerInfo.TriggerInterval, IntervalTicks = TimeSpan.FromHours(24).Ticks} }; } - public string Key - { - get { return "RefreshInternetChannels"; } - } + public string Key => "RefreshInternetChannels"; } } diff --git a/Emby.Server.Implementations/Configuration/ServerConfigurationManager.cs b/Emby.Server.Implementations/Configuration/ServerConfigurationManager.cs index 0154211970..6180645e41 100644 --- a/Emby.Server.Implementations/Configuration/ServerConfigurationManager.cs +++ b/Emby.Server.Implementations/Configuration/ServerConfigurationManager.cs @@ -38,28 +38,19 @@ namespace Emby.Server.Implementations.Configuration /// Gets the type of the configuration. /// /// The type of the configuration. - protected override Type ConfigurationType - { - get { return typeof(ServerConfiguration); } - } + protected override Type ConfigurationType => typeof(ServerConfiguration); /// /// Gets the application paths. /// /// The application paths. - public IServerApplicationPaths ApplicationPaths - { - get { return (IServerApplicationPaths)CommonApplicationPaths; } - } + public IServerApplicationPaths ApplicationPaths => (IServerApplicationPaths)CommonApplicationPaths; /// /// Gets the configuration. /// /// The configuration. - public ServerConfiguration Configuration - { - get { return (ServerConfiguration)CommonConfiguration; } - } + public ServerConfiguration Configuration => (ServerConfiguration)CommonConfiguration; /// /// Called when [configuration updated]. diff --git a/Emby.Server.Implementations/Data/BaseSqliteRepository.cs b/Emby.Server.Implementations/Data/BaseSqliteRepository.cs index 59776c3736..c714ba91b6 100644 --- a/Emby.Server.Implementations/Data/BaseSqliteRepository.cs +++ b/Emby.Server.Implementations/Data/BaseSqliteRepository.cs @@ -24,15 +24,9 @@ namespace Emby.Server.Implementations.Data WriteLock = new ReaderWriterLockSlim(LockRecursionPolicy.NoRecursion); } - protected TransactionMode TransactionMode - { - get { return TransactionMode.Deferred; } - } + protected TransactionMode TransactionMode => TransactionMode.Deferred; - protected TransactionMode ReadTransactionMode - { - get { return TransactionMode.Deferred; } - } + protected TransactionMode ReadTransactionMode => TransactionMode.Deferred; internal static int ThreadSafeMode { get; set; } @@ -58,10 +52,7 @@ namespace Emby.Server.Implementations.Data private string _defaultWal; protected ManagedConnection _connection; - protected virtual bool EnableSingleConnection - { - get { return true; } - } + protected virtual bool EnableSingleConnection => true; protected ManagedConnection CreateConnection(bool isReadOnly = false) { @@ -238,21 +229,9 @@ namespace Emby.Server.Implementations.Data Logger.LogInformation("PRAGMA synchronous=" + db.Query("PRAGMA synchronous").SelectScalarString().First()); } - protected virtual bool EnableTempStoreMemory - { - get - { - return false; - } - } + protected virtual bool EnableTempStoreMemory => false; - protected virtual int? CacheSize - { - get - { - return null; - } - } + protected virtual int? CacheSize => null; internal static void CheckOk(int rc) { @@ -276,7 +255,7 @@ namespace Emby.Server.Implementations.Data { if (_disposed) { - throw new ObjectDisposedException(GetType().Name + " has been disposed and cannot be accessed."); + throw new ObjectDisposedException(GetType().Name ,"Object has been disposed and cannot be accessed."); } } diff --git a/Emby.Server.Implementations/Data/SqliteDisplayPreferencesRepository.cs b/Emby.Server.Implementations/Data/SqliteDisplayPreferencesRepository.cs index 00e1956cf8..49d8f79a2e 100644 --- a/Emby.Server.Implementations/Data/SqliteDisplayPreferencesRepository.cs +++ b/Emby.Server.Implementations/Data/SqliteDisplayPreferencesRepository.cs @@ -32,13 +32,7 @@ namespace Emby.Server.Implementations.Data /// Gets the name of the repository /// /// The name. - public string Name - { - get - { - return "SQLite"; - } - } + public string Name => "SQLite"; /// /// The _json serializer @@ -94,11 +88,11 @@ namespace Emby.Server.Implementations.Data { if (displayPreferences == null) { - throw new ArgumentNullException("displayPreferences"); + throw new ArgumentNullException(nameof(displayPreferences)); } if (string.IsNullOrEmpty(displayPreferences.Id)) { - throw new ArgumentNullException("displayPreferences.Id"); + throw new ArgumentNullException(nameof(displayPreferences.Id)); } cancellationToken.ThrowIfCancellationRequested(); @@ -142,7 +136,7 @@ namespace Emby.Server.Implementations.Data { if (displayPreferences == null) { - throw new ArgumentNullException("displayPreferences"); + throw new ArgumentNullException(nameof(displayPreferences)); } cancellationToken.ThrowIfCancellationRequested(); @@ -174,7 +168,7 @@ namespace Emby.Server.Implementations.Data { if (string.IsNullOrEmpty(displayPreferencesId)) { - throw new ArgumentNullException("displayPreferencesId"); + throw new ArgumentNullException(nameof(displayPreferencesId)); } var guidId = displayPreferencesId.GetMD5(); diff --git a/Emby.Server.Implementations/Data/SqliteExtensions.cs b/Emby.Server.Implementations/Data/SqliteExtensions.cs index a755c65f4a..d9b2db56e7 100644 --- a/Emby.Server.Implementations/Data/SqliteExtensions.cs +++ b/Emby.Server.Implementations/Data/SqliteExtensions.cs @@ -14,7 +14,7 @@ namespace Emby.Server.Implementations.Data { if (queries == null) { - throw new ArgumentNullException("queries"); + throw new ArgumentNullException(nameof(queries)); } connection.RunInTransaction(conn => @@ -134,7 +134,7 @@ namespace Emby.Server.Implementations.Data { if (obj == null) { - throw new ArgumentNullException("obj"); + throw new ArgumentNullException(nameof(obj)); } using (var stream = new MemoryStream()) diff --git a/Emby.Server.Implementations/Data/SqliteItemRepository.cs b/Emby.Server.Implementations/Data/SqliteItemRepository.cs index 0f9770e8f7..f1894fd4f2 100644 --- a/Emby.Server.Implementations/Data/SqliteItemRepository.cs +++ b/Emby.Server.Implementations/Data/SqliteItemRepository.cs @@ -82,11 +82,11 @@ namespace Emby.Server.Implementations.Data { if (config == null) { - throw new ArgumentNullException("config"); + throw new ArgumentNullException(nameof(config)); } if (jsonSerializer == null) { - throw new ArgumentNullException("jsonSerializer"); + throw new ArgumentNullException(nameof(jsonSerializer)); } _appHost = appHost; @@ -455,7 +455,7 @@ namespace Emby.Server.Implementations.Data "ColorTransfer" }; - private string GetSaveItemCommandText() + private static string GetSaveItemCommandText() { var saveColumns = new List { @@ -558,7 +558,7 @@ namespace Emby.Server.Implementations.Data { if (item == null) { - throw new ArgumentNullException("item"); + throw new ArgumentNullException(nameof(item)); } SaveItems(new List { item }, cancellationToken); @@ -568,7 +568,7 @@ namespace Emby.Server.Implementations.Data { if (item == null) { - throw new ArgumentNullException("item"); + throw new ArgumentNullException(nameof(item)); } CheckDisposed(); @@ -605,7 +605,7 @@ namespace Emby.Server.Implementations.Data { if (items == null) { - throw new ArgumentNullException("items"); + throw new ArgumentNullException(nameof(items)); } cancellationToken.ThrowIfCancellationRequested(); @@ -1070,7 +1070,7 @@ namespace Emby.Server.Implementations.Data saveItemStatement.MoveNext(); } - private string SerializeProviderIds(BaseItem item) + private static string SerializeProviderIds(BaseItem item) { // Ideally we shouldn't need this IsNullOrWhiteSpace check but we're seeing some cases of bad data slip through var ids = item.ProviderIds @@ -1085,7 +1085,7 @@ namespace Emby.Server.Implementations.Data return string.Join("|", ids.Select(i => i.Key + "=" + i.Value).ToArray()); } - private void DeserializeProviderIds(string value, BaseItem item) + private static void DeserializeProviderIds(string value, BaseItem item) { if (string.IsNullOrWhiteSpace(value)) { @@ -1226,7 +1226,7 @@ namespace Emby.Server.Implementations.Data { if (id.Equals(Guid.Empty)) { - throw new ArgumentNullException("id"); + throw new ArgumentNullException(nameof(id)); } CheckDisposed(); @@ -1948,7 +1948,7 @@ namespace Emby.Server.Implementations.Data return item; } - private Guid[] SplitToGuids(string value) + private static Guid[] SplitToGuids(string value) { var ids = value.Split('|'); @@ -1965,7 +1965,7 @@ namespace Emby.Server.Implementations.Data /// /// Gets chapters for an item /// - /// The id. + /// The item. /// IEnumerable{ChapterInfo}. /// id public List GetChapters(BaseItem item) @@ -1996,7 +1996,7 @@ namespace Emby.Server.Implementations.Data /// /// Gets a single chapter for an item /// - /// The id. + /// The item. /// The index. /// ChapterInfo. /// id @@ -2067,12 +2067,12 @@ namespace Emby.Server.Implementations.Data if (id.Equals(Guid.Empty)) { - throw new ArgumentNullException("id"); + throw new ArgumentNullException(nameof(id)); } if (chapters == null) { - throw new ArgumentNullException("chapters"); + throw new ArgumentNullException(nameof(chapters)); } using (WriteLock.Write()) @@ -2144,7 +2144,7 @@ namespace Emby.Server.Implementations.Data } } - private bool EnableJoinUserData(InternalItemsQuery query) + private static bool EnableJoinUserData(InternalItemsQuery query) { if (query.User == null) { @@ -2681,7 +2681,7 @@ namespace Emby.Server.Implementations.Data { if (query == null) { - throw new ArgumentNullException("query"); + throw new ArgumentNullException(nameof(query)); } CheckDisposed(); @@ -2739,7 +2739,7 @@ namespace Emby.Server.Implementations.Data { if (query == null) { - throw new ArgumentNullException("query"); + throw new ArgumentNullException(nameof(query)); } CheckDisposed(); @@ -2928,7 +2928,7 @@ namespace Emby.Server.Implementations.Data { if (query == null) { - throw new ArgumentNullException("query"); + throw new ArgumentNullException(nameof(query)); } CheckDisposed(); @@ -3212,7 +3212,7 @@ namespace Emby.Server.Implementations.Data { if (query == null) { - throw new ArgumentNullException("query"); + throw new ArgumentNullException(nameof(query)); } CheckDisposed(); @@ -3286,7 +3286,7 @@ namespace Emby.Server.Implementations.Data { if (query == null) { - throw new ArgumentNullException("query"); + throw new ArgumentNullException(nameof(query)); } CheckDisposed(); @@ -3362,7 +3362,7 @@ namespace Emby.Server.Implementations.Data { if (query == null) { - throw new ArgumentNullException("query"); + throw new ArgumentNullException(nameof(query)); } CheckDisposed(); @@ -4038,7 +4038,7 @@ namespace Emby.Server.Implementations.Data if (query.PersonIds.Length > 0) { - // TODO: Should this query with CleanName ? + // TODO: Should this query with CleanName ? var clauses = new List(); var index = 0; @@ -5184,7 +5184,7 @@ where AncestorIdText not null and ItemValues.Value not null and ItemValues.Type { if (id.Equals(Guid.Empty)) { - throw new ArgumentNullException("id"); + throw new ArgumentNullException(nameof(id)); } CheckDisposed(); @@ -5233,7 +5233,7 @@ where AncestorIdText not null and ItemValues.Value not null and ItemValues.Type { if (query == null) { - throw new ArgumentNullException("query"); + throw new ArgumentNullException(nameof(query)); } CheckDisposed(); @@ -5273,7 +5273,7 @@ where AncestorIdText not null and ItemValues.Value not null and ItemValues.Type { if (query == null) { - throw new ArgumentNullException("query"); + throw new ArgumentNullException(nameof(query)); } CheckDisposed(); @@ -5387,19 +5387,19 @@ where AncestorIdText not null and ItemValues.Value not null and ItemValues.Type { if (itemId.Equals(Guid.Empty)) { - throw new ArgumentNullException("itemId"); + throw new ArgumentNullException(nameof(itemId)); } if (ancestorIds == null) { - throw new ArgumentNullException("ancestorIds"); + throw new ArgumentNullException(nameof(ancestorIds)); } CheckDisposed(); var itemIdBlob = itemId.ToGuidBlob(); - // First delete + // First delete deleteAncestorsStatement.Reset(); deleteAncestorsStatement.TryBind("@ItemId", itemIdBlob); deleteAncestorsStatement.MoveNext(); @@ -5556,7 +5556,7 @@ where AncestorIdText not null and ItemValues.Value not null and ItemValues.Type { if (query == null) { - throw new ArgumentNullException("query"); + throw new ArgumentNullException(nameof(query)); } if (!query.Limit.HasValue) @@ -5915,19 +5915,19 @@ where AncestorIdText not null and ItemValues.Value not null and ItemValues.Type { if (itemId.Equals(Guid.Empty)) { - throw new ArgumentNullException("itemId"); + throw new ArgumentNullException(nameof(itemId)); } if (values == null) { - throw new ArgumentNullException("keys"); + throw new ArgumentNullException(nameof(values)); } CheckDisposed(); var guidBlob = itemId.ToGuidBlob(); - // First delete + // First delete db.Execute("delete from ItemValues where ItemId=@Id", guidBlob); InsertItemValues(guidBlob, values, db); @@ -5991,12 +5991,12 @@ where AncestorIdText not null and ItemValues.Value not null and ItemValues.Type { if (itemId.Equals(Guid.Empty)) { - throw new ArgumentNullException("itemId"); + throw new ArgumentNullException(nameof(itemId)); } if (people == null) { - throw new ArgumentNullException("people"); + throw new ArgumentNullException(nameof(people)); } CheckDisposed(); @@ -6102,7 +6102,7 @@ where AncestorIdText not null and ItemValues.Value not null and ItemValues.Type if (query == null) { - throw new ArgumentNullException("query"); + throw new ArgumentNullException(nameof(query)); } var cmdText = "select " + string.Join(",", _mediaStreamSaveColumns) + " from mediastreams where"; @@ -6158,12 +6158,12 @@ where AncestorIdText not null and ItemValues.Value not null and ItemValues.Type if (id.Equals(Guid.Empty)) { - throw new ArgumentNullException("id"); + throw new ArgumentNullException(nameof(id)); } if (streams == null) { - throw new ArgumentNullException("streams"); + throw new ArgumentNullException(nameof(streams)); } cancellationToken.ThrowIfCancellationRequested(); diff --git a/Emby.Server.Implementations/Data/SqliteUserDataRepository.cs b/Emby.Server.Implementations/Data/SqliteUserDataRepository.cs index 6d4ddcedd9..cf60b71d63 100644 --- a/Emby.Server.Implementations/Data/SqliteUserDataRepository.cs +++ b/Emby.Server.Implementations/Data/SqliteUserDataRepository.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.IO; using System.Linq; @@ -28,13 +28,7 @@ namespace Emby.Server.Implementations.Data /// Gets the name of the repository /// /// The name. - public string Name - { - get - { - return "SQLite"; - } - } + public string Name => "SQLite"; /// /// Opens the connection to the database @@ -136,13 +130,7 @@ namespace Emby.Server.Implementations.Data return list; } - protected override bool EnableTempStoreMemory - { - get - { - return true; - } - } + protected override bool EnableTempStoreMemory => true; /// /// Saves the user data. @@ -151,15 +139,15 @@ namespace Emby.Server.Implementations.Data { if (userData == null) { - throw new ArgumentNullException("userData"); + throw new ArgumentNullException(nameof(userData)); } if (internalUserId <= 0) { - throw new ArgumentNullException("internalUserId"); + throw new ArgumentNullException(nameof(internalUserId)); } if (string.IsNullOrEmpty(key)) { - throw new ArgumentNullException("key"); + throw new ArgumentNullException(nameof(key)); } PersistUserData(internalUserId, key, userData, cancellationToken); @@ -169,11 +157,11 @@ namespace Emby.Server.Implementations.Data { if (userData == null) { - throw new ArgumentNullException("userData"); + throw new ArgumentNullException(nameof(userData)); } if (internalUserId <= 0) { - throw new ArgumentNullException("internalUserId"); + throw new ArgumentNullException(nameof(internalUserId)); } PersistAllUserData(internalUserId, userData, cancellationToken); @@ -182,7 +170,7 @@ namespace Emby.Server.Implementations.Data /// /// Persists the user data. /// - /// The user id. + /// The user id. /// The key. /// The user data. /// The cancellation token. @@ -203,7 +191,7 @@ namespace Emby.Server.Implementations.Data } } - private void SaveUserData(IDatabaseConnection db, long internalUserId, string key, UserItemData userData) + private static void SaveUserData(IDatabaseConnection db, long internalUserId, string key, UserItemData userData) { using (var statement = db.PrepareStatement("replace into UserDatas (key, userId, rating,played,playCount,isFavorite,playbackPositionTicks,lastPlayedDate,AudioStreamIndex,SubtitleStreamIndex) values (@key, @userId, @rating,@played,@playCount,@isFavorite,@playbackPositionTicks,@lastPlayedDate,@AudioStreamIndex,@SubtitleStreamIndex)")) { @@ -280,7 +268,7 @@ namespace Emby.Server.Implementations.Data /// /// Gets the user data. /// - /// The user id. + /// The user id. /// The key. /// Task{UserItemData}. /// @@ -292,11 +280,11 @@ namespace Emby.Server.Implementations.Data { if (internalUserId <= 0) { - throw new ArgumentNullException("internalUserId"); + throw new ArgumentNullException(nameof(internalUserId)); } if (string.IsNullOrEmpty(key)) { - throw new ArgumentNullException("key"); + throw new ArgumentNullException(nameof(key)); } using (WriteLock.Read()) @@ -323,7 +311,7 @@ namespace Emby.Server.Implementations.Data { if (keys == null) { - throw new ArgumentNullException("keys"); + throw new ArgumentNullException(nameof(keys)); } if (keys.Count == 0) @@ -337,13 +325,13 @@ namespace Emby.Server.Implementations.Data /// /// Return all user-data associated with the given user /// - /// + /// /// public List GetAllUserData(long internalUserId) { if (internalUserId <= 0) { - throw new ArgumentNullException("internalUserId"); + throw new ArgumentNullException(nameof(internalUserId)); } var list = new List(); diff --git a/Emby.Server.Implementations/Data/SqliteUserRepository.cs b/Emby.Server.Implementations/Data/SqliteUserRepository.cs index d490a481e4..125f254c10 100644 --- a/Emby.Server.Implementations/Data/SqliteUserRepository.cs +++ b/Emby.Server.Implementations/Data/SqliteUserRepository.cs @@ -31,13 +31,7 @@ namespace Emby.Server.Implementations.Data /// Gets the name of the repository /// /// The name. - public string Name - { - get - { - return "SQLite"; - } - } + public string Name => "SQLite"; /// /// Opens the connection to the database @@ -85,7 +79,7 @@ namespace Emby.Server.Implementations.Data { if (user == null) { - throw new ArgumentNullException("user"); + throw new ArgumentNullException(nameof(user)); } var serialized = _jsonSerializer.SerializeToBytes(user); @@ -122,7 +116,7 @@ namespace Emby.Server.Implementations.Data { if (user == null) { - throw new ArgumentNullException("user"); + throw new ArgumentNullException(nameof(user)); } var serialized = _jsonSerializer.SerializeToBytes(user); @@ -207,14 +201,13 @@ namespace Emby.Server.Implementations.Data /// Deletes the user. /// /// The user. - /// The cancellation token. /// Task. /// user public void DeleteUser(User user) { if (user == null) { - throw new ArgumentNullException("user"); + throw new ArgumentNullException(nameof(user)); } using (WriteLock.Write()) diff --git a/Emby.Server.Implementations/Data/TypeMapper.cs b/Emby.Server.Implementations/Data/TypeMapper.cs index f4b37749e7..e0c2de918f 100644 --- a/Emby.Server.Implementations/Data/TypeMapper.cs +++ b/Emby.Server.Implementations/Data/TypeMapper.cs @@ -32,7 +32,7 @@ namespace Emby.Server.Implementations.Data { if (string.IsNullOrEmpty(typeName)) { - throw new ArgumentNullException("typeName"); + throw new ArgumentNullException(nameof(typeName)); } return _typeMap.GetOrAdd(typeName, LookupType); diff --git a/Emby.Server.Implementations/Devices/DeviceId.cs b/Emby.Server.Implementations/Devices/DeviceId.cs index 90cef5d06e..4f5950ac73 100644 --- a/Emby.Server.Implementations/Devices/DeviceId.cs +++ b/Emby.Server.Implementations/Devices/DeviceId.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.IO; using System.Text; using MediaBrowser.Common.Configuration; @@ -10,15 +10,12 @@ namespace Emby.Server.Implementations.Devices public class DeviceId { private readonly IApplicationPaths _appPaths; - private readonly ILogger _logger; - private readonly IFileSystem _fileSystem; + private readonly ILogger _logger; + private readonly IFileSystem _fileSystem; private readonly object _syncLock = new object(); - private string CachePath - { - get { return Path.Combine(_appPaths.DataPath, "device.txt"); } - } + private string CachePath => Path.Combine(_appPaths.DataPath, "device.txt"); private string GetCachedId() { @@ -26,7 +23,7 @@ namespace Emby.Server.Implementations.Devices { lock (_syncLock) { - var value = File.ReadAllText(CachePath, Encoding.UTF8); + var value = File.ReadAllText(CachePath, Encoding.UTF8); Guid guid; if (Guid.TryParse(value, out guid)) @@ -57,7 +54,7 @@ namespace Emby.Server.Implementations.Devices { var path = CachePath; - _fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(path)); + _fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(path)); lock (_syncLock) { @@ -70,7 +67,7 @@ namespace Emby.Server.Implementations.Devices } } - private string GetNewId() + private static string GetNewId() { return Guid.NewGuid().ToString("N"); } @@ -92,18 +89,16 @@ namespace Emby.Server.Implementations.Devices public DeviceId(IApplicationPaths appPaths, ILogger logger, IFileSystem fileSystem) { - if (fileSystem == null) { - throw new ArgumentNullException ("fileSystem"); - } + if (fileSystem == null) + { + throw new ArgumentNullException(nameof(fileSystem)); + } _appPaths = appPaths; _logger = logger; - _fileSystem = fileSystem; + _fileSystem = fileSystem; } - public string Value - { - get { return _id ?? (_id = GetDeviceId()); } - } + public string Value => _id ?? (_id = GetDeviceId()); } } diff --git a/Emby.Server.Implementations/Devices/DeviceManager.cs b/Emby.Server.Implementations/Devices/DeviceManager.cs index f5314df6e1..c72334577e 100644 --- a/Emby.Server.Implementations/Devices/DeviceManager.cs +++ b/Emby.Server.Implementations/Devices/DeviceManager.cs @@ -1,4 +1,4 @@ -using MediaBrowser.Common.Configuration; +using MediaBrowser.Common.Configuration; using MediaBrowser.Common.Net; using MediaBrowser.Controller.Devices; using MediaBrowser.Controller.Library; @@ -144,7 +144,7 @@ namespace Emby.Server.Implementations.Devices HasUser = true }).Items; - + // TODO: DeviceQuery doesn't seem to be used from client. Not even Swagger. if (query.SupportsSync.HasValue) { @@ -360,10 +360,7 @@ namespace Emby.Server.Implementations.Devices return path; } - private string DefaultCameraUploadsPath - { - get { return Path.Combine(_config.CommonApplicationPaths.DataPath, "camerauploads"); } - } + private string DefaultCameraUploadsPath => Path.Combine(_config.CommonApplicationPaths.DataPath, "camerauploads"); public bool CanAccessDevice(User user, string deviceId) { @@ -373,7 +370,7 @@ namespace Emby.Server.Implementations.Devices } if (string.IsNullOrEmpty(deviceId)) { - throw new ArgumentNullException("deviceId"); + throw new ArgumentNullException(nameof(deviceId)); } if (!CanAccessDevice(user.Policy, deviceId)) @@ -389,7 +386,7 @@ namespace Emby.Server.Implementations.Devices return true; } - private bool CanAccessDevice(UserPolicy policy, string id) + private static bool CanAccessDevice(UserPolicy policy, string id) { if (policy.EnableAllDevices) { diff --git a/Emby.Server.Implementations/Diagnostics/CommonProcess.cs b/Emby.Server.Implementations/Diagnostics/CommonProcess.cs index a709607bde..99871a3c6a 100644 --- a/Emby.Server.Implementations/Diagnostics/CommonProcess.cs +++ b/Emby.Server.Implementations/Diagnostics/CommonProcess.cs @@ -81,30 +81,15 @@ namespace Emby.Server.Implementations.Diagnostics } } - public ProcessOptions StartInfo - { - get { return _options; } - } + public ProcessOptions StartInfo => _options; - public StreamWriter StandardInput - { - get { return _process.StandardInput; } - } + public StreamWriter StandardInput => _process.StandardInput; - public StreamReader StandardError - { - get { return _process.StandardError; } - } + public StreamReader StandardError => _process.StandardError; - public StreamReader StandardOutput - { - get { return _process.StandardOutput; } - } + public StreamReader StandardOutput => _process.StandardOutput; - public int ExitCode - { - get { return _process.ExitCode; } - } + public int ExitCode => _process.ExitCode; public void Start() { diff --git a/Emby.Server.Implementations/Dto/DtoService.cs b/Emby.Server.Implementations/Dto/DtoService.cs index 7871d3fb3b..3d519f35dd 100644 --- a/Emby.Server.Implementations/Dto/DtoService.cs +++ b/Emby.Server.Implementations/Dto/DtoService.cs @@ -1,4 +1,4 @@ -using MediaBrowser.Common; +using MediaBrowser.Common; using MediaBrowser.Controller.Channels; using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Devices; @@ -189,7 +189,7 @@ namespace Emby.Server.Implementations.Dto return dto; } - private IList GetTaggedItems(IItemByName byName, User user, DtoOptions options) + private static IList GetTaggedItems(IItemByName byName, User user, DtoOptions options) { return byName.GetTaggedItems(new InternalItemsQuery(user) { @@ -295,7 +295,7 @@ namespace Emby.Server.Implementations.Dto return dto; } - private void NormalizeMediaSourceContainers(BaseItemDto dto) + private static void NormalizeMediaSourceContainers(BaseItemDto dto) { foreach (var mediaSource in dto.MediaSources) { @@ -347,7 +347,7 @@ namespace Emby.Server.Implementations.Dto return dto; } - private void SetItemByNameInfo(BaseItem item, BaseItemDto dto, IList taggedItems, User user = null) + private static void SetItemByNameInfo(BaseItem item, BaseItemDto dto, IList taggedItems, User user = null) { if (item is MusicArtist) { @@ -447,7 +447,7 @@ namespace Emby.Server.Implementations.Dto } } - private int GetChildCount(Folder folder, User user) + private static int GetChildCount(Folder folder, User user) { // Right now this is too slow to calculate for top level folders on a per-user basis // Just return something so that apps that are expecting a value won't think the folders are empty @@ -470,11 +470,11 @@ namespace Emby.Server.Implementations.Dto return item.Id.ToString("N"); } - private void SetBookProperties(BaseItemDto dto, Book item) + private static void SetBookProperties(BaseItemDto dto, Book item) { dto.SeriesName = item.SeriesName; } - private void SetPhotoProperties(BaseItemDto dto, Photo item) + private static void SetPhotoProperties(BaseItemDto dto, Photo item) { dto.CameraMake = item.CameraMake; dto.CameraModel = item.CameraModel; @@ -520,13 +520,13 @@ namespace Emby.Server.Implementations.Dto dto.Album = item.Album; } - private void SetGameProperties(BaseItemDto dto, Game item) + private static void SetGameProperties(BaseItemDto dto, Game item) { dto.GameSystem = item.GameSystem; dto.MultiPartGameFiles = item.MultiPartGameFiles; } - private void SetGameSystemProperties(BaseItemDto dto, GameSystem item) + private static void SetGameSystemProperties(BaseItemDto dto, GameSystem item) { dto.GameSystem = item.GameSystemName; } diff --git a/Emby.Server.Implementations/EntryPoints/ExternalPortForwarding.cs b/Emby.Server.Implementations/EntryPoints/ExternalPortForwarding.cs index 6cd867921f..6c658a695f 100644 --- a/Emby.Server.Implementations/EntryPoints/ExternalPortForwarding.cs +++ b/Emby.Server.Implementations/EntryPoints/ExternalPortForwarding.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Globalization; using System.Net; @@ -227,7 +227,7 @@ namespace Emby.Server.Implementations.EntryPoints { if (_disposed) { - throw new ObjectDisposedException("PortMapper"); + throw new ObjectDisposedException(GetType().Name); } // On some systems the device discovered event seems to fire repeatedly diff --git a/Emby.Server.Implementations/EntryPoints/LibraryChangedNotifier.cs b/Emby.Server.Implementations/EntryPoints/LibraryChangedNotifier.cs index bb8ef52f18..a5c9072132 100644 --- a/Emby.Server.Implementations/EntryPoints/LibraryChangedNotifier.cs +++ b/Emby.Server.Implementations/EntryPoints/LibraryChangedNotifier.cs @@ -1,4 +1,4 @@ -using MediaBrowser.Controller.Entities; +using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Library; using MediaBrowser.Controller.Plugins; using MediaBrowser.Controller.Session; @@ -142,7 +142,7 @@ namespace Emby.Server.Implementations.EntryPoints _providerManager_RefreshProgress(sender, new GenericEventArgs>(new Tuple(e.Argument, 100))); } - private bool EnableRefreshMessage(BaseItem item) + private static bool EnableRefreshMessage(BaseItem item) { var folder = item as Folder; @@ -387,7 +387,7 @@ namespace Emby.Server.Implementations.EntryPoints }; } - private bool FilterItem(BaseItem item) + private static bool FilterItem(BaseItem item) { if (!item.IsFolder && !item.HasPathProtocol) { @@ -471,7 +471,7 @@ namespace Emby.Server.Implementations.EntryPoints LibraryUpdateTimer.Dispose(); LibraryUpdateTimer = null; } - + _libraryManager.ItemAdded -= libraryManager_ItemAdded; _libraryManager.ItemUpdated -= libraryManager_ItemUpdated; _libraryManager.ItemRemoved -= libraryManager_ItemRemoved; diff --git a/Emby.Server.Implementations/EntryPoints/RecordingNotifier.cs b/Emby.Server.Implementations/EntryPoints/RecordingNotifier.cs index 0b377dc682..c7bd03960d 100644 --- a/Emby.Server.Implementations/EntryPoints/RecordingNotifier.cs +++ b/Emby.Server.Implementations/EntryPoints/RecordingNotifier.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Linq; using System.Threading; using MediaBrowser.Controller.Library; @@ -62,7 +62,7 @@ namespace Emby.Server.Implementations.EntryPoints } catch (ObjectDisposedException) { - + // TODO Log exception or Investigate and properly fix. } catch (Exception ex) { diff --git a/Emby.Server.Implementations/EntryPoints/RefreshUsersMetadata.cs b/Emby.Server.Implementations/EntryPoints/RefreshUsersMetadata.cs index 660ca3a941..f0b834ccb4 100644 --- a/Emby.Server.Implementations/EntryPoints/RefreshUsersMetadata.cs +++ b/Emby.Server.Implementations/EntryPoints/RefreshUsersMetadata.cs @@ -30,10 +30,7 @@ namespace Emby.Server.Implementations.EntryPoints public string Description => "Refresh user infos"; - public string Category - { - get { return "Library"; } - } + public string Category => "Library"; public bool IsHidden => true; diff --git a/Emby.Server.Implementations/EnvironmentInfo/EnvironmentInfo.cs b/Emby.Server.Implementations/EnvironmentInfo/EnvironmentInfo.cs index 655867577b..24a3456c45 100644 --- a/Emby.Server.Implementations/EnvironmentInfo/EnvironmentInfo.cs +++ b/Emby.Server.Implementations/EnvironmentInfo/EnvironmentInfo.cs @@ -29,14 +29,8 @@ namespace Emby.Server.Implementations.EnvironmentInfo } } - public string OperatingSystemVersion - { - get - { - return Environment.OSVersion.Version.ToString() + " " + Environment.OSVersion.ServicePack.ToString(); - } - } + public string OperatingSystemVersion => Environment.OSVersion.Version.ToString() + " " + Environment.OSVersion.ServicePack.ToString(); - public Architecture SystemArchitecture { get { return RuntimeInformation.OSArchitecture; } } + public Architecture SystemArchitecture => RuntimeInformation.OSArchitecture; } } diff --git a/Emby.Server.Implementations/FFMpeg/FFMpegLoader.cs b/Emby.Server.Implementations/FFMpeg/FFMpegLoader.cs index 5f043e1275..83e3cb7206 100644 --- a/Emby.Server.Implementations/FFMpeg/FFMpegLoader.cs +++ b/Emby.Server.Implementations/FFMpeg/FFMpegLoader.cs @@ -114,7 +114,7 @@ namespace Emby.Server.Implementations.FFMpeg { var encoderFilename = Path.GetFileName(info.EncoderPath); var probeFilename = Path.GetFileName(info.ProbePath); - + foreach (var directory in _fileSystem.GetDirectoryPaths(rootEncoderPath) .ToList()) { diff --git a/Emby.Server.Implementations/HttpClientManager/HttpClientManager.cs b/Emby.Server.Implementations/HttpClientManager/HttpClientManager.cs index d3ba1b683e..2f5eed547d 100644 --- a/Emby.Server.Implementations/HttpClientManager/HttpClientManager.cs +++ b/Emby.Server.Implementations/HttpClientManager/HttpClientManager.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Concurrent; using System.Collections.Generic; using System.Globalization; @@ -48,11 +48,11 @@ namespace Emby.Server.Implementations.HttpClientManager { if (appPaths == null) { - throw new ArgumentNullException("appPaths"); + throw new ArgumentNullException(nameof(appPaths)); } if (logger == null) { - throw new ArgumentNullException("logger"); + throw new ArgumentNullException(nameof(logger)); } _logger = logger; @@ -87,7 +87,7 @@ namespace Emby.Server.Implementations.HttpClientManager { if (string.IsNullOrEmpty(host)) { - throw new ArgumentNullException("host"); + throw new ArgumentNullException(nameof(host)); } HttpClientInfo client; @@ -104,7 +104,7 @@ namespace Emby.Server.Implementations.HttpClientManager return client; } - private WebRequest CreateWebRequest(string url) + private static WebRequest CreateWebRequest(string url) { try { @@ -185,7 +185,7 @@ namespace Emby.Server.Implementations.HttpClientManager return request; } - private CredentialCache GetCredential(string url, string username, string password) + private static CredentialCache GetCredential(string url, string username, string password) { //ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3; CredentialCache credentialCache = new CredentialCache(); @@ -220,7 +220,7 @@ namespace Emby.Server.Implementations.HttpClientManager } } - private void SetUserAgent(HttpWebRequest request, string userAgent) + private static void SetUserAgent(HttpWebRequest request, string userAgent) { request.UserAgent = userAgent; } @@ -389,7 +389,7 @@ namespace Emby.Server.Implementations.HttpClientManager { options.ResourcePool?.Release(); - throw new HttpException(string.Format("Connection to {0} timed out", options.Url)) { IsTimedOut = true }; + throw new HttpException($"Connection to {options.Url} timed out") { IsTimedOut = true }; } if (options.LogRequest) @@ -491,7 +491,7 @@ namespace Emby.Server.Implementations.HttpClientManager return responseInfo; } - private void SetHeaders(WebHeaderCollection headers, HttpResponseInfo responseInfo) + private static void SetHeaders(WebHeaderCollection headers, HttpResponseInfo responseInfo) { foreach (var key in headers.AllKeys) { @@ -541,7 +541,7 @@ namespace Emby.Server.Implementations.HttpClientManager if (options.Progress == null) { - throw new ArgumentNullException("progress"); + throw new ArgumentException("Options did not have a Progress value.",nameof(options)); } options.CancellationToken.ThrowIfCancellationRequested(); @@ -616,7 +616,7 @@ namespace Emby.Server.Implementations.HttpClientManager } } - private long? GetContentLength(HttpWebResponse response) + private static long? GetContentLength(HttpWebResponse response) { var length = response.ContentLength; @@ -704,7 +704,7 @@ namespace Emby.Server.Implementations.HttpClientManager { if (string.IsNullOrEmpty(options.Url)) { - throw new ArgumentNullException("options"); + throw new ArgumentNullException(nameof(options)); } } @@ -713,7 +713,7 @@ namespace Emby.Server.Implementations.HttpClientManager /// /// The URL. /// System.String. - private string GetHostFromUrl(string url) + private static string GetHostFromUrl(string url) { var index = url.IndexOf("://", StringComparison.OrdinalIgnoreCase); @@ -803,7 +803,7 @@ namespace Emby.Server.Implementations.HttpClientManager }; } - private Task GetResponseAsync(WebRequest request, TimeSpan timeout) + private static Task GetResponseAsync(WebRequest request, TimeSpan timeout) { var taskCompletion = new TaskCompletionSource(); diff --git a/Emby.Server.Implementations/HttpServer/FileWriter.cs b/Emby.Server.Implementations/HttpServer/FileWriter.cs index 1a875e5334..5684329022 100644 --- a/Emby.Server.Implementations/HttpServer/FileWriter.cs +++ b/Emby.Server.Implementations/HttpServer/FileWriter.cs @@ -38,10 +38,7 @@ namespace Emby.Server.Implementations.HttpServer /// Gets the options. /// /// The options. - public IDictionary Headers - { - get { return _options; } - } + public IDictionary Headers => _options; public string Path { get; set; } @@ -49,7 +46,7 @@ namespace Emby.Server.Implementations.HttpServer { if (string.IsNullOrEmpty(contentType)) { - throw new ArgumentNullException("contentType"); + throw new ArgumentNullException(nameof(contentType)); } Path = path; @@ -148,7 +145,7 @@ namespace Emby.Server.Implementations.HttpServer } } - private string[] SkipLogExtensions = new string[] + private string[] SkipLogExtensions = new string[] { ".js", ".html", @@ -203,8 +200,8 @@ namespace Emby.Server.Implementations.HttpServer public HttpStatusCode StatusCode { - get { return (HttpStatusCode)Status; } - set { Status = (int)value; } + get => (HttpStatusCode)Status; + set => Status = (int)value; } public string StatusDescription { get; set; } diff --git a/Emby.Server.Implementations/HttpServer/HttpListenerHost.cs b/Emby.Server.Implementations/HttpServer/HttpListenerHost.cs index 69ca0f85b6..6b4f2bced5 100644 --- a/Emby.Server.Implementations/HttpServer/HttpListenerHost.cs +++ b/Emby.Server.Implementations/HttpServer/HttpListenerHost.cs @@ -1,27 +1,26 @@ -using MediaBrowser.Common.Extensions; -using MediaBrowser.Controller.Configuration; -using MediaBrowser.Controller.Net; -using Microsoft.Extensions.Logging; using System; using System.Collections.Generic; using System.Globalization; using System.IO; using System.Linq; +using System.Net.Sockets; using System.Reflection; using System.Text; using System.Threading; using System.Threading.Tasks; +using Emby.Server.Implementations.Net; using Emby.Server.Implementations.Services; +using MediaBrowser.Common.Extensions; using MediaBrowser.Common.Net; -using MediaBrowser.Common.Security; using MediaBrowser.Controller; +using MediaBrowser.Controller.Configuration; +using MediaBrowser.Controller.Net; +using MediaBrowser.Model.Events; using MediaBrowser.Model.Extensions; using MediaBrowser.Model.Serialization; using MediaBrowser.Model.Services; using MediaBrowser.Model.Text; -using System.Net.Sockets; -using Emby.Server.Implementations.Net; -using MediaBrowser.Model.Events; +using Microsoft.Extensions.Logging; namespace Emby.Server.Implementations.HttpServer { @@ -55,47 +54,34 @@ namespace Emby.Server.Implementations.HttpServer private IWebSocketListener[] _webSocketListeners = Array.Empty(); private readonly List _webSocketConnections = new List(); - public HttpListenerHost(IServerApplicationHost applicationHost, + public HttpListenerHost( + IServerApplicationHost applicationHost, ILogger logger, IServerConfigurationManager config, - string defaultRedirectPath, INetworkManager networkManager, ITextEncoding textEncoding, IJsonSerializer jsonSerializer, IXmlSerializer xmlSerializer, Func> funcParseFn) + string defaultRedirectPath, + INetworkManager networkManager, + ITextEncoding textEncoding, + IJsonSerializer jsonSerializer, + IXmlSerializer xmlSerializer, + Func> funcParseFn) { - Instance = this; - _appHost = applicationHost; + _logger = logger; + _config = config; DefaultRedirectPath = defaultRedirectPath; _networkManager = networkManager; _textEncoding = textEncoding; _jsonSerializer = jsonSerializer; _xmlSerializer = xmlSerializer; - _config = config; - - _logger = logger; _funcParseFn = funcParseFn; - ResponseFilters = new Action[] { }; + Instance = this; + ResponseFilters = Array.Empty>(); } public string GlobalResponse { get; set; } - readonly Dictionary _mapExceptionToStatusCode = new Dictionary - { - {typeof (ResourceNotFoundException), 404}, - {typeof (RemoteServiceUnavailableException), 502}, - {typeof (FileNotFoundException), 404}, - //{typeof (DirectoryNotFoundException), 404}, - {typeof (SecurityException), 401}, - {typeof (PaymentRequiredException), 402}, - {typeof (ArgumentException), 400} - }; - - protected ILogger Logger - { - get - { - return _logger; - } - } + protected ILogger Logger => _logger; public object CreateInstance(Type type) { @@ -103,7 +89,7 @@ namespace Emby.Server.Implementations.HttpServer } /// - /// Applies the request filters. Returns whether or not the request has been handled + /// Applies the request filters. Returns whether or not the request has been handled /// and no more processing should be done. /// /// @@ -111,9 +97,9 @@ namespace Emby.Server.Implementations.HttpServer { //Exec all RequestFilter attributes with Priority < 0 var attributes = GetRequestFilterAttributes(requestDto.GetType()); - var i = 0; - var count = attributes.Count; + int count = attributes.Count; + int i = 0; for (; i < count && attributes[i].Priority < 0; i++) { var attribute = attributes[i]; @@ -176,10 +162,7 @@ namespace Emby.Server.Implementations.HttpServer _webSocketConnections.Add(connection); } - if (WebSocketConnected != null) - { - WebSocketConnected?.Invoke(this, new GenericEventArgs(connection)); - } + WebSocketConnected?.Invoke(this, new GenericEventArgs(connection)); } private void Connection_Closed(object sender, EventArgs e) @@ -190,10 +173,9 @@ namespace Emby.Server.Implementations.HttpServer } } - private Exception GetActualException(Exception ex) + private static Exception GetActualException(Exception ex) { - var agg = ex as AggregateException; - if (agg != null) + if (ex is AggregateException agg) { var inner = agg.InnerException; if (inner != null) @@ -215,27 +197,16 @@ namespace Emby.Server.Implementations.HttpServer private int GetStatusCode(Exception ex) { - if (ex is ArgumentException) + switch (ex) { - return 400; + case ArgumentException _: return 400; + case SecurityException _: return 401; + case DirectoryNotFoundException _: + case FileNotFoundException _: + case ResourceNotFoundException _: return 404; + case RemoteServiceUnavailableException _: return 502; + default: return 500; } - - var exceptionType = ex.GetType(); - - int statusCode; - if (!_mapExceptionToStatusCode.TryGetValue(exceptionType, out statusCode)) - { - if (ex is DirectoryNotFoundException) - { - statusCode = 404; - } - else - { - statusCode = 500; - } - } - - return statusCode; } private async Task ErrorHandler(Exception ex, IRequest httpReq, bool logExceptionStackTrace, bool logExceptionMessage) @@ -321,32 +292,25 @@ namespace Emby.Server.Implementations.HttpServer } } - private readonly Dictionary _skipLogExtensions = new Dictionary(StringComparer.OrdinalIgnoreCase) + private static readonly string[] _skipLogExtensions = { - {".js", 0}, - {".css", 0}, - {".woff", 0}, - {".woff2", 0}, - {".ttf", 0}, - {".html", 0} + ".js", + ".css", + ".woff", + ".woff2", + ".ttf", + ".html" }; private bool EnableLogging(string url, string localPath) { var extension = GetExtension(url); - if (string.IsNullOrEmpty(extension) || !_skipLogExtensions.ContainsKey(extension)) - { - if (string.IsNullOrEmpty(localPath) || localPath.IndexOf("system/ping", StringComparison.OrdinalIgnoreCase) == -1) - { - return true; - } - } - - return false; + return ((string.IsNullOrEmpty(extension) || !_skipLogExtensions.Contains(extension)) + && (string.IsNullOrEmpty(localPath) || localPath.IndexOf("system/ping", StringComparison.OrdinalIgnoreCase) == -1)); } - private string GetExtension(string url) + private static string GetExtension(string url) { var parts = url.Split(new[] { '?' }, 2); @@ -379,18 +343,18 @@ namespace Emby.Server.Implementations.HttpServer string pagePathWithoutQueryString = url.Split(new[] { '?' }, StringSplitOptions.RemoveEmptyEntries)[0]; return newQueryString.Count > 0 - ? String.Format("{0}?{1}", pagePathWithoutQueryString, newQueryString) + ? string.Format("{0}?{1}", pagePathWithoutQueryString, newQueryString) : pagePathWithoutQueryString; } - private string GetUrlToLog(string url) + private static string GetUrlToLog(string url) { url = RemoveQueryStringByKey(url, "api_key"); return url; } - private string NormalizeConfiguredLocalAddress(string address) + private static string NormalizeConfiguredLocalAddress(string address) { var index = address.Trim('/').IndexOf('/'); @@ -566,9 +530,7 @@ namespace Emby.Server.Implementations.HttpServer return; } - if (string.Equals(localPath, "/mediabrowser/", StringComparison.OrdinalIgnoreCase) || - string.Equals(localPath, "/mediabrowser", StringComparison.OrdinalIgnoreCase) || - localPath.IndexOf("mediabrowser/web", StringComparison.OrdinalIgnoreCase) != -1) + if (localPath.IndexOf("mediabrowser/web", StringComparison.OrdinalIgnoreCase) != -1) { httpRes.StatusCode = 200; httpRes.ContentType = "text/html"; @@ -723,11 +685,11 @@ namespace Emby.Server.Implementations.HttpServer }; } - _logger.LogError("Could not find handler for {pathInfo}", pathInfo); + _logger.LogError("Could not find handler for {PathInfo}", pathInfo); return null; } - private Task Write(IResponse response, string text) + private static Task Write(IResponse response, string text) { var bOutput = Encoding.UTF8.GetBytes(text); response.SetContentLength(bOutput.Length); @@ -737,14 +699,13 @@ namespace Emby.Server.Implementations.HttpServer private void RedirectToSecureUrl(IHttpRequest httpReq, IResponse httpRes, string url) { - int currentPort; - Uri uri; - if (Uri.TryCreate(url, UriKind.Absolute, out uri)) + if (Uri.TryCreate(url, UriKind.Absolute, out Uri uri)) { - currentPort = uri.Port; - var builder = new UriBuilder(uri); - builder.Port = _config.Configuration.PublicHttpsPort; - builder.Scheme = "https"; + var builder = new UriBuilder(uri) + { + Port = _config.Configuration.PublicHttpsPort, + Scheme = "https" + }; url = builder.Uri.ToString(); RedirectToUrl(httpRes, url); @@ -844,16 +805,12 @@ namespace Emby.Server.Implementations.HttpServer public Task DeserializeJson(Type type, Stream stream) { - //using (var reader = new StreamReader(stream)) - //{ - // var json = reader.ReadToEnd(); - // logger.LogInformation(json); - // return _jsonSerializer.DeserializeFromString(json, type); - //} return _jsonSerializer.DeserializeFromStreamAsync(stream, type); } - private string NormalizeEmbyRoutePath(string path) + //TODO Add Jellyfin Route Path Normalizer + + private static string NormalizeEmbyRoutePath(string path) { if (path.StartsWith("/", StringComparison.OrdinalIgnoreCase)) { @@ -863,7 +820,7 @@ namespace Emby.Server.Implementations.HttpServer return "emby/" + path; } - private string NormalizeMediaBrowserRoutePath(string path) + private static string NormalizeMediaBrowserRoutePath(string path) { if (path.StartsWith("/", StringComparison.OrdinalIgnoreCase)) { @@ -873,7 +830,7 @@ namespace Emby.Server.Implementations.HttpServer return "mediabrowser/" + path; } - private string DoubleNormalizeEmbyRoutePath(string path) + private static string DoubleNormalizeEmbyRoutePath(string path) { if (path.StartsWith("/", StringComparison.OrdinalIgnoreCase)) { diff --git a/Emby.Server.Implementations/HttpServer/HttpResultFactory.cs b/Emby.Server.Implementations/HttpServer/HttpResultFactory.cs index 73b2afe640..bacf5556f0 100644 --- a/Emby.Server.Implementations/HttpServer/HttpResultFactory.cs +++ b/Emby.Server.Implementations/HttpServer/HttpResultFactory.cs @@ -1,4 +1,4 @@ -using MediaBrowser.Common.Extensions; +using MediaBrowser.Common.Extensions; using MediaBrowser.Controller.Net; using Microsoft.Extensions.Logging; using MediaBrowser.Model.Serialization; @@ -207,7 +207,7 @@ namespace Emby.Server.Implementations.HttpServer { if (result == null) { - throw new ArgumentNullException("result"); + throw new ArgumentNullException(nameof(result)); } if (responseHeaders == null) @@ -245,7 +245,7 @@ namespace Emby.Server.Implementations.HttpServer return GetCompressionType(request); } - private string GetCompressionType(IRequest request) + private static string GetCompressionType(IRequest request) { var acceptEncoding = request.Headers["Accept-Encoding"]; @@ -265,7 +265,7 @@ namespace Emby.Server.Implementations.HttpServer } /// - /// Returns the optimized result for the IRequestContext. + /// Returns the optimized result for the IRequestContext. /// Does not use or store results in any cache. /// /// @@ -365,7 +365,7 @@ namespace Emby.Server.Implementations.HttpServer return _brotliCompressor.Compress(bytes); } - private byte[] Deflate(byte[] bytes) + private static byte[] Deflate(byte[] bytes) { // In .NET FX incompat-ville, you can't access compressed bytes without closing DeflateStream // Which means we must use MemoryStream since you have to use ToArray() on a closed Stream @@ -379,7 +379,7 @@ namespace Emby.Server.Implementations.HttpServer } } - private byte[] GZip(byte[] buffer) + private static byte[] GZip(byte[] buffer) { using (var ms = new MemoryStream()) using (var zipStream = new GZipStream(ms, CompressionMode.Compress)) @@ -398,7 +398,7 @@ namespace Emby.Server.Implementations.HttpServer : contentType.Split(';')[0].ToLower().Trim(); } - private string SerializeToXmlString(object from) + private static string SerializeToXmlString(object from) { using (var ms = new MemoryStream()) { @@ -412,8 +412,10 @@ namespace Emby.Server.Implementations.HttpServer serializer.WriteObject(xw, from); xw.Flush(); ms.Seek(0, SeekOrigin.Begin); - var reader = new StreamReader(ms); - return reader.ReadToEnd(); + using (var reader = new StreamReader(ms)) + { + return reader.ReadToEnd(); + } } } } @@ -425,7 +427,7 @@ namespace Emby.Server.Implementations.HttpServer { responseHeaders["ETag"] = string.Format("\"{0}\"", cacheKeyString); - var noCache = (requestContext.Headers.Get("Cache-Control") ?? string.Empty).IndexOf("no-cache", StringComparison.OrdinalIgnoreCase) != -1; + bool noCache = (requestContext.Headers.Get("Cache-Control") ?? string.Empty).IndexOf("no-cache", StringComparison.OrdinalIgnoreCase) != -1; if (!noCache) { @@ -453,7 +455,7 @@ namespace Emby.Server.Implementations.HttpServer { if (string.IsNullOrEmpty(path)) { - throw new ArgumentNullException("path"); + throw new ArgumentNullException(nameof(path)); } return GetStaticFileResult(requestContext, new StaticFileResultOptions @@ -463,15 +465,14 @@ namespace Emby.Server.Implementations.HttpServer }); } - public Task GetStaticFileResult(IRequest requestContext, - StaticFileResultOptions options) + public Task GetStaticFileResult(IRequest requestContext, StaticFileResultOptions options) { var path = options.Path; var fileShare = options.FileShare; if (string.IsNullOrEmpty(path)) { - throw new ArgumentNullException("path"); + throw new ArgumentNullException(nameof(path)); } if (fileShare != FileShareMode.Read && fileShare != FileShareMode.ReadWrite) @@ -661,7 +662,7 @@ namespace Emby.Server.Implementations.HttpServer /// /// Adds the expires header. /// - private void AddExpiresHeader(IDictionary responseHeaders, string cacheKey, TimeSpan? cacheDuration) + private static void AddExpiresHeader(IDictionary responseHeaders, string cacheKey, TimeSpan? cacheDuration) { if (cacheDuration.HasValue) { @@ -678,7 +679,7 @@ namespace Emby.Server.Implementations.HttpServer /// /// The responseHeaders. /// The last date modified. - private void AddAgeHeader(IDictionary responseHeaders, DateTime? lastDateModified) + private static void AddAgeHeader(IDictionary responseHeaders, DateTime? lastDateModified) { if (lastDateModified.HasValue) { @@ -699,36 +700,26 @@ namespace Emby.Server.Implementations.HttpServer var ifModifiedSinceHeader = requestContext.Headers.Get("If-Modified-Since"); - if (!string.IsNullOrEmpty(ifModifiedSinceHeader)) + if (!string.IsNullOrEmpty(ifModifiedSinceHeader) + && DateTime.TryParse(ifModifiedSinceHeader, out DateTime ifModifiedSince) + && IsNotModified(ifModifiedSince.ToUniversalTime(), cacheDuration, lastDateModified)) { - DateTime ifModifiedSince; - - if (DateTime.TryParse(ifModifiedSinceHeader, out ifModifiedSince)) - { - if (IsNotModified(ifModifiedSince.ToUniversalTime(), cacheDuration, lastDateModified)) - { - return true; - } - } + return true; } var ifNoneMatchHeader = requestContext.Headers.Get("If-None-Match"); - var hasCacheKey = !cacheKey.Equals(Guid.Empty); + bool hasCacheKey = !cacheKey.Equals(Guid.Empty); // Validate If-None-Match - if ((hasCacheKey || !string.IsNullOrEmpty(ifNoneMatchHeader))) + if ((hasCacheKey && !string.IsNullOrEmpty(ifNoneMatchHeader))) { - Guid ifNoneMatch; - ifNoneMatchHeader = (ifNoneMatchHeader ?? string.Empty).Trim('\"'); - if (Guid.TryParse(ifNoneMatchHeader, out ifNoneMatch)) + if (Guid.TryParse(ifNoneMatchHeader, out Guid ifNoneMatch) + && cacheKey.Equals(ifNoneMatch)) { - if (hasCacheKey && cacheKey.Equals(ifNoneMatch)) - { - return true; - } + return true; } } @@ -771,7 +762,7 @@ namespace Emby.Server.Implementations.HttpServer /// /// The date. /// DateTime. - private DateTime NormalizeDateForComparison(DateTime date) + private static DateTime NormalizeDateForComparison(DateTime date) { return new DateTime(date.Year, date.Month, date.Day, date.Hour, date.Minute, date.Second, date.Kind); } @@ -781,7 +772,7 @@ namespace Emby.Server.Implementations.HttpServer /// /// The has options. /// The response headers. - private void AddResponseHeaders(IHasHeaders hasHeaders, IEnumerable> responseHeaders) + private static void AddResponseHeaders(IHasHeaders hasHeaders, IEnumerable> responseHeaders) { foreach (var item in responseHeaders) { diff --git a/Emby.Server.Implementations/HttpServer/IHttpListener.cs b/Emby.Server.Implementations/HttpServer/IHttpListener.cs index e21607ebd6..d50d7df6b9 100644 --- a/Emby.Server.Implementations/HttpServer/IHttpListener.cs +++ b/Emby.Server.Implementations/HttpServer/IHttpListener.cs @@ -33,7 +33,7 @@ namespace Emby.Server.Implementations.HttpServer /// /// The web socket connecting. Action WebSocketConnecting { get; set; } - + /// /// Starts this instance. /// diff --git a/Emby.Server.Implementations/HttpServer/RangeRequestWriter.cs b/Emby.Server.Implementations/HttpServer/RangeRequestWriter.cs index dc20ee1a24..ef47a7ca97 100644 --- a/Emby.Server.Implementations/HttpServer/RangeRequestWriter.cs +++ b/Emby.Server.Implementations/HttpServer/RangeRequestWriter.cs @@ -1,4 +1,4 @@ -using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Logging; using System; using System.Collections.Generic; using System.Globalization; @@ -40,16 +40,11 @@ namespace Emby.Server.Implementations.HttpServer /// private static readonly CultureInfo UsCulture = new CultureInfo("en-US"); - public List Cookies { get; private set; } - /// /// Additional HTTP Headers /// /// The headers. - public IDictionary Headers - { - get { return _options; } - } + public IDictionary Headers => _options; /// /// Initializes a new instance of the class. @@ -62,7 +57,7 @@ namespace Emby.Server.Implementations.HttpServer { if (string.IsNullOrEmpty(contentType)) { - throw new ArgumentNullException("contentType"); + throw new ArgumentNullException(nameof(contentType)); } RangeHeader = rangeHeader; @@ -75,7 +70,6 @@ namespace Emby.Server.Implementations.HttpServer Headers["Accept-Ranges"] = "bytes"; StatusCode = HttpStatusCode.PartialContent; - Cookies = new List(); SetRangeValues(contentLength); } @@ -186,7 +180,7 @@ namespace Emby.Server.Implementations.HttpServer } } - private async Task CopyToInternalAsync(Stream source, Stream destination, long copyLength) + private static async Task CopyToInternalAsync(Stream source, Stream destination, long copyLength) { var array = new byte[BufferSize]; int bytesRead; @@ -220,10 +214,8 @@ namespace Emby.Server.Implementations.HttpServer public HttpStatusCode StatusCode { - get { return (HttpStatusCode)Status; } - set { Status = (int)value; } + get => (HttpStatusCode)Status; + set => Status = (int)value; } - - public string StatusDescription { get; set; } } } diff --git a/Emby.Server.Implementations/HttpServer/ResponseFilter.cs b/Emby.Server.Implementations/HttpServer/ResponseFilter.cs index f38aa5ea06..afaee59f39 100644 --- a/Emby.Server.Implementations/HttpServer/ResponseFilter.cs +++ b/Emby.Server.Implementations/HttpServer/ResponseFilter.cs @@ -25,14 +25,11 @@ namespace Emby.Server.Implementations.HttpServer public void FilterResponse(IRequest req, IResponse res, object dto) { // Try to prevent compatibility view - //res.AddHeader("X-UA-Compatible", "IE=Edge"); res.AddHeader("Access-Control-Allow-Headers", "Accept, Accept-Language, Authorization, Cache-Control, Content-Disposition, Content-Encoding, Content-Language, Content-Length, Content-MD5, Content-Range, Content-Type, Date, Host, If-Match, If-Modified-Since, If-None-Match, If-Unmodified-Since, Origin, OriginToken, Pragma, Range, Slug, Transfer-Encoding, Want-Digest, X-MediaBrowser-Token, X-Emby-Authorization"); res.AddHeader("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, PATCH, OPTIONS"); res.AddHeader("Access-Control-Allow-Origin", "*"); - var exception = dto as Exception; - - if (exception != null) + if (dto is Exception exception) { _logger.LogError(exception, "Error processing request for {RawUrl}", req.RawUrl); @@ -45,43 +42,26 @@ namespace Emby.Server.Implementations.HttpServer } } - var hasHeaders = dto as IHasHeaders; - - if (hasHeaders != null) + if (dto is IHasHeaders hasHeaders) { if (!hasHeaders.Headers.ContainsKey("Server")) { hasHeaders.Headers["Server"] = "Microsoft-NetCore/2.0, UPnP/1.0 DLNADOC/1.50"; - //hasHeaders.Headers["Server"] = "Mono-HTTPAPI/1.1"; } // Content length has to be explicitly set on on HttpListenerResponse or it won't be happy - string contentLength; - - if (hasHeaders.Headers.TryGetValue("Content-Length", out contentLength) && !string.IsNullOrEmpty(contentLength)) + if (hasHeaders.Headers.TryGetValue("Content-Length", out string contentLength) + && !string.IsNullOrEmpty(contentLength)) { var length = long.Parse(contentLength, UsCulture); if (length > 0) { res.SetContentLength(length); - - //var listenerResponse = res.OriginalResponse as HttpListenerResponse; - - //if (listenerResponse != null) - //{ - // // Disable chunked encoding. Technically this is only needed when using Content-Range, but - // // anytime we know the content length there's no need for it - // listenerResponse.SendChunked = false; - // return; - //} - res.SendChunked = false; } } } - - //res.KeepAlive = false; } /// diff --git a/Emby.Server.Implementations/HttpServer/Security/AuthService.cs b/Emby.Server.Implementations/HttpServer/Security/AuthService.cs index e153d6f71f..fb5bfa601a 100644 --- a/Emby.Server.Implementations/HttpServer/Security/AuthService.cs +++ b/Emby.Server.Implementations/HttpServer/Security/AuthService.cs @@ -1,4 +1,4 @@ -using MediaBrowser.Controller.Configuration; +using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Connect; using MediaBrowser.Controller.Devices; using MediaBrowser.Controller.Entities; @@ -173,7 +173,7 @@ namespace Emby.Server.Implementations.HttpServer.Security return false; } - private void ValidateRoles(string[] roles, User user) + private static void ValidateRoles(string[] roles, User user) { if (roles.Contains("admin", StringComparer.OrdinalIgnoreCase)) { @@ -207,7 +207,7 @@ namespace Emby.Server.Implementations.HttpServer.Security } } - private AuthenticationInfo GetTokenInfo(IRequest request) + private static AuthenticationInfo GetTokenInfo(IRequest request) { object info; request.Items.TryGetValue("OriginalAuthenticationInfo", out info); diff --git a/Emby.Server.Implementations/HttpServer/Security/AuthorizationContext.cs b/Emby.Server.Implementations/HttpServer/Security/AuthorizationContext.cs index c3e2d31708..f561c3d60f 100644 --- a/Emby.Server.Implementations/HttpServer/Security/AuthorizationContext.cs +++ b/Emby.Server.Implementations/HttpServer/Security/AuthorizationContext.cs @@ -1,4 +1,4 @@ -using MediaBrowser.Controller.Connect; +using MediaBrowser.Controller.Connect; using MediaBrowser.Controller.Net; using MediaBrowser.Controller.Security; using System; @@ -115,7 +115,7 @@ namespace Emby.Server.Implementations.HttpServer.Security { info.Device = tokenInfo.DeviceName; } - + else if (!string.Equals(info.Device, tokenInfo.DeviceName, StringComparison.OrdinalIgnoreCase)) { if (allowTokenInfoUpdate) @@ -227,7 +227,7 @@ namespace Emby.Server.Implementations.HttpServer.Security return result; } - private string NormalizeValue(string value) + private static string NormalizeValue(string value) { if (string.IsNullOrEmpty(value)) { diff --git a/Emby.Server.Implementations/HttpServer/StreamWriter.cs b/Emby.Server.Implementations/HttpServer/StreamWriter.cs index 0a44a5fe5e..df0d746852 100644 --- a/Emby.Server.Implementations/HttpServer/StreamWriter.cs +++ b/Emby.Server.Implementations/HttpServer/StreamWriter.cs @@ -35,10 +35,7 @@ namespace Emby.Server.Implementations.HttpServer /// Gets the options. /// /// The options. - public IDictionary Headers - { - get { return _options; } - } + public IDictionary Headers => _options; public Action OnComplete { get; set; } public Action OnError { get; set; } @@ -53,7 +50,7 @@ namespace Emby.Server.Implementations.HttpServer { if (string.IsNullOrEmpty(contentType)) { - throw new ArgumentNullException("contentType"); + throw new ArgumentNullException(nameof(contentType)); } SourceStream = source; @@ -77,7 +74,7 @@ namespace Emby.Server.Implementations.HttpServer { if (string.IsNullOrEmpty(contentType)) { - throw new ArgumentNullException("contentType"); + throw new ArgumentNullException(nameof(contentType)); } SourceBytes = source; diff --git a/Emby.Server.Implementations/HttpServer/WebSocketConnection.cs b/Emby.Server.Implementations/HttpServer/WebSocketConnection.cs index 914fa9dbcc..5426114f6f 100644 --- a/Emby.Server.Implementations/HttpServer/WebSocketConnection.cs +++ b/Emby.Server.Implementations/HttpServer/WebSocketConnection.cs @@ -82,19 +82,19 @@ namespace Emby.Server.Implementations.HttpServer { if (socket == null) { - throw new ArgumentNullException("socket"); + throw new ArgumentNullException(nameof(socket)); } if (string.IsNullOrEmpty(remoteEndPoint)) { - throw new ArgumentNullException("remoteEndPoint"); + throw new ArgumentNullException(nameof(remoteEndPoint)); } if (jsonSerializer == null) { - throw new ArgumentNullException("jsonSerializer"); + throw new ArgumentNullException(nameof(jsonSerializer)); } if (logger == null) { - throw new ArgumentNullException("logger"); + throw new ArgumentNullException(nameof(logger)); } Id = Guid.NewGuid(); @@ -148,7 +148,8 @@ namespace Emby.Server.Implementations.HttpServer /// /// Called when [receive]. /// - /// The bytes. + /// The memory block. + /// The length of the memory block. private void OnReceiveInternal(Memory memory, int length) { LastActivityDate = DateTime.UtcNow; @@ -219,7 +220,7 @@ namespace Emby.Server.Implementations.HttpServer { if (message == null) { - throw new ArgumentNullException("message"); + throw new ArgumentNullException(nameof(message)); } var json = _jsonSerializer.SerializeToString(message); @@ -237,7 +238,7 @@ namespace Emby.Server.Implementations.HttpServer { if (buffer == null) { - throw new ArgumentNullException("buffer"); + throw new ArgumentNullException(nameof(buffer)); } cancellationToken.ThrowIfCancellationRequested(); @@ -249,7 +250,7 @@ namespace Emby.Server.Implementations.HttpServer { if (string.IsNullOrEmpty(text)) { - throw new ArgumentNullException("text"); + throw new ArgumentNullException(nameof(text)); } cancellationToken.ThrowIfCancellationRequested(); @@ -261,10 +262,7 @@ namespace Emby.Server.Implementations.HttpServer /// Gets the state. /// /// The state. - public WebSocketState State - { - get { return _socket.State; } - } + public WebSocketState State => _socket.State; /// /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. diff --git a/Emby.Server.Implementations/IO/FileRefresher.cs b/Emby.Server.Implementations/IO/FileRefresher.cs index 34c711324b..c2def33db9 100644 --- a/Emby.Server.Implementations/IO/FileRefresher.cs +++ b/Emby.Server.Implementations/IO/FileRefresher.cs @@ -51,7 +51,7 @@ namespace Emby.Server.Implementations.IO { if (string.IsNullOrEmpty(path)) { - throw new ArgumentNullException("path"); + throw new ArgumentNullException(nameof(path)); } if (!_affectedPaths.Contains(path, StringComparer.Ordinal)) @@ -64,7 +64,7 @@ namespace Emby.Server.Implementations.IO { if (string.IsNullOrEmpty(path)) { - throw new ArgumentNullException("path"); + throw new ArgumentNullException(nameof(path)); } lock (_timerLock) @@ -156,7 +156,7 @@ namespace Emby.Server.Implementations.IO continue; } - Logger.LogInformation("{name} ({path}}) will be refreshed.", item.Name, item.Path); + Logger.LogInformation("{name} ({path}) will be refreshed.", item.Name, item.Path); try { @@ -164,7 +164,7 @@ namespace Emby.Server.Implementations.IO } catch (IOException ex) { - // For now swallow and log. + // For now swallow and log. // Research item: If an IOException occurs, the item may be in a disconnected state (media unavailable) // Should we remove it from it's parent? Logger.LogError(ex, "Error refreshing {name}", item.Name); diff --git a/Emby.Server.Implementations/IO/IsoManager.cs b/Emby.Server.Implementations/IO/IsoManager.cs index 903d5f301f..e0cf328681 100644 --- a/Emby.Server.Implementations/IO/IsoManager.cs +++ b/Emby.Server.Implementations/IO/IsoManager.cs @@ -29,7 +29,7 @@ namespace Emby.Server.Implementations.IO { if (string.IsNullOrEmpty(isoPath)) { - throw new ArgumentNullException("isoPath"); + throw new ArgumentNullException(nameof(isoPath)); } var mounter = _mounters.FirstOrDefault(i => i.CanMount(isoPath)); diff --git a/Emby.Server.Implementations/IO/LibraryMonitor.cs b/Emby.Server.Implementations/IO/LibraryMonitor.cs index ca5810fd6c..9a224bd0e3 100644 --- a/Emby.Server.Implementations/IO/LibraryMonitor.cs +++ b/Emby.Server.Implementations/IO/LibraryMonitor.cs @@ -77,7 +77,7 @@ namespace Emby.Server.Implementations.IO { if (string.IsNullOrEmpty(path)) { - throw new ArgumentNullException("path"); + throw new ArgumentNullException(nameof(path)); } TemporarilyIgnore(path); @@ -95,7 +95,7 @@ namespace Emby.Server.Implementations.IO { if (string.IsNullOrEmpty(path)) { - throw new ArgumentNullException("path"); + throw new ArgumentNullException(nameof(path)); } // This is an arbitraty amount of time, but delay it because file system writes often trigger events long after the file was actually written to. @@ -145,7 +145,7 @@ namespace Emby.Server.Implementations.IO { if (taskManager == null) { - throw new ArgumentNullException("taskManager"); + throw new ArgumentNullException(nameof(taskManager)); } LibraryManager = libraryManager; @@ -268,7 +268,7 @@ namespace Emby.Server.Implementations.IO { if (string.IsNullOrEmpty(path)) { - throw new ArgumentNullException("path"); + throw new ArgumentNullException(nameof(path)); } path = path.TrimEnd(Path.DirectorySeparatorChar); @@ -469,7 +469,7 @@ namespace Emby.Server.Implementations.IO { if (string.IsNullOrEmpty(path)) { - throw new ArgumentNullException("path"); + throw new ArgumentNullException(nameof(path)); } var filename = Path.GetFileName(path); diff --git a/Emby.Server.Implementations/IO/ManagedFileSystem.cs b/Emby.Server.Implementations/IO/ManagedFileSystem.cs index 0f85e0642b..bee96c785d 100644 --- a/Emby.Server.Implementations/IO/ManagedFileSystem.cs +++ b/Emby.Server.Implementations/IO/ManagedFileSystem.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; @@ -85,17 +85,11 @@ namespace Emby.Server.Implementations.IO { // Be consistent across platforms because the windows server will fail to query network shares that don't follow windows conventions // https://referencesource.microsoft.com/#mscorlib/system/io/path.cs - _invalidFileNameChars = new char[] { '\"', '<', '>', '|', '\0', (Char)1, (Char)2, (Char)3, (Char)4, (Char)5, (Char)6, (Char)7, (Char)8, (Char)9, (Char)10, (Char)11, (Char)12, (Char)13, (Char)14, (Char)15, (Char)16, (Char)17, (Char)18, (Char)19, (Char)20, (Char)21, (Char)22, (Char)23, (Char)24, (Char)25, (Char)26, (Char)27, (Char)28, (Char)29, (Char)30, (Char)31, ':', '*', '?', '\\', '/' }; + _invalidFileNameChars = new char[] { '\"', '<', '>', '|', '\0', (char)1, (char)2, (char)3, (char)4, (char)5, (char)6, (char)7, (char)8, (char)9, (char)10, (char)11, (char)12, (char)13, (char)14, (char)15, (char)16, (char)17, (char)18, (char)19, (char)20, (char)21, (char)22, (char)23, (char)24, (char)25, (char)26, (char)27, (char)28, (char)29, (char)30, (char)31, ':', '*', '?', '\\', '/' }; } } - public char DirectorySeparatorChar - { - get - { - return Path.DirectorySeparatorChar; - } - } + public char DirectorySeparatorChar => Path.DirectorySeparatorChar; public string GetFullPath(string path) { @@ -112,7 +106,7 @@ namespace Emby.Server.Implementations.IO { if (string.IsNullOrEmpty(filename)) { - throw new ArgumentNullException("filename"); + throw new ArgumentNullException(nameof(filename)); } var extension = Path.GetExtension(filename); @@ -129,7 +123,7 @@ namespace Emby.Server.Implementations.IO { if (string.IsNullOrEmpty(filename)) { - throw new ArgumentNullException("filename"); + throw new ArgumentNullException(nameof(filename)); } var extension = Path.GetExtension(filename); @@ -145,7 +139,7 @@ namespace Emby.Server.Implementations.IO public string MakeAbsolutePath(string folderPath, string filePath) { - if (String.IsNullOrWhiteSpace(filePath)) return filePath; + if (string.IsNullOrWhiteSpace(filePath)) return filePath; if (filePath.Contains(@"://")) return filePath; //stream if (filePath.Length > 3 && filePath[1] == ':' && filePath[2] == '/') return filePath; //absolute local path @@ -159,7 +153,7 @@ namespace Emby.Server.Implementations.IO var firstChar = filePath[0]; if (firstChar == '/') { - // For this we don't really know. + // For this we don't really know. return filePath; } if (firstChar == '\\') //relative path @@ -200,12 +194,12 @@ namespace Emby.Server.Implementations.IO { if (string.IsNullOrEmpty(shortcutPath)) { - throw new ArgumentNullException("shortcutPath"); + throw new ArgumentNullException(nameof(shortcutPath)); } if (string.IsNullOrEmpty(target)) { - throw new ArgumentNullException("target"); + throw new ArgumentNullException(nameof(target)); } var extension = Path.GetExtension(shortcutPath); @@ -321,7 +315,7 @@ namespace Emby.Server.Implementations.IO return result; } - private ExtendedFileSystemInfo GetExtendedFileSystemInfo(string path) + private static ExtendedFileSystemInfo GetExtendedFileSystemInfo(string path) { var result = new ExtendedFileSystemInfo(); @@ -456,13 +450,13 @@ namespace Emby.Server.Implementations.IO return new FileStream(path, GetFileMode(mode), GetFileAccess(access), GetFileShare(share), defaultBufferSize, GetFileOptions(fileOpenOptions)); } - private FileOptions GetFileOptions(FileOpenOptions mode) + private static FileOptions GetFileOptions(FileOpenOptions mode) { var val = (int)mode; return (FileOptions)val; } - private FileMode GetFileMode(FileOpenMode mode) + private static FileMode GetFileMode(FileOpenMode mode) { switch (mode) { @@ -483,7 +477,7 @@ namespace Emby.Server.Implementations.IO } } - private FileAccess GetFileAccess(FileAccessMode mode) + private static FileAccess GetFileAccess(FileAccessMode mode) { switch (mode) { @@ -498,7 +492,7 @@ namespace Emby.Server.Implementations.IO } } - private FileShare GetFileShare(FileShareMode mode) + private static FileShare GetFileShare(FileShareMode mode) { switch (mode) { @@ -619,12 +613,12 @@ namespace Emby.Server.Implementations.IO { if (string.IsNullOrEmpty(file1)) { - throw new ArgumentNullException("file1"); + throw new ArgumentNullException(nameof(file1)); } if (string.IsNullOrEmpty(file2)) { - throw new ArgumentNullException("file2"); + throw new ArgumentNullException(nameof(file2)); } var temp1 = Path.Combine(_tempPath, Guid.NewGuid().ToString("N")); @@ -640,7 +634,7 @@ namespace Emby.Server.Implementations.IO CopyFile(temp1, file2, true); } - private char GetDirectorySeparatorChar(string path) + private static char GetDirectorySeparatorChar(string path) { return Path.DirectorySeparatorChar; } @@ -649,12 +643,12 @@ namespace Emby.Server.Implementations.IO { if (string.IsNullOrEmpty(parentPath)) { - throw new ArgumentNullException("parentPath"); + throw new ArgumentNullException(nameof(parentPath)); } if (string.IsNullOrEmpty(path)) { - throw new ArgumentNullException("path"); + throw new ArgumentNullException(nameof(path)); } var separatorChar = GetDirectorySeparatorChar(parentPath); @@ -666,7 +660,7 @@ namespace Emby.Server.Implementations.IO { if (string.IsNullOrEmpty(path)) { - throw new ArgumentNullException("path"); + throw new ArgumentNullException(nameof(path)); } var parent = GetDirectoryName(path); @@ -688,7 +682,7 @@ namespace Emby.Server.Implementations.IO { if (string.IsNullOrEmpty(path)) { - throw new ArgumentNullException("path"); + throw new ArgumentNullException(nameof(path)); } if (path.EndsWith(":\\", StringComparison.OrdinalIgnoreCase)) @@ -772,7 +766,7 @@ namespace Emby.Server.Implementations.IO }).ToList(); } - private string GetName(DriveInfo drive) + private static string GetName(DriveInfo drive) { return drive.Name; } @@ -972,7 +966,7 @@ namespace Emby.Server.Implementations.IO } } - private void RunProcess(string path, string args, string workingDirectory) + private static void RunProcess(string path, string args, string workingDirectory) { using (var process = Process.Start(new ProcessStartInfo { diff --git a/Emby.Server.Implementations/IO/MbLinkShortcutHandler.cs b/Emby.Server.Implementations/IO/MbLinkShortcutHandler.cs index aef53751ee..8ac662f78e 100644 --- a/Emby.Server.Implementations/IO/MbLinkShortcutHandler.cs +++ b/Emby.Server.Implementations/IO/MbLinkShortcutHandler.cs @@ -15,16 +15,13 @@ namespace Emby.Server.Implementations.IO _fileSystem = fileSystem; } - public string Extension - { - get { return ".mblink"; } - } + public string Extension => ".mblink"; public string Resolve(string shortcutPath) { if (string.IsNullOrEmpty(shortcutPath)) { - throw new ArgumentNullException("filenshortcutPathame"); + throw new ArgumentException("Shortcut path is empty or null.", nameof(shortcutPath)); } if (string.Equals(Path.GetExtension(shortcutPath), ".mblink", StringComparison.OrdinalIgnoreCase)) @@ -41,12 +38,12 @@ namespace Emby.Server.Implementations.IO { if (string.IsNullOrEmpty(shortcutPath)) { - throw new ArgumentNullException("shortcutPath"); + throw new ArgumentNullException(nameof(shortcutPath)); } if (string.IsNullOrEmpty(targetPath)) { - throw new ArgumentNullException("targetPath"); + throw new ArgumentNullException(nameof(targetPath)); } _fileSystem.WriteAllText(shortcutPath, targetPath); diff --git a/Emby.Server.Implementations/IO/ThrottledStream.cs b/Emby.Server.Implementations/IO/ThrottledStream.cs index 81760b6397..3635ee1db7 100644 --- a/Emby.Server.Implementations/IO/ThrottledStream.cs +++ b/Emby.Server.Implementations/IO/ThrottledStream.cs @@ -42,13 +42,7 @@ namespace Emby.Server.Implementations.IO /// Gets the current milliseconds. /// /// The current milliseconds. - protected long CurrentMilliseconds - { - get - { - return Environment.TickCount; - } - } + protected long CurrentMilliseconds => Environment.TickCount; /// /// Gets or sets the maximum bytes per second that can be transferred through the base stream. @@ -56,10 +50,7 @@ namespace Emby.Server.Implementations.IO /// The maximum bytes per second. public long MaximumBytesPerSecond { - get - { - return _maximumBytesPerSecond; - } + get => _maximumBytesPerSecond; set { if (MaximumBytesPerSecond != value) @@ -74,39 +65,21 @@ namespace Emby.Server.Implementations.IO /// Gets a value indicating whether the current stream supports reading. /// /// true if the stream supports reading; otherwise, false. - public override bool CanRead - { - get - { - return _baseStream.CanRead; - } - } + public override bool CanRead => _baseStream.CanRead; /// /// Gets a value indicating whether the current stream supports seeking. /// /// /// true if the stream supports seeking; otherwise, false. - public override bool CanSeek - { - get - { - return _baseStream.CanSeek; - } - } + public override bool CanSeek => _baseStream.CanSeek; /// /// Gets a value indicating whether the current stream supports writing. /// /// /// true if the stream supports writing; otherwise, false. - public override bool CanWrite - { - get - { - return _baseStream.CanWrite; - } - } + public override bool CanWrite => _baseStream.CanWrite; /// /// Gets the length in bytes of the stream. @@ -115,13 +88,7 @@ namespace Emby.Server.Implementations.IO /// A long value representing the length of the stream in bytes. /// The base stream does not support seeking. /// Methods were called after the stream was closed. - public override long Length - { - get - { - return _baseStream.Length; - } - } + public override long Length => _baseStream.Length; /// /// Gets or sets the position within the current stream. @@ -133,14 +100,8 @@ namespace Emby.Server.Implementations.IO /// Methods were called after the stream was closed. public override long Position { - get - { - return _baseStream.Position; - } - set - { - _baseStream.Position = value; - } + get => _baseStream.Position; + set => _baseStream.Position = value; } #endregion @@ -158,12 +119,12 @@ namespace Emby.Server.Implementations.IO { if (baseStream == null) { - throw new ArgumentNullException("baseStream"); + throw new ArgumentNullException(nameof(baseStream)); } if (maximumBytesPerSecond < 0) { - throw new ArgumentOutOfRangeException("maximumBytesPerSecond", + throw new ArgumentOutOfRangeException(nameof(maximumBytesPerSecond), maximumBytesPerSecond, "The maximum number of bytes per second can't be negative."); } diff --git a/Emby.Server.Implementations/Images/BaseDynamicImageProvider.cs b/Emby.Server.Implementations/Images/BaseDynamicImageProvider.cs index be17893d8f..964e389620 100644 --- a/Emby.Server.Implementations/Images/BaseDynamicImageProvider.cs +++ b/Emby.Server.Implementations/Images/BaseDynamicImageProvider.cs @@ -193,10 +193,7 @@ namespace Emby.Server.Implementations.Images return outputPath; } - public string Name - { - get { return "Dynamic Image Provider"; } - } + public string Name => "Dynamic Image Provider"; protected virtual string CreateImage(BaseItem item, List itemsWithImages, @@ -232,10 +229,7 @@ namespace Emby.Server.Implementations.Images throw new ArgumentException("Unexpected image type"); } - protected virtual int MaxImageAgeDays - { - get { return 7; } - } + protected virtual int MaxImageAgeDays => 7; public bool HasChanged(BaseItem item, IDirectoryService directoryServicee) { @@ -293,14 +287,7 @@ namespace Emby.Server.Implementations.Images return true; } - public int Order - { - get - { - // Run before the default image provider which will download placeholders - return 0; - } - } + public int Order => 0; protected string CreateSingleImage(List itemsWithImages, string outputPathWithoutExtension, ImageType imageType) { diff --git a/Emby.Server.Implementations/Library/DefaultAuthenticationProvider.cs b/Emby.Server.Implementations/Library/DefaultAuthenticationProvider.cs index 7c79a7c69e..775b5d283c 100644 --- a/Emby.Server.Implementations/Library/DefaultAuthenticationProvider.cs +++ b/Emby.Server.Implementations/Library/DefaultAuthenticationProvider.cs @@ -67,7 +67,7 @@ namespace Emby.Server.Implementations.Library if (string.IsNullOrWhiteSpace(newPasswordHash)) { - throw new ArgumentNullException("newPasswordHash"); + throw new ArgumentNullException(nameof(newPasswordHash)); } user.Password = newPasswordHash; diff --git a/Emby.Server.Implementations/Library/LibraryManager.cs b/Emby.Server.Implementations/Library/LibraryManager.cs index 451f16bef8..d901381cd4 100644 --- a/Emby.Server.Implementations/Library/LibraryManager.cs +++ b/Emby.Server.Implementations/Library/LibraryManager.cs @@ -1,4 +1,4 @@ -using MediaBrowser.Common.Extensions; +using MediaBrowser.Common.Extensions; using MediaBrowser.Common.Progress; using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Entities; @@ -147,13 +147,7 @@ namespace Emby.Server.Implementations.Library /// Gets the library items cache. /// /// The library items cache. - private ConcurrentDictionary LibraryItemsCache - { - get - { - return _libraryItemsCache; - } - } + private ConcurrentDictionary LibraryItemsCache => _libraryItemsCache; private readonly IFileSystem _fileSystem; @@ -188,7 +182,6 @@ namespace Emby.Server.Implementations.Library /// Adds the parts. /// /// The rules. - /// The plugin folders. /// The resolvers. /// The intro providers. /// The item comparers. @@ -277,7 +270,7 @@ namespace Emby.Server.Implementations.Library { if (item == null) { - throw new ArgumentNullException("item"); + throw new ArgumentNullException(nameof(item)); } if (item is IItemByName) { @@ -317,7 +310,7 @@ namespace Emby.Server.Implementations.Library { if (item == null) { - throw new ArgumentNullException("item"); + throw new ArgumentNullException(nameof(item)); } var parent = item.GetOwner() ?? item.GetParent(); @@ -329,7 +322,7 @@ namespace Emby.Server.Implementations.Library { if (item == null) { - throw new ArgumentNullException("item"); + throw new ArgumentNullException(nameof(item)); } if (item.SourceType == SourceType.Channel) @@ -449,7 +442,7 @@ namespace Emby.Server.Implementations.Library ReportItemRemoved(item, parent); } - private IEnumerable GetMetadataPaths(BaseItem item, IEnumerable children) + private static IEnumerable GetMetadataPaths(BaseItem item, IEnumerable children) { var list = new List { @@ -502,11 +495,11 @@ namespace Emby.Server.Implementations.Library { if (string.IsNullOrEmpty(key)) { - throw new ArgumentNullException("key"); + throw new ArgumentNullException(nameof(key)); } if (type == null) { - throw new ArgumentNullException("type"); + throw new ArgumentNullException(nameof(type)); } if (key.StartsWith(ConfigurationManager.ApplicationPaths.ProgramDataPath)) @@ -542,7 +535,7 @@ namespace Emby.Server.Implementations.Library { if (fileInfo == null) { - throw new ArgumentNullException("fileInfo"); + throw new ArgumentNullException(nameof(fileInfo)); } var fullPath = fileInfo.FullName; @@ -818,12 +811,12 @@ namespace Emby.Server.Implementations.Library public BaseItem FindByPath(string path, bool? isFolder) { - // If this returns multiple items it could be tricky figuring out which one is correct. + // If this returns multiple items it could be tricky figuring out which one is correct. // In most cases, the newest one will be and the others obsolete but not yet cleaned up if (string.IsNullOrEmpty(path)) { - throw new ArgumentNullException("path"); + throw new ArgumentNullException(nameof(path)); } //_logger.LogInformation("FindByPath {0}", path); @@ -921,7 +914,7 @@ namespace Emby.Server.Implementations.Library { if (value <= 0) { - throw new ArgumentOutOfRangeException("Years less than or equal to 0 are invalid."); + throw new ArgumentOutOfRangeException(nameof(value),"Years less than or equal to 0 are invalid."); } var name = value.ToString(CultureInfo.InvariantCulture); @@ -1249,7 +1242,7 @@ namespace Emby.Server.Implementations.Library { if (id.Equals(Guid.Empty)) { - throw new ArgumentNullException("id"); + throw new ArgumentNullException(nameof(id)); } BaseItem item; @@ -1699,7 +1692,7 @@ namespace Emby.Server.Implementations.Library { try { - // Try to resolve the path into a video + // Try to resolve the path into a video video = ResolvePath(_fileSystem.GetFileSystemInfo(info.Path)) as Video; if (video == null) @@ -1828,7 +1821,7 @@ namespace Emby.Server.Implementations.Library /// Creates the item. /// /// The item. - /// The cancellation token. + /// The parent item. /// Task. public void CreateItem(BaseItem item, BaseItem parent) { @@ -2023,7 +2016,7 @@ namespace Emby.Server.Implementations.Library return GetCollectionFoldersInternal(item, allUserRootChildren); } - private List GetCollectionFoldersInternal(BaseItem item, List allUserRootChildren) + private static List GetCollectionFoldersInternal(BaseItem item, List allUserRootChildren) { return allUserRootChildren .Where(i => string.Equals(i.Path, item.Path, StringComparison.OrdinalIgnoreCase) || i.PhysicalLocations.Contains(item.Path, StringComparer.OrdinalIgnoreCase)) @@ -2247,7 +2240,7 @@ namespace Emby.Server.Implementations.Library { if (parent == null) { - throw new ArgumentNullException("parent"); + throw new ArgumentNullException(nameof(parent)); } var name = parent.Name; @@ -2313,7 +2306,7 @@ namespace Emby.Server.Implementations.Library { if (string.IsNullOrEmpty(name)) { - throw new ArgumentNullException("name"); + throw new ArgumentNullException(nameof(name)); } var parentIdString = parentId.Equals(Guid.Empty) ? null : parentId.ToString("N"); @@ -2708,15 +2701,15 @@ namespace Emby.Server.Implementations.Library { if (string.IsNullOrWhiteSpace(path)) { - throw new ArgumentNullException("path"); + throw new ArgumentNullException(nameof(path)); } if (string.IsNullOrWhiteSpace(from)) { - throw new ArgumentNullException("from"); + throw new ArgumentNullException(nameof(from)); } if (string.IsNullOrWhiteSpace(to)) { - throw new ArgumentNullException("to"); + throw new ArgumentNullException(nameof(to)); } from = from.Trim(); @@ -2864,7 +2857,7 @@ namespace Emby.Server.Implementations.Library { if (string.IsNullOrWhiteSpace(name)) { - throw new ArgumentNullException("name"); + throw new ArgumentNullException(nameof(name)); } name = _fileSystem.GetValidFilename(name); @@ -2937,7 +2930,7 @@ namespace Emby.Server.Implementations.Library }); } - private bool ValidateNetworkPath(string path) + private static bool ValidateNetworkPath(string path) { //if (Environment.OSVersion.Platform == PlatformID.Win32NT) //{ @@ -2962,14 +2955,14 @@ namespace Emby.Server.Implementations.Library { if (pathInfo == null) { - throw new ArgumentNullException("path"); + throw new ArgumentNullException(nameof(pathInfo)); } var path = pathInfo.Path; if (string.IsNullOrWhiteSpace(path)) { - throw new ArgumentNullException("path"); + throw new ArgumentNullException(nameof(path)); } if (!_fileSystem.DirectoryExists(path)) @@ -3017,7 +3010,7 @@ namespace Emby.Server.Implementations.Library { if (pathInfo == null) { - throw new ArgumentNullException("path"); + throw new ArgumentNullException(nameof(pathInfo)); } if (!string.IsNullOrWhiteSpace(pathInfo.NetworkPath) && !ValidateNetworkPath(pathInfo.NetworkPath)) @@ -3075,7 +3068,7 @@ namespace Emby.Server.Implementations.Library { if (string.IsNullOrWhiteSpace(name)) { - throw new ArgumentNullException("name"); + throw new ArgumentNullException(nameof(name)); } var rootFolderPath = ConfigurationManager.ApplicationPaths.DefaultUserViewsPath; @@ -3116,7 +3109,7 @@ namespace Emby.Server.Implementations.Library { if (string.IsNullOrWhiteSpace(path)) { - throw new ArgumentNullException("path"); + throw new ArgumentNullException(nameof(path)); } var removeList = new List(); @@ -3148,7 +3141,7 @@ namespace Emby.Server.Implementations.Library { if (string.IsNullOrEmpty(mediaPath)) { - throw new ArgumentNullException("mediaPath"); + throw new ArgumentNullException(nameof(mediaPath)); } var rootFolderPath = ConfigurationManager.ApplicationPaths.DefaultUserViewsPath; diff --git a/Emby.Server.Implementations/Library/MediaSourceManager.cs b/Emby.Server.Implementations/Library/MediaSourceManager.cs index ddda4b2c39..3578d87639 100644 --- a/Emby.Server.Implementations/Library/MediaSourceManager.cs +++ b/Emby.Server.Implementations/Library/MediaSourceManager.cs @@ -1,4 +1,4 @@ -using MediaBrowser.Common.Extensions; +using MediaBrowser.Common.Extensions; using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Entities.Audio; using MediaBrowser.Controller.Library; @@ -74,7 +74,7 @@ namespace Emby.Server.Implementations.Library return list; } - private bool StreamSupportsExternalStream(MediaStream stream) + private static bool StreamSupportsExternalStream(MediaStream stream) { if (stream.IsExternal) { @@ -261,7 +261,7 @@ namespace Emby.Server.Implementations.Library } } - private void SetKeyProperties(IMediaSourceProvider provider, MediaSourceInfo mediaSource) + private static void SetKeyProperties(IMediaSourceProvider provider, MediaSourceInfo mediaSource) { var prefix = provider.GetType().FullName.GetMD5().ToString("N") + LiveStreamIdDelimeter; @@ -292,7 +292,7 @@ namespace Emby.Server.Implementations.Library { if (item == null) { - throw new ArgumentNullException("item"); + throw new ArgumentNullException(nameof(item)); } var hasMediaSources = (IHasMediaSources)item; @@ -401,7 +401,7 @@ namespace Emby.Server.Implementations.Library } } - private IEnumerable SortMediaSources(IEnumerable sources) + private static IEnumerable SortMediaSources(IEnumerable sources) { return sources.OrderBy(i => { @@ -501,7 +501,7 @@ namespace Emby.Server.Implementations.Library }, liveStream as IDirectStreamProvider); } - private void AddMediaInfo(MediaSourceInfo mediaSource, bool isAudio) + private static void AddMediaInfo(MediaSourceInfo mediaSource, bool isAudio) { mediaSource.DefaultSubtitleStreamIndex = null; @@ -629,6 +629,7 @@ namespace Emby.Server.Implementations.Library } catch (Exception ex) { + _logger.LogDebug(ex, "_jsonSerializer.DeserializeFromFile threw an exception."); } } @@ -759,7 +760,7 @@ namespace Emby.Server.Implementations.Library { if (string.IsNullOrEmpty(id)) { - throw new ArgumentNullException("id"); + throw new ArgumentNullException(nameof(id)); } var info = await GetLiveStreamInfo(id, cancellationToken).ConfigureAwait(false); @@ -770,7 +771,7 @@ namespace Emby.Server.Implementations.Library { if (string.IsNullOrEmpty(id)) { - throw new ArgumentNullException("id"); + throw new ArgumentNullException(nameof(id)); } await _liveStreamSemaphore.WaitAsync(cancellationToken).ConfigureAwait(false); @@ -803,7 +804,7 @@ namespace Emby.Server.Implementations.Library { if (string.IsNullOrEmpty(id)) { - throw new ArgumentNullException("id"); + throw new ArgumentNullException(nameof(id)); } await _liveStreamSemaphore.WaitAsync().ConfigureAwait(false); diff --git a/Emby.Server.Implementations/Library/PathExtensions.cs b/Emby.Server.Implementations/Library/PathExtensions.cs index 28ed2f53ca..2d3019d171 100644 --- a/Emby.Server.Implementations/Library/PathExtensions.cs +++ b/Emby.Server.Implementations/Library/PathExtensions.cs @@ -16,12 +16,12 @@ namespace Emby.Server.Implementations.Library { if (string.IsNullOrEmpty(str)) { - throw new ArgumentNullException("str"); + throw new ArgumentNullException(nameof(str)); } if (string.IsNullOrEmpty(attrib)) { - throw new ArgumentNullException("attrib"); + throw new ArgumentNullException(nameof(attrib)); } string srch = "[" + attrib + "="; diff --git a/Emby.Server.Implementations/Library/ResolverHelper.cs b/Emby.Server.Implementations/Library/ResolverHelper.cs index 14b28966aa..027d82c588 100644 --- a/Emby.Server.Implementations/Library/ResolverHelper.cs +++ b/Emby.Server.Implementations/Library/ResolverHelper.cs @@ -117,15 +117,15 @@ namespace Emby.Server.Implementations.Library { if (fileSystem == null) { - throw new ArgumentNullException("fileSystem"); + throw new ArgumentNullException(nameof(fileSystem)); } if (item == null) { - throw new ArgumentNullException("item"); + throw new ArgumentNullException(nameof(item)); } if (args == null) { - throw new ArgumentNullException("args"); + throw new ArgumentNullException(nameof(args)); } // See if a different path came out of the resolver than what went in diff --git a/Emby.Server.Implementations/Library/Resolvers/Audio/AudioResolver.cs b/Emby.Server.Implementations/Library/Resolvers/Audio/AudioResolver.cs index 8872bd641e..bac39122b3 100644 --- a/Emby.Server.Implementations/Library/Resolvers/Audio/AudioResolver.cs +++ b/Emby.Server.Implementations/Library/Resolvers/Audio/AudioResolver.cs @@ -1,4 +1,4 @@ -using MediaBrowser.Controller.Library; +using MediaBrowser.Controller.Library; using MediaBrowser.Controller.Resolvers; using MediaBrowser.Model.Entities; using System; @@ -30,10 +30,7 @@ namespace Emby.Server.Implementations.Library.Resolvers.Audio /// Gets the priority. /// /// The priority. - public override ResolverPriority Priority - { - get { return ResolverPriority.Fourth; } - } + public override ResolverPriority Priority => ResolverPriority.Fourth; public MultiItemResolverResult ResolveMultiple(Folder parent, List files, @@ -231,7 +228,7 @@ namespace Emby.Server.Implementations.Library.Resolvers.Audio } var firstMedia = resolvedItem.Files.First(); - + var libraryItem = new T { Path = firstMedia.Path, @@ -264,12 +261,12 @@ namespace Emby.Server.Implementations.Library.Resolvers.Audio result.Extras.Any(i => ContainsFile(i, file)); } - private bool ContainsFile(AudioBookFileInfo result, FileSystemMetadata file) + private static bool ContainsFile(AudioBookFileInfo result, FileSystemMetadata file) { return string.Equals(result.Path, file.FullName, StringComparison.OrdinalIgnoreCase); } - private bool IsIgnored(string filename) + private static bool IsIgnored(string filename) { return false; } diff --git a/Emby.Server.Implementations/Library/Resolvers/Audio/MusicAlbumResolver.cs b/Emby.Server.Implementations/Library/Resolvers/Audio/MusicAlbumResolver.cs index dbfcf41e8b..da5fe48cda 100644 --- a/Emby.Server.Implementations/Library/Resolvers/Audio/MusicAlbumResolver.cs +++ b/Emby.Server.Implementations/Library/Resolvers/Audio/MusicAlbumResolver.cs @@ -36,14 +36,7 @@ namespace Emby.Server.Implementations.Library.Resolvers.Audio /// Gets the priority. /// /// The priority. - public override ResolverPriority Priority - { - get - { - // Behind special folder resolver - return ResolverPriority.Second; - } - } + public override ResolverPriority Priority => ResolverPriority.Second; /// /// Resolves the specified args. diff --git a/Emby.Server.Implementations/Library/Resolvers/Audio/MusicArtistResolver.cs b/Emby.Server.Implementations/Library/Resolvers/Audio/MusicArtistResolver.cs index 71ccd7da8e..b3a5c27c88 100644 --- a/Emby.Server.Implementations/Library/Resolvers/Audio/MusicArtistResolver.cs +++ b/Emby.Server.Implementations/Library/Resolvers/Audio/MusicArtistResolver.cs @@ -35,14 +35,7 @@ namespace Emby.Server.Implementations.Library.Resolvers.Audio /// Gets the priority. /// /// The priority. - public override ResolverPriority Priority - { - get - { - // Behind special folder resolver - return ResolverPriority.Second; - } - } + public override ResolverPriority Priority => ResolverPriority.Second; /// /// Resolves the specified args. diff --git a/Emby.Server.Implementations/Library/Resolvers/BaseVideoResolver.cs b/Emby.Server.Implementations/Library/Resolvers/BaseVideoResolver.cs index 143af40767..b9ac2056fc 100644 --- a/Emby.Server.Implementations/Library/Resolvers/BaseVideoResolver.cs +++ b/Emby.Server.Implementations/Library/Resolvers/BaseVideoResolver.cs @@ -48,7 +48,7 @@ namespace Emby.Server.Implementations.Library.Resolvers where TVideoType : Video, new() { var namingOptions = ((LibraryManager)LibraryManager).GetNamingOptions(); - + // If the path is a file check for a matching extensions var parser = new Emby.Naming.Video.VideoResolver(namingOptions); @@ -120,7 +120,7 @@ namespace Emby.Server.Implementations.Library.Resolvers if (video != null) { - video.Name = parseName ? + video.Name = parseName ? videoInfo.Name : Path.GetFileName(args.Path); @@ -150,7 +150,7 @@ namespace Emby.Server.Implementations.Library.Resolvers }; SetVideoType(video, videoInfo); - + video.Name = parseName ? videoInfo.Name : Path.GetFileNameWithoutExtension(args.Path); @@ -281,7 +281,7 @@ namespace Emby.Server.Implementations.Library.Resolvers { return string.Equals(name, "video_ts.ifo", StringComparison.OrdinalIgnoreCase); } - + /// /// Determines whether [is blu ray directory] [the specified directory name]. /// diff --git a/Emby.Server.Implementations/Library/Resolvers/Books/BookResolver.cs b/Emby.Server.Implementations/Library/Resolvers/Books/BookResolver.cs index 7aa4c299ff..d7f80b3f41 100644 --- a/Emby.Server.Implementations/Library/Resolvers/Books/BookResolver.cs +++ b/Emby.Server.Implementations/Library/Resolvers/Books/BookResolver.cs @@ -8,14 +8,14 @@ using MediaBrowser.Model.Entities; namespace Emby.Server.Implementations.Library.Resolvers.Books { /// - /// + /// /// public class BookResolver : MediaBrowser.Controller.Resolvers.ItemResolver { private readonly string[] _validExtensions = { ".pdf", ".epub", ".mobi", ".cbr", ".cbz", ".azw3" }; /// - /// + /// /// /// /// @@ -48,7 +48,7 @@ namespace Emby.Server.Implementations.Library.Resolvers.Books } /// - /// + /// /// /// /// diff --git a/Emby.Server.Implementations/Library/Resolvers/FolderResolver.cs b/Emby.Server.Implementations/Library/Resolvers/FolderResolver.cs index 5e73baa5ce..47e7f7344b 100644 --- a/Emby.Server.Implementations/Library/Resolvers/FolderResolver.cs +++ b/Emby.Server.Implementations/Library/Resolvers/FolderResolver.cs @@ -13,10 +13,7 @@ namespace Emby.Server.Implementations.Library.Resolvers /// Gets the priority. /// /// The priority. - public override ResolverPriority Priority - { - get { return ResolverPriority.Last; } - } + public override ResolverPriority Priority => ResolverPriority.Last; /// /// Resolves the specified args. diff --git a/Emby.Server.Implementations/Library/Resolvers/ItemResolver.cs b/Emby.Server.Implementations/Library/Resolvers/ItemResolver.cs index b4a37be5f2..529916619c 100644 --- a/Emby.Server.Implementations/Library/Resolvers/ItemResolver.cs +++ b/Emby.Server.Implementations/Library/Resolvers/ItemResolver.cs @@ -25,13 +25,7 @@ namespace Emby.Server.Implementations.Library.Resolvers /// Gets the priority. /// /// The priority. - public virtual ResolverPriority Priority - { - get - { - return ResolverPriority.First; - } - } + public virtual ResolverPriority Priority => ResolverPriority.First; /// /// Sets initial values on the newly resolved item diff --git a/Emby.Server.Implementations/Library/Resolvers/Movies/BoxSetResolver.cs b/Emby.Server.Implementations/Library/Resolvers/Movies/BoxSetResolver.cs index b9aca14173..d3ab4dd377 100644 --- a/Emby.Server.Implementations/Library/Resolvers/Movies/BoxSetResolver.cs +++ b/Emby.Server.Implementations/Library/Resolvers/Movies/BoxSetResolver.cs @@ -1,4 +1,4 @@ -using MediaBrowser.Controller.Entities; +using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Entities.Movies; using MediaBrowser.Controller.Library; using MediaBrowser.Model.Entities; @@ -61,7 +61,7 @@ namespace Emby.Server.Implementations.Library.Resolvers.Movies /// Sets the provider id from path. /// /// The item. - private void SetProviderIdFromPath(BaseItem item) + private static void SetProviderIdFromPath(BaseItem item) { //we need to only look at the name of this actual item (not parents) var justName = Path.GetFileName(item.Path); diff --git a/Emby.Server.Implementations/Library/Resolvers/Movies/MovieResolver.cs b/Emby.Server.Implementations/Library/Resolvers/Movies/MovieResolver.cs index 68b6c57ae6..0a45317a4e 100644 --- a/Emby.Server.Implementations/Library/Resolvers/Movies/MovieResolver.cs +++ b/Emby.Server.Implementations/Library/Resolvers/Movies/MovieResolver.cs @@ -1,4 +1,4 @@ -using MediaBrowser.Controller.Entities; +using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Entities.Movies; using MediaBrowser.Controller.Entities.TV; using MediaBrowser.Controller.Library; @@ -27,17 +27,7 @@ namespace Emby.Server.Implementations.Library.Resolvers.Movies /// Gets the priority. /// /// The priority. - public override ResolverPriority Priority - { - get - { - // Give plugins a chance to catch iso's first - // Also since we have to loop through child files looking for videos, - // see if we can avoid some of that by letting other resolvers claim folders first - // Also run after series resolver - return ResolverPriority.Third; - } - } + public override ResolverPriority Priority => ResolverPriority.Third; public MultiItemResolverResult ResolveMultiple(Folder parent, List files, @@ -176,7 +166,7 @@ namespace Emby.Server.Implementations.Library.Resolvers.Movies return result; } - private bool IsIgnored(string filename) + private static bool IsIgnored(string filename) { // Ignore samples var sampleFilename = " " + filename.Replace(".", " ", StringComparison.OrdinalIgnoreCase) @@ -204,7 +194,7 @@ namespace Emby.Server.Implementations.Library.Resolvers.Movies result.Extras.Any(i => ContainsFile(i, file)); } - private bool ContainsFile(VideoFileInfo result, FileSystemMetadata file) + private static bool ContainsFile(VideoFileInfo result, FileSystemMetadata file) { return string.Equals(result.Path, file.FullName, StringComparison.OrdinalIgnoreCase); } @@ -330,7 +320,7 @@ namespace Emby.Server.Implementations.Library.Resolvers.Movies /// Sets the provider id from path. /// /// The item. - private void SetProviderIdsFromPath(Video item) + private static void SetProviderIdsFromPath(Video item) { if (item is Movie || item is MusicVideo) { diff --git a/Emby.Server.Implementations/Library/Resolvers/PhotoAlbumResolver.cs b/Emby.Server.Implementations/Library/Resolvers/PhotoAlbumResolver.cs index 311abf14e3..a073e0bd5b 100644 --- a/Emby.Server.Implementations/Library/Resolvers/PhotoAlbumResolver.cs +++ b/Emby.Server.Implementations/Library/Resolvers/PhotoAlbumResolver.cs @@ -79,13 +79,6 @@ namespace Emby.Server.Implementations.Library.Resolvers return false; } - public override ResolverPriority Priority - { - get - { - // Behind special folder resolver - return ResolverPriority.Second; - } - } + public override ResolverPriority Priority => ResolverPriority.Second; } } diff --git a/Emby.Server.Implementations/Library/Resolvers/SpecialFolderResolver.cs b/Emby.Server.Implementations/Library/Resolvers/SpecialFolderResolver.cs index 6a1f8ec6f2..5cf5cd3ad7 100644 --- a/Emby.Server.Implementations/Library/Resolvers/SpecialFolderResolver.cs +++ b/Emby.Server.Implementations/Library/Resolvers/SpecialFolderResolver.cs @@ -26,10 +26,7 @@ namespace Emby.Server.Implementations.Library.Resolvers /// Gets the priority. /// /// The priority. - public override ResolverPriority Priority - { - get { return ResolverPriority.First; } - } + public override ResolverPriority Priority => ResolverPriority.First; /// /// Resolves the specified args. diff --git a/Emby.Server.Implementations/Library/Resolvers/TV/EpisodeResolver.cs b/Emby.Server.Implementations/Library/Resolvers/TV/EpisodeResolver.cs index 7d1c4d65a5..4e5ac959ca 100644 --- a/Emby.Server.Implementations/Library/Resolvers/TV/EpisodeResolver.cs +++ b/Emby.Server.Implementations/Library/Resolvers/TV/EpisodeResolver.cs @@ -27,7 +27,7 @@ namespace Emby.Server.Implementations.Library.Resolvers.TV } var season = parent as Season; - // Just in case the user decided to nest episodes. + // Just in case the user decided to nest episodes. // Not officially supported but in some cases we can handle it. if (season == null) { @@ -36,8 +36,8 @@ namespace Emby.Server.Implementations.Library.Resolvers.TV // If the parent is a Season or Series, then this is an Episode if the VideoResolver returns something // Also handle flat tv folders - if (season != null || - string.Equals(args.GetCollectionType(), CollectionType.TvShows, StringComparison.OrdinalIgnoreCase) || + if (season != null || + string.Equals(args.GetCollectionType(), CollectionType.TvShows, StringComparison.OrdinalIgnoreCase) || args.HasParent()) { var episode = ResolveVideo(args, false); diff --git a/Emby.Server.Implementations/Library/Resolvers/TV/SeasonResolver.cs b/Emby.Server.Implementations/Library/Resolvers/TV/SeasonResolver.cs index 0fe42fa736..4bfedf3c62 100644 --- a/Emby.Server.Implementations/Library/Resolvers/TV/SeasonResolver.cs +++ b/Emby.Server.Implementations/Library/Resolvers/TV/SeasonResolver.cs @@ -1,4 +1,4 @@ -using System.Globalization; +using System.Globalization; using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Entities.TV; using MediaBrowser.Controller.Library; @@ -28,6 +28,9 @@ namespace Emby.Server.Implementations.Library.Resolvers.TV /// Initializes a new instance of the class. /// /// The config. + /// The library manager. + /// The localization + /// The logger public SeasonResolver(IServerConfigurationManager config, ILibraryManager libraryManager, ILocalizationManager localization, ILogger logger) { _config = config; diff --git a/Emby.Server.Implementations/Library/Resolvers/TV/SeriesResolver.cs b/Emby.Server.Implementations/Library/Resolvers/TV/SeriesResolver.cs index 32e8b6120d..7d2865f0d8 100644 --- a/Emby.Server.Implementations/Library/Resolvers/TV/SeriesResolver.cs +++ b/Emby.Server.Implementations/Library/Resolvers/TV/SeriesResolver.cs @@ -1,4 +1,4 @@ -using MediaBrowser.Controller.Entities.TV; +using MediaBrowser.Controller.Entities.TV; using MediaBrowser.Controller.Library; using MediaBrowser.Controller.Providers; using MediaBrowser.Controller.Resolvers; @@ -38,13 +38,7 @@ namespace Emby.Server.Implementations.Library.Resolvers.TV /// Gets the priority. /// /// The priority. - public override ResolverPriority Priority - { - get - { - return ResolverPriority.Second; - } - } + public override ResolverPriority Priority => ResolverPriority.Second; /// /// Resolves the specified args. @@ -195,7 +189,7 @@ namespace Emby.Server.Implementations.Library.Resolvers.TV { if (string.IsNullOrEmpty(path)) { - throw new ArgumentNullException("path"); + throw new ArgumentNullException(nameof(path)); } var extension = Path.GetExtension(path); @@ -236,7 +230,7 @@ namespace Emby.Server.Implementations.Library.Resolvers.TV /// /// The item. /// The path. - private void SetProviderIdFromPath(Series item, string path) + private static void SetProviderIdFromPath(Series item, string path) { var justName = Path.GetFileName(path); diff --git a/Emby.Server.Implementations/Library/SearchEngine.cs b/Emby.Server.Implementations/Library/SearchEngine.cs index 1212ba549e..bbb1394395 100644 --- a/Emby.Server.Implementations/Library/SearchEngine.cs +++ b/Emby.Server.Implementations/Library/SearchEngine.cs @@ -1,4 +1,4 @@ -using MediaBrowser.Controller.Entities; +using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Entities.Audio; using MediaBrowser.Controller.Library; using Microsoft.Extensions.Logging; @@ -64,7 +64,7 @@ namespace Emby.Server.Implementations.Library }; } - private void AddIfMissing(List list, string value) + private static void AddIfMissing(List list, string value) { if (!list.Contains(value, StringComparer.OrdinalIgnoreCase)) { @@ -85,7 +85,7 @@ namespace Emby.Server.Implementations.Library if (string.IsNullOrEmpty(searchTerm)) { - throw new ArgumentNullException("searchTerm"); + throw new ArgumentNullException(nameof(searchTerm)); } searchTerm = searchTerm.Trim().RemoveDiacritics(); diff --git a/Emby.Server.Implementations/Library/UserDataManager.cs b/Emby.Server.Implementations/Library/UserDataManager.cs index 27ba32c0cb..3ca4b6b109 100644 --- a/Emby.Server.Implementations/Library/UserDataManager.cs +++ b/Emby.Server.Implementations/Library/UserDataManager.cs @@ -53,11 +53,11 @@ namespace Emby.Server.Implementations.Library { if (userData == null) { - throw new ArgumentNullException("userData"); + throw new ArgumentNullException(nameof(userData)); } if (item == null) { - throw new ArgumentNullException("item"); + throw new ArgumentNullException(nameof(item)); } cancellationToken.ThrowIfCancellationRequested(); @@ -150,7 +150,7 @@ namespace Emby.Server.Implementations.Library /// Gets the internal key. /// /// System.String. - private string GetCacheKey(long internalUserId, Guid itemId) + private static string GetCacheKey(long internalUserId, Guid itemId) { return internalUserId.ToString(CultureInfo.InvariantCulture) + "-" + itemId.ToString("N"); } @@ -198,7 +198,7 @@ namespace Emby.Server.Implementations.Library { if (data == null) { - throw new ArgumentNullException("data"); + throw new ArgumentNullException(nameof(data)); } return new UserItemDataDto @@ -226,7 +226,7 @@ namespace Emby.Server.Implementations.Library // If a position has been reported, and if we know the duration if (positionTicks > 0 && hasRuntime) { - var pctIn = Decimal.Divide(positionTicks, runtimeTicks) * 100; + var pctIn = decimal.Divide(positionTicks, runtimeTicks) * 100; // Don't track in very beginning if (pctIn < _config.Configuration.MinResumePct) diff --git a/Emby.Server.Implementations/Library/UserManager.cs b/Emby.Server.Implementations/Library/UserManager.cs index 679116fc0a..c059cbc75b 100644 --- a/Emby.Server.Implementations/Library/UserManager.cs +++ b/Emby.Server.Implementations/Library/UserManager.cs @@ -1,4 +1,4 @@ -using MediaBrowser.Common.Events; +using MediaBrowser.Common.Events; using MediaBrowser.Common.Net; using MediaBrowser.Controller; using MediaBrowser.Controller.Configuration; @@ -44,7 +44,7 @@ namespace Emby.Server.Implementations.Library /// Gets the users. /// /// The users. - public IEnumerable Users { get { return _users; } } + public IEnumerable Users => _users; private User[] _users; @@ -163,7 +163,7 @@ namespace Emby.Server.Implementations.Library { if (id.Equals(Guid.Empty)) { - throw new ArgumentNullException("id"); + throw new ArgumentNullException(nameof(id)); } return Users.FirstOrDefault(u => u.Id == id); @@ -183,7 +183,7 @@ namespace Emby.Server.Implementations.Library { if (string.IsNullOrWhiteSpace(name)) { - throw new ArgumentNullException("name"); + throw new ArgumentNullException(nameof(name)); } return Users.FirstOrDefault(u => string.Equals(u.Name, name, StringComparison.OrdinalIgnoreCase)); @@ -222,7 +222,7 @@ namespace Emby.Server.Implementations.Library return true; } - private bool IsValidUsernameCharacter(char i) + private static bool IsValidUsernameCharacter(char i) { return !char.Equals(i, '<') && !char.Equals(i, '>'); } @@ -251,7 +251,7 @@ namespace Emby.Server.Implementations.Library { if (string.IsNullOrWhiteSpace(username)) { - throw new ArgumentNullException("username"); + throw new ArgumentNullException(nameof(username)); } var user = Users @@ -344,7 +344,7 @@ namespace Emby.Server.Implementations.Library return success ? user : null; } - private string GetAuthenticationProviderId(IAuthenticationProvider provider) + private static string GetAuthenticationProviderId(IAuthenticationProvider provider) { return provider.GetType().FullName; } @@ -526,7 +526,7 @@ namespace Emby.Server.Implementations.Library { if (user == null) { - throw new ArgumentNullException("user"); + throw new ArgumentNullException(nameof(user)); } var hasConfiguredPassword = GetAuthenticationProvider(user).HasPassword(user).Result; @@ -625,12 +625,12 @@ namespace Emby.Server.Implementations.Library { if (user == null) { - throw new ArgumentNullException("user"); + throw new ArgumentNullException(nameof(user)); } if (string.IsNullOrEmpty(newName)) { - throw new ArgumentNullException("newName"); + throw new ArgumentNullException(nameof(newName)); } if (Users.Any(u => u.Id != user.Id && u.Name.Equals(newName, StringComparison.OrdinalIgnoreCase))) @@ -658,7 +658,7 @@ namespace Emby.Server.Implementations.Library { if (user == null) { - throw new ArgumentNullException("user"); + throw new ArgumentNullException(nameof(user)); } if (user.Id.Equals(Guid.Empty) || !Users.Any(u => u.Id.Equals(user.Id))) @@ -689,7 +689,7 @@ namespace Emby.Server.Implementations.Library { if (string.IsNullOrWhiteSpace(name)) { - throw new ArgumentNullException("name"); + throw new ArgumentNullException(nameof(name)); } if (!IsValidUsername(name)) @@ -737,7 +737,7 @@ namespace Emby.Server.Implementations.Library { if (user == null) { - throw new ArgumentNullException("user"); + throw new ArgumentNullException(nameof(user)); } var allUsers = Users.ToList(); @@ -804,7 +804,7 @@ namespace Emby.Server.Implementations.Library { if (user == null) { - throw new ArgumentNullException("user"); + throw new ArgumentNullException(nameof(user)); } if (user.ConnectLinkType.HasValue && user.ConnectLinkType.Value == UserLinkType.Guest) @@ -823,7 +823,7 @@ namespace Emby.Server.Implementations.Library { if (user == null) { - throw new ArgumentNullException("user"); + throw new ArgumentNullException(nameof(user)); } if (newPassword != null) @@ -833,7 +833,7 @@ namespace Emby.Server.Implementations.Library if (string.IsNullOrWhiteSpace(newPasswordHash)) { - throw new ArgumentNullException("newPasswordHash"); + throw new ArgumentNullException(nameof(newPasswordHash)); } user.EasyPassword = newPasswordHash; @@ -848,7 +848,7 @@ namespace Emby.Server.Implementations.Library /// /// The name. /// User. - private User InstantiateNewUser(string name) + private static User InstantiateNewUser(string name) { return new User { @@ -861,10 +861,7 @@ namespace Emby.Server.Implementations.Library }; } - private string PasswordResetFile - { - get { return Path.Combine(ConfigurationManager.ApplicationPaths.ProgramDataPath, "passwordreset.txt"); } - } + private string PasswordResetFile => Path.Combine(ConfigurationManager.ApplicationPaths.ProgramDataPath, "passwordreset.txt"); private string _lastPin; private PasswordPinCreationResult _lastPasswordPinCreationResult; @@ -888,7 +885,7 @@ namespace Emby.Server.Implementations.Library text.AppendLine("Use your web browser to visit:"); text.AppendLine(string.Empty); - text.AppendLine(localAddress + "/web/forgotpasswordpin.html"); + text.AppendLine(localAddress + "/web/index.html#!/forgotpasswordpin.html"); text.AppendLine(string.Empty); text.AppendLine("Enter the following pin code:"); text.AppendLine(string.Empty); @@ -1047,7 +1044,7 @@ namespace Emby.Server.Implementations.Library } } - private UserPolicy GetDefaultPolicy(User user) + private static UserPolicy GetDefaultPolicy(User user) { return new UserPolicy { @@ -1109,12 +1106,12 @@ namespace Emby.Server.Implementations.Library } } - private string GetPolicyFilePath(User user) + private static string GetPolicyFilePath(User user) { return Path.Combine(user.ConfigurationDirectoryPath, "policy.xml"); } - private string GetConfigurationFilePath(User user) + private static string GetConfigurationFilePath(User user) { return Path.Combine(user.ConfigurationDirectoryPath, "config.xml"); } diff --git a/Emby.Server.Implementations/Library/UserViewManager.cs b/Emby.Server.Implementations/Library/UserViewManager.cs index aae5751de1..d616e12095 100644 --- a/Emby.Server.Implementations/Library/UserViewManager.cs +++ b/Emby.Server.Implementations/Library/UserViewManager.cs @@ -282,7 +282,7 @@ namespace Emby.Server.Implementations.Library if (includeItemTypes.Length == 0) { - // Handle situations with the grouping setting, e.g. movies showing up in tv, etc. + // Handle situations with the grouping setting, e.g. movies showing up in tv, etc. // Thanks to mixed content libraries included in the UserView var hasCollectionType = parents.OfType().ToArray(); if (hasCollectionType.Length > 0) diff --git a/Emby.Server.Implementations/Library/Validators/ArtistsValidator.cs b/Emby.Server.Implementations/Library/Validators/ArtistsValidator.cs index 1686dc23c1..278c0cc7ad 100644 --- a/Emby.Server.Implementations/Library/Validators/ArtistsValidator.cs +++ b/Emby.Server.Implementations/Library/Validators/ArtistsValidator.cs @@ -94,7 +94,7 @@ namespace Emby.Server.Implementations.Library.Validators { continue; } - + _logger.LogInformation("Deleting dead {2} {0} {1}.", item.Id.ToString("N"), item.Name, item.GetType().Name); _libraryManager.DeleteItem(item, new DeleteOptions diff --git a/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs b/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs index 81a47bfea1..b787e8f0f9 100644 --- a/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs +++ b/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Concurrent; using System.Collections.Generic; using System.Globalization; @@ -254,27 +254,15 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV if (requiresRefresh) { - await _libraryManager.ValidateMediaLibrary(new SimpleProgress(), CancellationToken.None); + await _libraryManager.ValidateMediaLibrary(new SimpleProgress(), CancellationToken.None); } } - public string Name - { - get { return "Emby"; } - } + public string Name => "Emby"; - public string DataPath - { - get { return Path.Combine(_config.CommonApplicationPaths.DataPath, "livetv"); } - } + public string DataPath => Path.Combine(_config.CommonApplicationPaths.DataPath, "livetv"); - private string DefaultRecordingPath - { - get - { - return Path.Combine(DataPath, "recordings"); - } - } + private string DefaultRecordingPath => Path.Combine(DataPath, "recordings"); private string RecordingPath { @@ -288,10 +276,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV } } - public string HomePageUrl - { - get { return "https://github.com/jellyfin/jellyfin"; } - } + public string HomePageUrl => "https://github.com/jellyfin/jellyfin"; public async Task RefreshSeriesTimers(CancellationToken cancellationToken, IProgress progress) { @@ -467,18 +452,14 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV public ChannelInfo GetChannelByNumber(string number) { - ChannelInfo result = null; - - ChannelsByNumber.TryGetValue(number, out result); + ChannelsByNumber.TryGetValue(number, out var result); return result; } public ChannelInfo GetChannelByName(string name) { - ChannelInfo result = null; - - ChannelsByName.TryGetValue(name, out result); + ChannelsByName.TryGetValue(name, out var result); return result; } @@ -491,7 +472,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV return GetEpgChannelFromTunerChannel(info, tunerChannel, epgChannels); } - private string GetMappedChannel(string channelId, NameValuePair[] mappings) + private static string GetMappedChannel(string channelId, NameValuePair[] mappings) { foreach (NameValuePair mapping in mappings) { @@ -850,7 +831,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV return Task.CompletedTask; } - private void UpdateExistingTimerWithNewMetadata(TimerInfo existingTimer, TimerInfo updatedTimer) + private static void UpdateExistingTimerWithNewMetadata(TimerInfo existingTimer, TimerInfo updatedTimer) { // Update the program info but retain the status existingTimer.ChannelId = updatedTimer.ChannelId; @@ -980,7 +961,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV if (string.IsNullOrWhiteSpace(tunerHostId)) { - throw new ArgumentNullException("tunerHostId"); + throw new ArgumentNullException(nameof(tunerHostId)); } return info.EnabledTuners.Contains(tunerHostId, StringComparer.OrdinalIgnoreCase); @@ -1055,7 +1036,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV { _logger.LogInformation("Streaming Channel " + channelId); - var result = string.IsNullOrEmpty(streamId) ? + var result = string.IsNullOrEmpty(streamId) ? null : currentLiveStreams.FirstOrDefault(i => string.Equals(i.OriginalStreamId, streamId, StringComparison.OrdinalIgnoreCase)); @@ -1114,7 +1095,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV { if (string.IsNullOrWhiteSpace(channelId)) { - throw new ArgumentNullException("channelId"); + throw new ArgumentNullException(nameof(channelId)); } foreach (var hostInstance in _liveTvManager.TunerHosts) @@ -1198,14 +1179,6 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV return; } - var registration = await _liveTvManager.GetRegistrationInfo("dvr").ConfigureAwait(false); - if (!registration.IsValid) - { - _logger.LogWarning("Emby Premiere required to use Emby DVR."); - OnTimerOutOfDate(timer); - return; - } - var activeRecordingInfo = new ActiveRecordingInfo { CancellationTokenSource = new CancellationTokenSource(), @@ -1342,7 +1315,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV { if (timer == null) { - throw new ArgumentNullException("timer"); + throw new ArgumentNullException(nameof(timer)); } LiveTvProgram programInfo = null; @@ -1795,7 +1768,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV } } - private string GetPostProcessArguments(string path, string arguments) + private static string GetPostProcessArguments(string path, string arguments) { return arguments.Replace("{path}", path, StringComparison.OrdinalIgnoreCase); } @@ -2394,80 +2367,68 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV var allTimers = GetTimersForSeries(seriesTimer) .ToList(); - var registration = await _liveTvManager.GetRegistrationInfo("seriesrecordings").ConfigureAwait(false); var enabledTimersForSeries = new List(); - - if (registration.IsValid) + foreach (var timer in allTimers) { - foreach (var timer in allTimers) + var existingTimer = _timerProvider.GetTimer(timer.Id); + + if (existingTimer == null) { - var existingTimer = _timerProvider.GetTimer(timer.Id); + existingTimer = string.IsNullOrWhiteSpace(timer.ProgramId) + ? null + : _timerProvider.GetTimerByProgramId(timer.ProgramId); + } - if (existingTimer == null) + if (existingTimer == null) + { + if (ShouldCancelTimerForSeriesTimer(seriesTimer, timer)) { - existingTimer = string.IsNullOrWhiteSpace(timer.ProgramId) - ? null - : _timerProvider.GetTimerByProgramId(timer.ProgramId); - } - - if (existingTimer == null) - { - if (ShouldCancelTimerForSeriesTimer(seriesTimer, timer)) - { - timer.Status = RecordingStatus.Cancelled; - } - else - { - enabledTimersForSeries.Add(timer); - } - _timerProvider.Add(timer); - - if (TimerCreated != null) - { - TimerCreated(this, new GenericEventArgs(timer)); - } + timer.Status = RecordingStatus.Cancelled; } else { - // Only update if not currently active - test both new timer and existing in case Id's are different - // Id's could be different if the timer was created manually prior to series timer creation - ActiveRecordingInfo activeRecordingInfo; - if (!_activeRecordings.TryGetValue(timer.Id, out activeRecordingInfo) && !_activeRecordings.TryGetValue(existingTimer.Id, out activeRecordingInfo)) - { - UpdateExistingTimerWithNewMetadata(existingTimer, timer); - - // Needed by ShouldCancelTimerForSeriesTimer - timer.IsManual = existingTimer.IsManual; - - if (ShouldCancelTimerForSeriesTimer(seriesTimer, timer)) - { - existingTimer.Status = RecordingStatus.Cancelled; - } - else if (!existingTimer.IsManual) - { - existingTimer.Status = RecordingStatus.New; - } - - if (existingTimer.Status != RecordingStatus.Cancelled) - { - enabledTimersForSeries.Add(existingTimer); - } - - if (updateTimerSettings) - { - existingTimer.KeepUntil = seriesTimer.KeepUntil; - existingTimer.IsPostPaddingRequired = seriesTimer.IsPostPaddingRequired; - existingTimer.IsPrePaddingRequired = seriesTimer.IsPrePaddingRequired; - existingTimer.PostPaddingSeconds = seriesTimer.PostPaddingSeconds; - existingTimer.PrePaddingSeconds = seriesTimer.PrePaddingSeconds; - existingTimer.Priority = seriesTimer.Priority; - } - - existingTimer.SeriesTimerId = seriesTimer.Id; - _timerProvider.Update(existingTimer); - } + enabledTimersForSeries.Add(timer); } + _timerProvider.Add(timer); + + TimerCreated?.Invoke(this, new GenericEventArgs(timer)); + } + // Only update if not currently active - test both new timer and existing in case Id's are different + // Id's could be different if the timer was created manually prior to series timer creation + else if (!_activeRecordings.TryGetValue(timer.Id, out _) && !_activeRecordings.TryGetValue(existingTimer.Id, out _)) + { + UpdateExistingTimerWithNewMetadata(existingTimer, timer); + + // Needed by ShouldCancelTimerForSeriesTimer + timer.IsManual = existingTimer.IsManual; + + if (ShouldCancelTimerForSeriesTimer(seriesTimer, timer)) + { + existingTimer.Status = RecordingStatus.Cancelled; + } + else if (!existingTimer.IsManual) + { + existingTimer.Status = RecordingStatus.New; + } + + if (existingTimer.Status != RecordingStatus.Cancelled) + { + enabledTimersForSeries.Add(existingTimer); + } + + if (updateTimerSettings) + { + existingTimer.KeepUntil = seriesTimer.KeepUntil; + existingTimer.IsPostPaddingRequired = seriesTimer.IsPostPaddingRequired; + existingTimer.IsPrePaddingRequired = seriesTimer.IsPrePaddingRequired; + existingTimer.PostPaddingSeconds = seriesTimer.PostPaddingSeconds; + existingTimer.PrePaddingSeconds = seriesTimer.PrePaddingSeconds; + existingTimer.Priority = seriesTimer.Priority; + } + + existingTimer.SeriesTimerId = seriesTimer.Id; + _timerProvider.Update(existingTimer); } } @@ -2501,7 +2462,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV { if (seriesTimer == null) { - throw new ArgumentNullException("seriesTimer"); + throw new ArgumentNullException(nameof(seriesTimer)); } var query = new InternalItemsQuery @@ -2536,9 +2497,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV if (string.IsNullOrWhiteSpace(channelId) && !parent.ChannelId.Equals(Guid.Empty)) { - LiveTvChannel channel; - - if (!tempChannelCache.TryGetValue(parent.ChannelId, out channel)) + if (!tempChannelCache.TryGetValue(parent.ChannelId, out var channel)) { channel = _libraryManager.GetItemList(new InternalItemsQuery { @@ -2597,9 +2556,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV if (!programInfo.ChannelId.Equals(Guid.Empty)) { - LiveTvChannel channel; - - if (!tempChannelCache.TryGetValue(programInfo.ChannelId, out channel)) + if (!tempChannelCache.TryGetValue(programInfo.ChannelId, out var channel)) { channel = _libraryManager.GetItemList(new InternalItemsQuery { @@ -2797,15 +2754,12 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV { var configuredDevice = configuredDevices.FirstOrDefault(i => string.Equals(i.DeviceId, device.DeviceId, StringComparison.OrdinalIgnoreCase)); - if (configuredDevice != null) + if (configuredDevice != null && !string.Equals(device.Url, configuredDevice.Url, StringComparison.OrdinalIgnoreCase)) { - if (!string.Equals(device.Url, configuredDevice.Url, StringComparison.OrdinalIgnoreCase)) - { - _logger.LogInformation("Tuner url has changed from {0} to {1}", configuredDevice.Url, device.Url); + _logger.LogInformation("Tuner url has changed from {PreviousUrl} to {NewUrl}", configuredDevice.Url, device.Url); - configuredDevice.Url = device.Url; - await _liveTvManager.SaveTunerHost(configuredDevice).ConfigureAwait(false); - } + configuredDevice.Url = device.Url; + await _liveTvManager.SaveTunerHost(configuredDevice).ConfigureAwait(false); } } } diff --git a/Emby.Server.Implementations/LiveTv/EmbyTV/EncodedRecorder.cs b/Emby.Server.Implementations/LiveTv/EmbyTV/EncodedRecorder.cs index 4ea83b7acd..292f3621d1 100644 --- a/Emby.Server.Implementations/LiveTv/EmbyTV/EncodedRecorder.cs +++ b/Emby.Server.Implementations/LiveTv/EmbyTV/EncodedRecorder.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; @@ -55,14 +55,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV _assemblyInfo = assemblyInfo; } - private bool CopySubtitles - { - get - { - return false; - //return string.Equals(OutputFormat, "mkv", StringComparison.OrdinalIgnoreCase); - } - } + private static bool CopySubtitles => false; public string GetOutputPath(MediaSourceInfo mediaSource, string targetFile) { @@ -214,19 +207,19 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV var outputParam = string.Empty; - var commandLineArgs = string.Format("-i \"{0}\"{5} {2} -map_metadata -1 -threads 0 {3}{4}{6} -y \"{1}\"", - inputTempFile, - targetFile, - videoArgs, - GetAudioArgs(mediaSource), - subtitleArgs, - durationParam, + var commandLineArgs = string.Format("-i \"{0}\"{5} {2} -map_metadata -1 -threads 0 {3}{4}{6} -y \"{1}\"", + inputTempFile, + targetFile, + videoArgs, + GetAudioArgs(mediaSource), + subtitleArgs, + durationParam, outputParam); return inputModifier + " " + commandLineArgs; } - private string GetAudioArgs(MediaSourceInfo mediaSource) + private static string GetAudioArgs(MediaSourceInfo mediaSource) { var mediaStreams = mediaSource.MediaStreams ?? new List(); var inputAudioCodec = mediaStreams.Where(i => i.Type == MediaStreamType.Audio).Select(i => i.Codec).FirstOrDefault() ?? string.Empty; @@ -242,7 +235,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV //return "-codec:a:0 aac -strict experimental -ab 320000"; } - private bool EncodeVideo(MediaSourceInfo mediaSource) + private static bool EncodeVideo(MediaSourceInfo mediaSource) { return false; } @@ -383,6 +376,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV } catch (ObjectDisposedException) { + // TODO Investigate and properly fix. // Don't spam the log. This doesn't seem to throw in windows, but sometimes under linux } catch (Exception ex) diff --git a/Emby.Server.Implementations/LiveTv/EmbyTV/ItemDataProvider.cs b/Emby.Server.Implementations/LiveTv/EmbyTV/ItemDataProvider.cs index 9f179dc2ce..593f98881a 100644 --- a/Emby.Server.Implementations/LiveTv/EmbyTV/ItemDataProvider.cs +++ b/Emby.Server.Implementations/LiveTv/EmbyTV/ItemDataProvider.cs @@ -68,7 +68,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV { if (newList == null) { - throw new ArgumentNullException("newList"); + throw new ArgumentNullException(nameof(newList)); } var file = _dataPath + ".json"; @@ -85,7 +85,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV { if (item == null) { - throw new ArgumentNullException("item"); + throw new ArgumentNullException(nameof(item)); } var list = GetAll().ToList(); @@ -106,7 +106,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV { if (item == null) { - throw new ArgumentNullException("item"); + throw new ArgumentNullException(nameof(item)); } var list = GetAll().ToList(); diff --git a/Emby.Server.Implementations/LiveTv/EmbyTV/TimerManager.cs b/Emby.Server.Implementations/LiveTv/EmbyTV/TimerManager.cs index e4ab347704..bdc6ae0093 100644 --- a/Emby.Server.Implementations/LiveTv/EmbyTV/TimerManager.cs +++ b/Emby.Server.Implementations/LiveTv/EmbyTV/TimerManager.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Concurrent; using System.Globalization; using System.Linq; @@ -90,7 +90,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV AddOrUpdateSystemTimer(item); } - private bool ShouldStartTimer(TimerInfo item) + private static bool ShouldStartTimer(TimerInfo item) { if (item.Status == RecordingStatus.Completed || item.Status == RecordingStatus.Cancelled) diff --git a/Emby.Server.Implementations/LiveTv/Listings/SchedulesDirect.cs b/Emby.Server.Implementations/LiveTv/Listings/SchedulesDirect.cs index e8ffd0caaf..0ba8c8b42b 100644 --- a/Emby.Server.Implementations/LiveTv/Listings/SchedulesDirect.cs +++ b/Emby.Server.Implementations/LiveTv/Listings/SchedulesDirect.cs @@ -1,4 +1,4 @@ -using System.Net; +using System.Net; using MediaBrowser.Common; using MediaBrowser.Common.Net; using MediaBrowser.Controller.LiveTv; @@ -38,12 +38,9 @@ namespace Emby.Server.Implementations.LiveTv.Listings _appHost = appHost; } - private string UserAgent - { - get { return "Emby/" + _appHost.ApplicationVersion; } - } + private string UserAgent => "Emby/" + _appHost.ApplicationVersion; - private List GetScheduleRequestDates(DateTime startDateUtc, DateTime endDateUtc) + private static List GetScheduleRequestDates(DateTime startDateUtc, DateTime endDateUtc) { List dates = new List(); @@ -63,7 +60,7 @@ namespace Emby.Server.Implementations.LiveTv.Listings { if (string.IsNullOrEmpty(channelId)) { - throw new ArgumentNullException("channelId"); + throw new ArgumentNullException(nameof(channelId)); } // Normalize incoming input @@ -189,7 +186,7 @@ namespace Emby.Server.Implementations.LiveTv.Listings } } - private int GetSizeOrder(ScheduleDirect.ImageData image) + private static int GetSizeOrder(ScheduleDirect.ImageData image) { if (!string.IsNullOrWhiteSpace(image.height)) { @@ -202,7 +199,7 @@ namespace Emby.Server.Implementations.LiveTv.Listings return 0; } - private string GetChannelNumber(ScheduleDirect.Map map) + private static string GetChannelNumber(ScheduleDirect.Map map) { var channelNumber = map.logicalChannelNumber; @@ -218,7 +215,7 @@ namespace Emby.Server.Implementations.LiveTv.Listings return channelNumber.TrimStart('0'); } - private bool IsMovie(ScheduleDirect.ProgramDetails programInfo) + private static bool IsMovie(ScheduleDirect.ProgramDetails programInfo) { return string.Equals(programInfo.entityType, "movie", StringComparison.OrdinalIgnoreCase); } @@ -390,7 +387,7 @@ namespace Emby.Server.Implementations.LiveTv.Listings return info; } - private DateTime GetDate(string value) + private static DateTime GetDate(string value) { var date = DateTime.ParseExact(value, "yyyy'-'MM'-'dd'T'HH':'mm':'ss'Z'", CultureInfo.InvariantCulture); @@ -429,7 +426,7 @@ namespace Emby.Server.Implementations.LiveTv.Listings } } - private double GetAspectRatio(ScheduleDirect.ImageData i) + private static double GetAspectRatio(ScheduleDirect.ImageData i) { int width = 0; int height = 0; @@ -664,7 +661,7 @@ namespace Emby.Server.Implementations.LiveTv.Listings } } - options.RequestHeaders["token"] = await GetToken(providerInfo, options.CancellationToken).ConfigureAwait(false);; + options.RequestHeaders["token"] = await GetToken(providerInfo, options.CancellationToken).ConfigureAwait(false); return await Post(options, false, providerInfo).ConfigureAwait(false); } @@ -765,16 +762,10 @@ namespace Emby.Server.Implementations.LiveTv.Listings } } - public string Name - { - get { return "Schedules Direct"; } - } + public string Name => "Schedules Direct"; public static string TypeName = "SchedulesDirect"; - public string Type - { - get { return TypeName; } - } + public string Type => TypeName; private async Task HasLineup(ListingsProviderInfo info, CancellationToken cancellationToken) { @@ -951,7 +942,7 @@ namespace Emby.Server.Implementations.LiveTv.Listings return null; } - private string NormalizeName(string value) + private static string NormalizeName(string value) { return value.Replace(" ", string.Empty).Replace("-", string.Empty); } diff --git a/Emby.Server.Implementations/LiveTv/Listings/XmlTvListingsProvider.cs b/Emby.Server.Implementations/LiveTv/Listings/XmlTvListingsProvider.cs index 4d7c7fef41..2b1ee84a8a 100644 --- a/Emby.Server.Implementations/LiveTv/Listings/XmlTvListingsProvider.cs +++ b/Emby.Server.Implementations/LiveTv/Listings/XmlTvListingsProvider.cs @@ -36,15 +36,9 @@ namespace Jellyfin.Server.Implementations.LiveTv.Listings _zipClient = zipClient; } - public string Name - { - get { return "XmlTV"; } - } + public string Name => "XmlTV"; - public string Type - { - get { return "xmltv"; } - } + public string Type => "xmltv"; private string GetLanguage(ListingsProviderInfo info) { @@ -78,7 +72,7 @@ namespace Jellyfin.Server.Implementations.LiveTv.Listings { CancellationToken = cancellationToken, Url = path, - Progress = new SimpleProgress(), + Progress = new SimpleProgress(), DecompressionMethod = CompressionMethod.Gzip, // It's going to come back gzipped regardless of this value @@ -164,7 +158,7 @@ namespace Jellyfin.Server.Implementations.LiveTv.Listings { if (string.IsNullOrWhiteSpace(channelId)) { - throw new ArgumentNullException("channelId"); + throw new ArgumentNullException(nameof(channelId)); } /* @@ -187,7 +181,7 @@ namespace Jellyfin.Server.Implementations.LiveTv.Listings .Select(p => GetProgramInfo(p, info)); } - private ProgramInfo GetProgramInfo(XmlTvProgram program, ListingsProviderInfo info) + private static ProgramInfo GetProgramInfo(XmlTvProgram program, ListingsProviderInfo info) { string episodeTitle = program.Episode?.Title; @@ -210,9 +204,9 @@ namespace Jellyfin.Server.Implementations.LiveTv.Listings IsMovie = program.Categories.Any(c => info.MovieCategories.Contains(c, StringComparer.OrdinalIgnoreCase)), IsNews = program.Categories.Any(c => info.NewsCategories.Contains(c, StringComparer.OrdinalIgnoreCase)), IsSports = program.Categories.Any(c => info.SportsCategories.Contains(c, StringComparer.OrdinalIgnoreCase)), - ImageUrl = program.Icon != null && !String.IsNullOrEmpty(program.Icon.Source) ? program.Icon.Source : null, - HasImage = program.Icon != null && !String.IsNullOrEmpty(program.Icon.Source), - OfficialRating = program.Rating != null && !String.IsNullOrEmpty(program.Rating.Value) ? program.Rating.Value : null, + ImageUrl = program.Icon != null && !string.IsNullOrEmpty(program.Icon.Source) ? program.Icon.Source : null, + HasImage = program.Icon != null && !string.IsNullOrEmpty(program.Icon.Source), + OfficialRating = program.Rating != null && !string.IsNullOrEmpty(program.Rating.Value) ? program.Rating.Value : null, CommunityRating = program.StarRating, SeriesId = program.Episode == null ? null : program.Title.GetMD5().ToString("N") }; @@ -246,7 +240,7 @@ namespace Jellyfin.Server.Implementations.LiveTv.Listings } // Construct an id from the channel and start date - programInfo.Id = String.Format("{0}_{1:O}", program.ChannelId, program.StartDate); + programInfo.Id = string.Format("{0}_{1:O}", program.ChannelId, program.StartDate); if (programInfo.IsMovie) { @@ -294,7 +288,7 @@ namespace Jellyfin.Server.Implementations.LiveTv.Listings { Id = c.Id, Name = c.DisplayName, - ImageUrl = c.Icon != null && !String.IsNullOrEmpty(c.Icon.Source) ? c.Icon.Source : null, + ImageUrl = c.Icon != null && !string.IsNullOrEmpty(c.Icon.Source) ? c.Icon.Source : null, Number = string.IsNullOrWhiteSpace(c.Number) ? c.Id : c.Number }).ToList(); diff --git a/Emby.Server.Implementations/LiveTv/LiveTvDtoService.cs b/Emby.Server.Implementations/LiveTv/LiveTvDtoService.cs index 6fe5787158..7397d4b60f 100644 --- a/Emby.Server.Implementations/LiveTv/LiveTvDtoService.cs +++ b/Emby.Server.Implementations/LiveTv/LiveTvDtoService.cs @@ -1,4 +1,4 @@ -using MediaBrowser.Common; +using MediaBrowser.Common; using MediaBrowser.Common.Extensions; using MediaBrowser.Controller.Drawing; using MediaBrowser.Controller.Dto; @@ -321,6 +321,7 @@ namespace Emby.Server.Implementations.LiveTv } catch (Exception ex) { + _logger.LogDebug(ex, "GetImageCacheTag raised an exception in LiveTvDtoService.FillImages."); } } @@ -331,10 +332,10 @@ namespace Emby.Server.Implementations.LiveTv { try { - dto.ParentBackdropImageTags = new string[] - { - _imageProcessor.GetImageCacheTag(program, image) - }; + dto.ParentBackdropImageTags = new[] + { + _imageProcessor.GetImageCacheTag(program, image) + }; dto.ParentBackdropItemId = program.Id.ToString("N"); } catch (Exception ex) diff --git a/Emby.Server.Implementations/LiveTv/LiveTvManager.cs b/Emby.Server.Implementations/LiveTv/LiveTvManager.cs index a81a0bcbb7..c360a6a82d 100644 --- a/Emby.Server.Implementations/LiveTv/LiveTvManager.cs +++ b/Emby.Server.Implementations/LiveTv/LiveTvManager.cs @@ -1,4 +1,4 @@ -using MediaBrowser.Common.Configuration; +using MediaBrowser.Common.Configuration; using MediaBrowser.Common.Extensions; using MediaBrowser.Common.Progress; using MediaBrowser.Controller.Configuration; @@ -22,7 +22,6 @@ using System.Linq; using System.Threading; using System.Threading.Tasks; using MediaBrowser.Model.IO; -using MediaBrowser.Common.Security; using MediaBrowser.Controller.Entities.Movies; using MediaBrowser.Controller.Entities.TV; using MediaBrowser.Model.Events; @@ -51,7 +50,6 @@ namespace Emby.Server.Implementations.LiveTv private readonly ITaskManager _taskManager; private readonly IJsonSerializer _jsonSerializer; private readonly IProviderManager _providerManager; - private readonly ISecurityManager _security; private readonly Func _channelManager; private readonly IDtoService _dtoService; @@ -78,7 +76,23 @@ namespace Emby.Server.Implementations.LiveTv private IServerApplicationHost _appHost; private IHttpClient _httpClient; - public LiveTvManager(IServerApplicationHost appHost, IHttpClient httpClient, IServerConfigurationManager config, ILogger logger, IItemRepository itemRepo, IImageProcessor imageProcessor, IUserDataManager userDataManager, IDtoService dtoService, IUserManager userManager, ILibraryManager libraryManager, ITaskManager taskManager, ILocalizationManager localization, IJsonSerializer jsonSerializer, IProviderManager providerManager, IFileSystem fileSystem, ISecurityManager security, Func channelManager) + public LiveTvManager( + IServerApplicationHost appHost, + IHttpClient httpClient, + IServerConfigurationManager config, + ILogger logger, + IItemRepository itemRepo, + IImageProcessor imageProcessor, + IUserDataManager userDataManager, + IDtoService dtoService, + IUserManager userManager, + ILibraryManager libraryManager, + ITaskManager taskManager, + ILocalizationManager localization, + IJsonSerializer jsonSerializer, + IProviderManager providerManager, + IFileSystem fileSystem, + Func channelManager) { _appHost = appHost; _config = config; @@ -91,7 +105,6 @@ namespace Emby.Server.Implementations.LiveTv _jsonSerializer = jsonSerializer; _providerManager = providerManager; _fileSystem = fileSystem; - _security = security; _dtoService = dtoService; _userDataManager = userDataManager; _channelManager = channelManager; @@ -104,10 +117,7 @@ namespace Emby.Server.Implementations.LiveTv /// Gets the services. /// /// The services. - public IReadOnlyList Services - { - get { return _services; } - } + public IReadOnlyList Services => _services; private LiveTvOptions GetConfiguration() { @@ -167,15 +177,9 @@ namespace Emby.Server.Implementations.LiveTv }); } - public ITunerHost[] TunerHosts - { - get { return _tunerHosts; } - } + public ITunerHost[] TunerHosts => _tunerHosts; - public IListingsProvider[] ListingProviders - { - get { return _listingProviders; } - } + public IListingsProvider[] ListingProviders => _listingProviders; public List GetTunerHostTypes() { @@ -323,7 +327,7 @@ namespace Emby.Server.Implementations.LiveTv return _services.FirstOrDefault(i => string.Equals(i.Name, name, StringComparison.OrdinalIgnoreCase)); } - private void Normalize(MediaSourceInfo mediaSource, ILiveTvService service, bool isVideo) + private static void Normalize(MediaSourceInfo mediaSource, ILiveTvService service, bool isVideo) { // Not all of the plugins are setting this mediaSource.IsInfiniteStream = true; @@ -1418,6 +1422,7 @@ namespace Emby.Server.Implementations.LiveTv if (query.IsInProgress ?? false) { + //TODO Fix The co-variant conversion between Video[] and BaseItem[], this can generate runtime issues. result.Items = result .Items .OfType