浏览代码

Merge pull request #2267 from MediaBrowser/dev

Dev
Luke 8 年之前
父节点
当前提交
c53745548a
共有 100 个文件被更改,包括 668 次插入381 次删除
  1. 2 0
      Emby.Common.Implementations/BaseApplicationHost.cs
  2. 17 0
      Emby.Common.Implementations/Cryptography/CryptographyProvider.cs
  3. 17 3
      Emby.Common.Implementations/HttpClientManager/HttpClientManager.cs
  4. 5 1
      Emby.Common.Implementations/Reflection/AssemblyInfo.cs
  5. 2 3
      Emby.Common.Implementations/TextEncoding/TextEncoding.cs
  6. 3 1
      Emby.Common.Implementations/Xml/XmlReaderSettingsFactory.cs
  7. 13 15
      Emby.Common.Implementations/project.json
  8. 4 2
      Emby.Dlna/DlnaManager.cs
  9. 3 0
      Emby.Photos/Emby.Photos.csproj
  10. 1 3
      Emby.Photos/Properties/AssemblyInfo.cs
  11. 1 1
      Emby.Server.Implementations/Activity/ActivityLogEntryPoint.cs
  12. 1 1
      Emby.Server.Implementations/Activity/ActivityManager.cs
  13. 1 1
      Emby.Server.Implementations/Branding/BrandingConfigurationFactory.cs
  14. 1 1
      Emby.Server.Implementations/Channels/ChannelConfigurations.cs
  15. 1 1
      Emby.Server.Implementations/Channels/ChannelDynamicMediaSourceProvider.cs
  16. 1 1
      Emby.Server.Implementations/Channels/ChannelImageProvider.cs
  17. 8 8
      Emby.Server.Implementations/Channels/ChannelManager.cs
  18. 1 1
      Emby.Server.Implementations/Channels/ChannelPostScanTask.cs
  19. 1 1
      Emby.Server.Implementations/Channels/RefreshChannelsScheduledTask.cs
  20. 2 4
      Emby.Server.Implementations/Collections/CollectionImageProvider.cs
  21. 1 3
      Emby.Server.Implementations/Collections/CollectionManager.cs
  22. 1 1
      Emby.Server.Implementations/Devices/DeviceManager.cs
  23. 1 1
      Emby.Server.Implementations/Dto/DtoService.cs
  24. 249 0
      Emby.Server.Implementations/Emby.Server.Implementations.csproj
  25. 7 4
      Emby.Server.Implementations/EntryPoints/AutomaticRestartEntryPoint.cs
  26. 9 6
      Emby.Server.Implementations/EntryPoints/LibraryChangedNotifier.cs
  27. 7 5
      Emby.Server.Implementations/EntryPoints/LoadRegistrations.cs
  28. 5 5
      Emby.Server.Implementations/EntryPoints/RecordingNotifier.cs
  29. 1 1
      Emby.Server.Implementations/EntryPoints/RefreshUsersMetadata.cs
  30. 1 1
      Emby.Server.Implementations/EntryPoints/ServerEventNotifier.cs
  31. 1 1
      Emby.Server.Implementations/EntryPoints/UsageEntryPoint.cs
  32. 1 1
      Emby.Server.Implementations/EntryPoints/UsageReporter.cs
  33. 7 4
      Emby.Server.Implementations/EntryPoints/UserDataChangeNotifier.cs
  34. 15 12
      Emby.Server.Implementations/FileOrganization/EpisodeFileOrganizer.cs
  35. 1 1
      Emby.Server.Implementations/FileOrganization/Extensions.cs
  36. 1 1
      Emby.Server.Implementations/FileOrganization/FileOrganizationNotifier.cs
  37. 1 1
      Emby.Server.Implementations/FileOrganization/FileOrganizationService.cs
  38. 3 18
      Emby.Server.Implementations/FileOrganization/NameUtils.cs
  39. 1 1
      Emby.Server.Implementations/FileOrganization/OrganizerScheduledTask.cs
  40. 2 2
      Emby.Server.Implementations/FileOrganization/TvFolderOrganizer.cs
  41. 4 3
      Emby.Server.Implementations/IO/ThrottledStream.cs
  42. 2 2
      Emby.Server.Implementations/Images/BaseDynamicImageProvider.cs
  43. 1 3
      Emby.Server.Implementations/Intros/DefaultIntroProvider.cs
  44. 1 1
      Emby.Server.Implementations/Library/CoreResolutionIgnoreRule.cs
  45. 27 28
      Emby.Server.Implementations/Library/LibraryManager.cs
  46. 1 1
      Emby.Server.Implementations/Library/LocalTrailerPostScanTask.cs
  47. 7 4
      Emby.Server.Implementations/Library/MediaSourceManager.cs
  48. 1 1
      Emby.Server.Implementations/Library/MusicManager.cs
  49. 1 1
      Emby.Server.Implementations/Library/PathExtensions.cs
  50. 2 2
      Emby.Server.Implementations/Library/ResolverHelper.cs
  51. 4 4
      Emby.Server.Implementations/Library/Resolvers/Audio/AudioResolver.cs
  52. 2 2
      Emby.Server.Implementations/Library/Resolvers/Audio/MusicAlbumResolver.cs
  53. 1 1
      Emby.Server.Implementations/Library/Resolvers/Audio/MusicArtistResolver.cs
  54. 4 4
      Emby.Server.Implementations/Library/Resolvers/BaseVideoResolver.cs
  55. 1 1
      Emby.Server.Implementations/Library/Resolvers/FolderResolver.cs
  56. 1 1
      Emby.Server.Implementations/Library/Resolvers/ItemResolver.cs
  57. 1 1
      Emby.Server.Implementations/Library/Resolvers/Movies/BoxSetResolver.cs
  58. 2 2
      Emby.Server.Implementations/Library/Resolvers/Movies/MovieResolver.cs
  59. 1 1
      Emby.Server.Implementations/Library/Resolvers/PhotoAlbumResolver.cs
  60. 1 1
      Emby.Server.Implementations/Library/Resolvers/PhotoResolver.cs
  61. 1 1
      Emby.Server.Implementations/Library/Resolvers/PlaylistResolver.cs
  62. 1 1
      Emby.Server.Implementations/Library/Resolvers/SpecialFolderResolver.cs
  63. 1 1
      Emby.Server.Implementations/Library/Resolvers/TV/EpisodeResolver.cs
  64. 1 1
      Emby.Server.Implementations/Library/Resolvers/TV/SeasonResolver.cs
  65. 3 3
      Emby.Server.Implementations/Library/Resolvers/TV/SeriesResolver.cs
  66. 1 1
      Emby.Server.Implementations/Library/Resolvers/VideoResolver.cs
  67. 2 7
      Emby.Server.Implementations/Library/SearchEngine.cs
  68. 1 1
      Emby.Server.Implementations/Library/UserDataManager.cs
  69. 31 23
      Emby.Server.Implementations/Library/UserManager.cs
  70. 1 1
      Emby.Server.Implementations/Library/UserViewManager.cs
  71. 1 1
      Emby.Server.Implementations/Library/Validators/ArtistsPostScanTask.cs
  72. 1 1
      Emby.Server.Implementations/Library/Validators/ArtistsValidator.cs
  73. 1 1
      Emby.Server.Implementations/Library/Validators/GameGenresPostScanTask.cs
  74. 1 1
      Emby.Server.Implementations/Library/Validators/GameGenresValidator.cs
  75. 1 1
      Emby.Server.Implementations/Library/Validators/GenresPostScanTask.cs
  76. 1 1
      Emby.Server.Implementations/Library/Validators/GenresValidator.cs
  77. 1 1
      Emby.Server.Implementations/Library/Validators/MusicGenresPostScanTask.cs
  78. 1 1
      Emby.Server.Implementations/Library/Validators/MusicGenresValidator.cs
  79. 1 1
      Emby.Server.Implementations/Library/Validators/PeopleValidator.cs
  80. 1 1
      Emby.Server.Implementations/Library/Validators/StudiosPostScanTask.cs
  81. 1 1
      Emby.Server.Implementations/Library/Validators/StudiosValidator.cs
  82. 1 1
      Emby.Server.Implementations/Library/Validators/YearsPostScanTask.cs
  83. 1 1
      Emby.Server.Implementations/LiveTv/ChannelImageProvider.cs
  84. 1 1
      Emby.Server.Implementations/LiveTv/EmbyTV/DirectRecorder.cs
  85. 50 54
      Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs
  86. 1 1
      Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTVRegistration.cs
  87. 19 20
      Emby.Server.Implementations/LiveTv/EmbyTV/EncodedRecorder.cs
  88. 1 1
      Emby.Server.Implementations/LiveTv/EmbyTV/EntryPoint.cs
  89. 1 1
      Emby.Server.Implementations/LiveTv/EmbyTV/IRecorder.cs
  90. 1 4
      Emby.Server.Implementations/LiveTv/EmbyTV/ItemDataProvider.cs
  91. 1 1
      Emby.Server.Implementations/LiveTv/EmbyTV/RecordingHelper.cs
  92. 1 1
      Emby.Server.Implementations/LiveTv/EmbyTV/SeriesTimerManager.cs
  93. 8 5
      Emby.Server.Implementations/LiveTv/EmbyTV/TimerManager.cs
  94. 5 4
      Emby.Server.Implementations/LiveTv/Listings/SchedulesDirect.cs
  95. 17 14
      Emby.Server.Implementations/LiveTv/Listings/XmlTvListingsProvider.cs
  96. 3 3
      Emby.Server.Implementations/LiveTv/LiveStreamHelper.cs
  97. 1 1
      Emby.Server.Implementations/LiveTv/LiveTvConfigurationFactory.cs
  98. 1 1
      Emby.Server.Implementations/LiveTv/LiveTvDtoService.cs
  99. 33 32
      Emby.Server.Implementations/LiveTv/LiveTvManager.cs
  100. 3 3
      Emby.Server.Implementations/LiveTv/LiveTvMediaSourceProvider.cs

+ 2 - 0
Emby.Common.Implementations/BaseApplicationHost.cs

@@ -549,6 +549,8 @@ return null;
             TimerFactory = new TimerFactory();
             TimerFactory = new TimerFactory();
             RegisterSingleInstance(TimerFactory);
             RegisterSingleInstance(TimerFactory);
 
 
+            RegisterSingleInstance(CryptographyProvider);
+
             return Task.FromResult(true);
             return Task.FromResult(true);
         }
         }
 
 

+ 17 - 0
Emby.Common.Implementations/Cryptography/CryptographyProvider.cs

@@ -19,6 +19,15 @@ namespace Emby.Common.Implementations.Cryptography
                 return provider.ComputeHash(Encoding.Unicode.GetBytes(str));
                 return provider.ComputeHash(Encoding.Unicode.GetBytes(str));
             }
             }
         }
         }
+
+        public byte[] GetSHA1Bytes(byte[] bytes)
+        {
+            using (var provider = SHA1.Create())
+            {
+                return provider.ComputeHash(bytes);
+            }
+        }
+
         public byte[] GetMD5Bytes(Stream str)
         public byte[] GetMD5Bytes(Stream str)
         {
         {
             using (var provider = MD5.Create())
             using (var provider = MD5.Create())
@@ -26,5 +35,13 @@ namespace Emby.Common.Implementations.Cryptography
                 return provider.ComputeHash(str);
                 return provider.ComputeHash(str);
             }
             }
         }
         }
+
+        public byte[] GetMD5Bytes(byte[] bytes)
+        {
+            using (var provider = MD5.Create())
+            {
+                return provider.ComputeHash(bytes);
+            }
+        }
     }
     }
 }
 }

+ 17 - 3
Emby.Common.Implementations/HttpClientManager/HttpClientManager.cs

@@ -169,9 +169,23 @@ namespace Emby.Common.Implementations.HttpClientManager
                 AddRequestHeaders(httpWebRequest, options);
                 AddRequestHeaders(httpWebRequest, options);
 
 
 #if NET46
 #if NET46
-                httpWebRequest.AutomaticDecompression = options.EnableHttpCompression ?
-                    (options.DecompressionMethod ?? DecompressionMethods.Deflate) :
-                    DecompressionMethods.None;
+                if (options.EnableHttpCompression)
+                {
+                    if (options.DecompressionMethod.HasValue)
+                    {
+                        httpWebRequest.AutomaticDecompression = options.DecompressionMethod.Value == CompressionMethod.Gzip
+                            ? DecompressionMethods.GZip
+                            : DecompressionMethods.Deflate;
+                    }
+                    else
+                    {
+                        httpWebRequest.AutomaticDecompression = DecompressionMethods.Deflate;
+                    }
+                }
+                else
+                {
+                    httpWebRequest.AutomaticDecompression = DecompressionMethods.None;
+                }
 #endif    
 #endif    
             }
             }
 
 

+ 5 - 1
MediaBrowser.Server.Implementations/Reflection/AssemblyInfo.cs → Emby.Common.Implementations/Reflection/AssemblyInfo.cs

@@ -1,14 +1,18 @@
 using System;
 using System;
 using System.IO;
 using System.IO;
 using MediaBrowser.Model.Reflection;
 using MediaBrowser.Model.Reflection;
+using System.Reflection;
 
 
-namespace MediaBrowser.Server.Implementations.Reflection
+namespace Emby.Common.Implementations.Reflection
 {
 {
     public class AssemblyInfo : IAssemblyInfo
     public class AssemblyInfo : IAssemblyInfo
     {
     {
         public Stream GetManifestResourceStream(Type type, string resource)
         public Stream GetManifestResourceStream(Type type, string resource)
         {
         {
+#if NET46
             return type.Assembly.GetManifestResourceStream(resource);
             return type.Assembly.GetManifestResourceStream(resource);
+#endif
+            return type.GetTypeInfo().Assembly.GetManifestResourceStream(resource);
         }
         }
     }
     }
 }
 }

+ 2 - 3
MediaBrowser.Server.Implementations/TextEncoding/TextEncoding.cs → Emby.Common.Implementations/TextEncoding/TextEncoding.cs

@@ -2,7 +2,7 @@
 using MediaBrowser.Model.IO;
 using MediaBrowser.Model.IO;
 using MediaBrowser.Model.TextEncoding;
 using MediaBrowser.Model.TextEncoding;
 
 
-namespace MediaBrowser.Server.Implementations.TextEncoding
+namespace Emby.Common.Implementations.TextEncoding
 {
 {
     public class TextEncoding : IEncoding
     public class TextEncoding : IEncoding
     {
     {
@@ -42,8 +42,7 @@ namespace MediaBrowser.Server.Implementations.TextEncoding
             if (buffer[0] == 0x2b && buffer[1] == 0x2f && buffer[2] == 0x76)
             if (buffer[0] == 0x2b && buffer[1] == 0x2f && buffer[2] == 0x76)
                 return Encoding.UTF7;
                 return Encoding.UTF7;
 
 
-            // It's ok - anything aside from utf is ok since that's what we're looking for
-            return Encoding.Default;
+            return null;
         }
         }
     }
     }
 }
 }

+ 3 - 1
MediaBrowser.Server.Implementations/Xml/XmlReaderSettingsFactory.cs → Emby.Common.Implementations/Xml/XmlReaderSettingsFactory.cs

@@ -1,7 +1,7 @@
 using System.Xml;
 using System.Xml;
 using MediaBrowser.Model.Xml;
 using MediaBrowser.Model.Xml;
 
 
-namespace MediaBrowser.Server.Implementations.Xml
+namespace Emby.Common.Implementations.Xml
 {
 {
     public class XmlReaderSettingsFactory : IXmlReaderSettingsFactory
     public class XmlReaderSettingsFactory : IXmlReaderSettingsFactory
     {
     {
@@ -11,7 +11,9 @@ namespace MediaBrowser.Server.Implementations.Xml
 
 
             if (!enableValidation)
             if (!enableValidation)
             {
             {
+#if NET46
                 settings.ValidationType = ValidationType.None;
                 settings.ValidationType = ValidationType.None;
+#endif
             }
             }
 
 
             return settings;
             return settings;

+ 13 - 15
Emby.Common.Implementations/project.json

@@ -23,27 +23,20 @@
         "System.Xml.Serialization": "4.0.0.0"
         "System.Xml.Serialization": "4.0.0.0"
       },
       },
       "dependencies": {
       "dependencies": {
-        "MediaBrowser.Common": {
-          "target": "project"
-        },
+        "SimpleInjector": "3.2.4",
+        "NLog": "4.4.0-betaV15",
         "MediaBrowser.Model": {
         "MediaBrowser.Model": {
           "target": "project"
           "target": "project"
         },
         },
-		"SimpleInjector": "3.2.4",
-		"NLog": "4.4.0-betaV15"
-      }
+        "MediaBrowser.Common": {
+          "target": "project"
+        }      }
     },
     },
     "netstandard1.6": {
     "netstandard1.6": {
       "imports": "dnxcore50",
       "imports": "dnxcore50",
       "dependencies": {
       "dependencies": {
         "NETStandard.Library": "1.6.0",
         "NETStandard.Library": "1.6.0",
-		"MediaBrowser.Common": {
-          "target": "project"
-        },
-        "MediaBrowser.Model": {
-          "target": "project"
-        },
-        "System.IO.FileSystem.DriveInfo": "4.0.0",
+		"System.IO.FileSystem.DriveInfo": "4.0.0",
 		"System.Diagnostics.Process": "4.1.0",
 		"System.Diagnostics.Process": "4.1.0",
 		"System.Threading.Timer": "4.0.1",
 		"System.Threading.Timer": "4.0.1",
 		"System.Net.Requests": "4.0.11",
 		"System.Net.Requests": "4.0.11",
@@ -58,8 +51,13 @@
 		"System.Reflection.Primitives": "4.0.1",
 		"System.Reflection.Primitives": "4.0.1",
 		"System.Runtime.Loader": "4.0.0",
 		"System.Runtime.Loader": "4.0.0",
 		"SimpleInjector": "3.2.4",
 		"SimpleInjector": "3.2.4",
-		"NLog": "4.4.0-betaV15"
-      }
+        "NLog": "4.4.0-betaV15",
+        "MediaBrowser.Model": {
+          "target": "project"
+        },
+        "MediaBrowser.Common": {
+          "target": "project"
+        }      }
     }
     }
   }
   }
 }
 }

+ 4 - 2
Emby.Dlna/DlnaManager.cs

@@ -560,17 +560,19 @@ namespace Emby.Dlna
                 ? ImageFormat.Png
                 ? ImageFormat.Png
                 : ImageFormat.Jpg;
                 : ImageFormat.Jpg;
 
 
+            var resource = GetType().Namespace + ".Images." + filename.ToLower();
+
 #if NET46
 #if NET46
             return new ImageStream
             return new ImageStream
             {
             {
                 Format = format,
                 Format = format,
-                Stream = GetType().Assembly.GetManifestResourceStream("MediaBrowser.Dlna.Images." + filename.ToLower())
+                Stream = GetType().Assembly.GetManifestResourceStream(resource)
             };
             };
 #elif NETSTANDARD1_6
 #elif NETSTANDARD1_6
             return new ImageStream
             return new ImageStream
             {
             {
                 Format = format,
                 Format = format,
-                Stream = GetType().GetTypeInfo().Assembly.GetManifestResourceStream("MediaBrowser.Dlna.Images." + filename.ToLower())
+                Stream = GetType().GetTypeInfo().Assembly.GetManifestResourceStream(resource)
             };
             };
 #endif
 #endif
             throw new NotImplementedException();
             throw new NotImplementedException();

+ 3 - 0
Emby.Photos/Emby.Photos.csproj

@@ -37,6 +37,9 @@
     </Reference>
     </Reference>
   </ItemGroup>
   </ItemGroup>
   <ItemGroup>
   <ItemGroup>
+    <Compile Include="..\SharedVersion.cs">
+      <Link>Properties\SharedVersion.cs</Link>
+    </Compile>
     <Compile Include="PhotoProvider.cs" />
     <Compile Include="PhotoProvider.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
   </ItemGroup>
   </ItemGroup>

+ 1 - 3
Emby.Photos/Properties/AssemblyInfo.cs

@@ -31,6 +31,4 @@ using System.Runtime.InteropServices;
 //
 //
 // 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:
 // by using the '*' as shown below:
-// [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("1.0.0.0")]
-[assembly: AssemblyFileVersion("1.0.0.0")]
+// [assembly: AssemblyVersion("1.0.*")]

+ 1 - 1
MediaBrowser.Server.Implementations/EntryPoints/ActivityLogEntryPoint.cs → Emby.Server.Implementations/Activity/ActivityLogEntryPoint.cs

@@ -19,7 +19,7 @@ using System.Linq;
 using System.Text;
 using System.Text;
 using MediaBrowser.Model.Globalization;
 using MediaBrowser.Model.Globalization;
 
 
-namespace MediaBrowser.Server.Implementations.EntryPoints
+namespace Emby.Server.Implementations.Activity
 {
 {
     public class ActivityLogEntryPoint : IServerEntryPoint
     public class ActivityLogEntryPoint : IServerEntryPoint
     {
     {

+ 1 - 1
MediaBrowser.Server.Implementations/Activity/ActivityManager.cs → Emby.Server.Implementations/Activity/ActivityManager.cs

@@ -8,7 +8,7 @@ using System;
 using System.Linq;
 using System.Linq;
 using System.Threading.Tasks;
 using System.Threading.Tasks;
 
 
-namespace MediaBrowser.Server.Implementations.Activity
+namespace Emby.Server.Implementations.Activity
 {
 {
     public class ActivityManager : IActivityManager
     public class ActivityManager : IActivityManager
     {
     {

+ 1 - 1
MediaBrowser.Server.Implementations/Branding/BrandingConfigurationFactory.cs → Emby.Server.Implementations/Branding/BrandingConfigurationFactory.cs

@@ -2,7 +2,7 @@
 using MediaBrowser.Model.Branding;
 using MediaBrowser.Model.Branding;
 using System.Collections.Generic;
 using System.Collections.Generic;
 
 
-namespace MediaBrowser.Server.Implementations.Branding
+namespace Emby.Server.Implementations.Branding
 {
 {
     public class BrandingConfigurationFactory : IConfigurationFactory
     public class BrandingConfigurationFactory : IConfigurationFactory
     {
     {

+ 1 - 1
MediaBrowser.Server.Implementations/Channels/ChannelConfigurations.cs → Emby.Server.Implementations/Channels/ChannelConfigurations.cs

@@ -2,7 +2,7 @@
 using MediaBrowser.Model.Configuration;
 using MediaBrowser.Model.Configuration;
 using System.Collections.Generic;
 using System.Collections.Generic;
 
 
-namespace MediaBrowser.Server.Implementations.Channels
+namespace Emby.Server.Implementations.Channels
 {
 {
     public static class ChannelConfigurationExtension
     public static class ChannelConfigurationExtension
     {
     {

+ 1 - 1
MediaBrowser.Server.Implementations/Channels/ChannelDynamicMediaSourceProvider.cs → Emby.Server.Implementations/Channels/ChannelDynamicMediaSourceProvider.cs

@@ -7,7 +7,7 @@ using System.Collections.Generic;
 using System.Threading;
 using System.Threading;
 using System.Threading.Tasks;
 using System.Threading.Tasks;
 
 
-namespace MediaBrowser.Server.Implementations.Channels
+namespace Emby.Server.Implementations.Channels
 {
 {
     public class ChannelDynamicMediaSourceProvider : IMediaSourceProvider
     public class ChannelDynamicMediaSourceProvider : IMediaSourceProvider
     {
     {

+ 1 - 1
MediaBrowser.Server.Implementations/Channels/ChannelImageProvider.cs → Emby.Server.Implementations/Channels/ChannelImageProvider.cs

@@ -7,7 +7,7 @@ using System.Linq;
 using System.Threading;
 using System.Threading;
 using System.Threading.Tasks;
 using System.Threading.Tasks;
 
 
-namespace MediaBrowser.Server.Implementations.Channels
+namespace Emby.Server.Implementations.Channels
 {
 {
     public class ChannelImageProvider : IDynamicImageProvider, IHasItemChangeMonitor
     public class ChannelImageProvider : IDynamicImageProvider, IHasItemChangeMonitor
     {
     {

+ 8 - 8
MediaBrowser.Server.Implementations/Channels/ChannelManager.cs → Emby.Server.Implementations/Channels/ChannelManager.cs

@@ -31,7 +31,7 @@ using MediaBrowser.Controller.Entities.TV;
 using MediaBrowser.Controller.IO;
 using MediaBrowser.Controller.IO;
 using MediaBrowser.Model.Globalization;
 using MediaBrowser.Model.Globalization;
 
 
-namespace MediaBrowser.Server.Implementations.Channels
+namespace Emby.Server.Implementations.Channels
 {
 {
     public class ChannelManager : IChannelManager
     public class ChannelManager : IChannelManager
     {
     {
@@ -410,7 +410,7 @@ namespace MediaBrowser.Server.Implementations.Channels
                     }
                     }
                 }
                 }
             }
             }
-            catch (DirectoryNotFoundException)
+            catch (IOException)
             {
             {
 
 
             }
             }
@@ -781,7 +781,7 @@ namespace MediaBrowser.Server.Implementations.Channels
             {
             {
 
 
             }
             }
-            catch (DirectoryNotFoundException)
+            catch (IOException)
             {
             {
 
 
             }
             }
@@ -801,7 +801,7 @@ namespace MediaBrowser.Server.Implementations.Channels
                 {
                 {
 
 
                 }
                 }
-                catch (DirectoryNotFoundException)
+                catch (IOException)
                 {
                 {
 
 
                 }
                 }
@@ -943,7 +943,7 @@ namespace MediaBrowser.Server.Implementations.Channels
             {
             {
 
 
             }
             }
-            catch (DirectoryNotFoundException)
+            catch (IOException)
             {
             {
 
 
             }
             }
@@ -963,7 +963,7 @@ namespace MediaBrowser.Server.Implementations.Channels
                 {
                 {
 
 
                 }
                 }
-                catch (DirectoryNotFoundException)
+                catch (IOException)
                 {
                 {
 
 
                 }
                 }
@@ -1104,7 +1104,7 @@ namespace MediaBrowser.Server.Implementations.Channels
             {
             {
 
 
             }
             }
-            catch (DirectoryNotFoundException)
+            catch (IOException)
             {
             {
 
 
             }
             }
@@ -1127,7 +1127,7 @@ namespace MediaBrowser.Server.Implementations.Channels
                 {
                 {
 
 
                 }
                 }
-                catch (DirectoryNotFoundException)
+                catch (IOException)
                 {
                 {
 
 
                 }
                 }

+ 1 - 1
MediaBrowser.Server.Implementations/Channels/ChannelPostScanTask.cs → Emby.Server.Implementations/Channels/ChannelPostScanTask.cs

@@ -11,7 +11,7 @@ using System.Threading;
 using System.Threading.Tasks;
 using System.Threading.Tasks;
 using MediaBrowser.Model.Extensions;
 using MediaBrowser.Model.Extensions;
 
 
-namespace MediaBrowser.Server.Implementations.Channels
+namespace Emby.Server.Implementations.Channels
 {
 {
     public class ChannelPostScanTask
     public class ChannelPostScanTask
     {
     {

+ 1 - 1
MediaBrowser.Server.Implementations/Channels/RefreshChannelsScheduledTask.cs → Emby.Server.Implementations/Channels/RefreshChannelsScheduledTask.cs

@@ -6,7 +6,7 @@ using System.Collections.Generic;
 using System.Threading.Tasks;
 using System.Threading.Tasks;
 using MediaBrowser.Model.Tasks;
 using MediaBrowser.Model.Tasks;
 
 
-namespace MediaBrowser.Server.Implementations.Channels
+namespace Emby.Server.Implementations.Channels
 {
 {
     class RefreshChannelsScheduledTask : IScheduledTask
     class RefreshChannelsScheduledTask : IScheduledTask
     {
     {

+ 2 - 4
MediaBrowser.Server.Implementations/Collections/CollectionImageProvider.cs → Emby.Server.Implementations/Collections/CollectionImageProvider.cs

@@ -6,16 +6,14 @@ using MediaBrowser.Controller.Entities.Movies;
 using MediaBrowser.Controller.Entities.TV;
 using MediaBrowser.Controller.Entities.TV;
 using MediaBrowser.Controller.Providers;
 using MediaBrowser.Controller.Providers;
 using MediaBrowser.Model.Entities;
 using MediaBrowser.Model.Entities;
-using MediaBrowser.Server.Implementations.Photos;
 using System.Collections.Generic;
 using System.Collections.Generic;
 using System.Linq;
 using System.Linq;
 using System.Threading.Tasks;
 using System.Threading.Tasks;
-using MediaBrowser.Common.IO;
-using MediaBrowser.Controller.IO;
+using Emby.Server.Implementations.Images;
 using MediaBrowser.Model.IO;
 using MediaBrowser.Model.IO;
 using MediaBrowser.Model.Extensions;
 using MediaBrowser.Model.Extensions;
 
 
-namespace MediaBrowser.Server.Implementations.Collections
+namespace Emby.Server.Implementations.Collections
 {
 {
     public class CollectionImageProvider : BaseDynamicImageProvider<BoxSet>
     public class CollectionImageProvider : BaseDynamicImageProvider<BoxSet>
     {
     {

+ 1 - 3
MediaBrowser.Server.Implementations/Collections/CollectionManager.cs → Emby.Server.Implementations/Collections/CollectionManager.cs

@@ -11,11 +11,9 @@ using System.IO;
 using System.Linq;
 using System.Linq;
 using System.Threading;
 using System.Threading;
 using System.Threading.Tasks;
 using System.Threading.Tasks;
-using MediaBrowser.Common.IO;
-using MediaBrowser.Controller.IO;
 using MediaBrowser.Model.IO;
 using MediaBrowser.Model.IO;
 
 
-namespace MediaBrowser.Server.Implementations.Collections
+namespace Emby.Server.Implementations.Collections
 {
 {
     public class CollectionManager : ICollectionManager
     public class CollectionManager : ICollectionManager
     {
     {

+ 1 - 1
MediaBrowser.Server.Implementations/Devices/DeviceManager.cs → Emby.Server.Implementations/Devices/DeviceManager.cs

@@ -21,7 +21,7 @@ using MediaBrowser.Model.IO;
 using MediaBrowser.Controller.Configuration;
 using MediaBrowser.Controller.Configuration;
 using MediaBrowser.Controller.IO;
 using MediaBrowser.Controller.IO;
 
 
-namespace MediaBrowser.Server.Implementations.Devices
+namespace Emby.Server.Implementations.Devices
 {
 {
     public class DeviceManager : IDeviceManager
     public class DeviceManager : IDeviceManager
     {
     {

+ 1 - 1
MediaBrowser.Server.Implementations/Dto/DtoService.cs → Emby.Server.Implementations/Dto/DtoService.cs

@@ -29,7 +29,7 @@ using MediaBrowser.Controller.IO;
 using MediaBrowser.Model.IO;
 using MediaBrowser.Model.IO;
 using MediaBrowser.Model.Extensions;
 using MediaBrowser.Model.Extensions;
 
 
-namespace MediaBrowser.Server.Implementations.Dto
+namespace Emby.Server.Implementations.Dto
 {
 {
     public class DtoService : IDtoService
     public class DtoService : IDtoService
     {
     {

+ 249 - 0
Emby.Server.Implementations/Emby.Server.Implementations.csproj

@@ -0,0 +1,249 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+  <PropertyGroup>
+    <MinimumVisualStudioVersion>11.0</MinimumVisualStudioVersion>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProjectGuid>{E383961B-9356-4D5D-8233-9A1079D03055}</ProjectGuid>
+    <OutputType>Library</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <RootNamespace>Emby.Server.Implementations</RootNamespace>
+    <AssemblyName>Emby.Server.Implementations</AssemblyName>
+    <DefaultLanguage>en-US</DefaultLanguage>
+    <FileAlignment>512</FileAlignment>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <TargetFrameworkProfile>Profile7</TargetFrameworkProfile>
+    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>bin\Debug\</OutputPath>
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+    <DebugType>pdbonly</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>bin\Release\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <ItemGroup>
+    <!-- A reference to the entire .NET Framework is automatically included -->
+    <None Include="project.json" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="Activity\ActivityLogEntryPoint.cs" />
+    <Compile Include="Activity\ActivityManager.cs" />
+    <Compile Include="Branding\BrandingConfigurationFactory.cs" />
+    <Compile Include="Channels\ChannelConfigurations.cs" />
+    <Compile Include="Channels\ChannelDynamicMediaSourceProvider.cs" />
+    <Compile Include="Channels\ChannelImageProvider.cs" />
+    <Compile Include="Channels\ChannelManager.cs" />
+    <Compile Include="Channels\ChannelPostScanTask.cs" />
+    <Compile Include="Channels\RefreshChannelsScheduledTask.cs" />
+    <Compile Include="Collections\CollectionImageProvider.cs" />
+    <Compile Include="Collections\CollectionManager.cs" />
+    <Compile Include="Devices\DeviceManager.cs" />
+    <Compile Include="Dto\DtoService.cs" />
+    <Compile Include="EntryPoints\AutomaticRestartEntryPoint.cs" />
+    <Compile Include="EntryPoints\LibraryChangedNotifier.cs" />
+    <Compile Include="EntryPoints\LoadRegistrations.cs" />
+    <Compile Include="EntryPoints\RecordingNotifier.cs" />
+    <Compile Include="EntryPoints\RefreshUsersMetadata.cs" />
+    <Compile Include="EntryPoints\ServerEventNotifier.cs" />
+    <Compile Include="EntryPoints\UsageEntryPoint.cs" />
+    <Compile Include="EntryPoints\UsageReporter.cs" />
+    <Compile Include="EntryPoints\UserDataChangeNotifier.cs" />
+    <Compile Include="FileOrganization\EpisodeFileOrganizer.cs" />
+    <Compile Include="FileOrganization\Extensions.cs" />
+    <Compile Include="FileOrganization\FileOrganizationNotifier.cs" />
+    <Compile Include="FileOrganization\FileOrganizationService.cs" />
+    <Compile Include="FileOrganization\NameUtils.cs" />
+    <Compile Include="FileOrganization\OrganizerScheduledTask.cs" />
+    <Compile Include="FileOrganization\TvFolderOrganizer.cs" />
+    <Compile Include="Images\BaseDynamicImageProvider.cs" />
+    <Compile Include="Intros\DefaultIntroProvider.cs" />
+    <Compile Include="IO\ThrottledStream.cs" />
+    <Compile Include="Library\CoreResolutionIgnoreRule.cs" />
+    <Compile Include="Library\LibraryManager.cs" />
+    <Compile Include="Library\LocalTrailerPostScanTask.cs" />
+    <Compile Include="Library\MediaSourceManager.cs" />
+    <Compile Include="Library\MusicManager.cs" />
+    <Compile Include="Library\PathExtensions.cs" />
+    <Compile Include="Library\ResolverHelper.cs" />
+    <Compile Include="Library\Resolvers\Audio\AudioResolver.cs" />
+    <Compile Include="Library\Resolvers\Audio\MusicAlbumResolver.cs" />
+    <Compile Include="Library\Resolvers\Audio\MusicArtistResolver.cs" />
+    <Compile Include="Library\Resolvers\BaseVideoResolver.cs" />
+    <Compile Include="Library\Resolvers\FolderResolver.cs" />
+    <Compile Include="Library\Resolvers\ItemResolver.cs" />
+    <Compile Include="Library\Resolvers\Movies\BoxSetResolver.cs" />
+    <Compile Include="Library\Resolvers\Movies\MovieResolver.cs" />
+    <Compile Include="Library\Resolvers\PhotoAlbumResolver.cs" />
+    <Compile Include="Library\Resolvers\PhotoResolver.cs" />
+    <Compile Include="Library\Resolvers\PlaylistResolver.cs" />
+    <Compile Include="Library\Resolvers\SpecialFolderResolver.cs" />
+    <Compile Include="Library\Resolvers\TV\EpisodeResolver.cs" />
+    <Compile Include="Library\Resolvers\TV\SeasonResolver.cs" />
+    <Compile Include="Library\Resolvers\TV\SeriesResolver.cs" />
+    <Compile Include="Library\Resolvers\VideoResolver.cs" />
+    <Compile Include="Library\SearchEngine.cs" />
+    <Compile Include="Library\UserDataManager.cs" />
+    <Compile Include="Library\UserManager.cs" />
+    <Compile Include="Library\UserViewManager.cs" />
+    <Compile Include="Library\Validators\ArtistsPostScanTask.cs" />
+    <Compile Include="Library\Validators\ArtistsValidator.cs" />
+    <Compile Include="Library\Validators\GameGenresPostScanTask.cs" />
+    <Compile Include="Library\Validators\GameGenresValidator.cs" />
+    <Compile Include="Library\Validators\GenresPostScanTask.cs" />
+    <Compile Include="Library\Validators\GenresValidator.cs" />
+    <Compile Include="Library\Validators\MusicGenresPostScanTask.cs" />
+    <Compile Include="Library\Validators\MusicGenresValidator.cs" />
+    <Compile Include="Library\Validators\PeopleValidator.cs" />
+    <Compile Include="Library\Validators\StudiosPostScanTask.cs" />
+    <Compile Include="Library\Validators\StudiosValidator.cs" />
+    <Compile Include="Library\Validators\YearsPostScanTask.cs" />
+    <Compile Include="LiveTv\ChannelImageProvider.cs" />
+    <Compile Include="LiveTv\EmbyTV\DirectRecorder.cs" />
+    <Compile Include="LiveTv\EmbyTV\EmbyTV.cs" />
+    <Compile Include="LiveTv\EmbyTV\EmbyTVRegistration.cs" />
+    <Compile Include="LiveTv\EmbyTV\EncodedRecorder.cs" />
+    <Compile Include="LiveTv\EmbyTV\EntryPoint.cs" />
+    <Compile Include="LiveTv\EmbyTV\IRecorder.cs" />
+    <Compile Include="LiveTv\EmbyTV\ItemDataProvider.cs" />
+    <Compile Include="LiveTv\EmbyTV\RecordingHelper.cs" />
+    <Compile Include="LiveTv\EmbyTV\SeriesTimerManager.cs" />
+    <Compile Include="LiveTv\EmbyTV\TimerManager.cs" />
+    <Compile Include="LiveTv\Listings\SchedulesDirect.cs" />
+    <Compile Include="LiveTv\Listings\XmlTvListingsProvider.cs" />
+    <Compile Include="LiveTv\LiveStreamHelper.cs" />
+    <Compile Include="LiveTv\LiveTvConfigurationFactory.cs" />
+    <Compile Include="LiveTv\LiveTvDtoService.cs" />
+    <Compile Include="LiveTv\LiveTvManager.cs" />
+    <Compile Include="LiveTv\LiveTvMediaSourceProvider.cs" />
+    <Compile Include="LiveTv\ProgramImageProvider.cs" />
+    <Compile Include="LiveTv\RecordingImageProvider.cs" />
+    <Compile Include="LiveTv\RefreshChannelsScheduledTask.cs" />
+    <Compile Include="LiveTv\TunerHosts\BaseTunerHost.cs" />
+    <Compile Include="LiveTv\TunerHosts\HdHomerun\HdHomerunDiscovery.cs" />
+    <Compile Include="LiveTv\TunerHosts\HdHomerun\HdHomerunHost.cs" />
+    <Compile Include="LiveTv\TunerHosts\HdHomerun\HdHomerunLiveStream.cs" />
+    <Compile Include="LiveTv\TunerHosts\M3uParser.cs" />
+    <Compile Include="LiveTv\TunerHosts\M3UTunerHost.cs" />
+    <Compile Include="LiveTv\TunerHosts\MulticastStream.cs" />
+    <Compile Include="LiveTv\TunerHosts\QueueStream.cs" />
+    <Compile Include="Logging\PatternsLogger.cs" />
+    <Compile Include="MediaEncoder\EncodingManager.cs" />
+    <Compile Include="News\NewsEntryPoint.cs" />
+    <Compile Include="News\NewsService.cs" />
+    <Compile Include="Notifications\CoreNotificationTypes.cs" />
+    <Compile Include="Notifications\IConfigurableNotificationService.cs" />
+    <Compile Include="Notifications\InternalNotificationService.cs" />
+    <Compile Include="Notifications\NotificationConfigurationFactory.cs" />
+    <Compile Include="Notifications\NotificationManager.cs" />
+    <Compile Include="Notifications\Notifications.cs" />
+    <Compile Include="Notifications\WebSocketNotifier.cs" />
+    <Compile Include="Persistence\CleanDatabaseScheduledTask.cs" />
+    <Compile Include="Photos\PhotoAlbumImageProvider.cs" />
+    <Compile Include="Playlists\PlaylistImageProvider.cs" />
+    <Compile Include="Playlists\PlaylistManager.cs" />
+    <Compile Include="Properties\AssemblyInfo.cs" />
+    <Compile Include="ScheduledTasks\ChapterImagesTask.cs" />
+    <Compile Include="ScheduledTasks\PeopleValidationTask.cs" />
+    <Compile Include="ScheduledTasks\PluginUpdateTask.cs" />
+    <Compile Include="ScheduledTasks\RefreshIntrosTask.cs" />
+    <Compile Include="ScheduledTasks\RefreshMediaLibraryTask.cs" />
+    <Compile Include="ScheduledTasks\SystemUpdateTask.cs" />
+    <Compile Include="ServerManager\ServerManager.cs" />
+    <Compile Include="ServerManager\WebSocketConnection.cs" />
+    <Compile Include="Session\HttpSessionController.cs" />
+    <Compile Include="Session\SessionManager.cs" />
+    <Compile Include="Session\SessionWebSocketListener.cs" />
+    <Compile Include="Session\WebSocketController.cs" />
+    <Compile Include="Sorting\AiredEpisodeOrderComparer.cs" />
+    <Compile Include="Sorting\AirTimeComparer.cs" />
+    <Compile Include="Sorting\AlbumArtistComparer.cs" />
+    <Compile Include="Sorting\AlbumComparer.cs" />
+    <Compile Include="Sorting\AlphanumComparator.cs" />
+    <Compile Include="Sorting\ArtistComparer.cs" />
+    <Compile Include="Sorting\BudgetComparer.cs" />
+    <Compile Include="Sorting\CommunityRatingComparer.cs" />
+    <Compile Include="Sorting\CriticRatingComparer.cs" />
+    <Compile Include="Sorting\DateCreatedComparer.cs" />
+    <Compile Include="Sorting\DateLastMediaAddedComparer.cs" />
+    <Compile Include="Sorting\DatePlayedComparer.cs" />
+    <Compile Include="Sorting\GameSystemComparer.cs" />
+    <Compile Include="Sorting\IsFavoriteOrLikeComparer.cs" />
+    <Compile Include="Sorting\IsFolderComparer.cs" />
+    <Compile Include="Sorting\IsPlayedComparer.cs" />
+    <Compile Include="Sorting\IsUnplayedComparer.cs" />
+    <Compile Include="Sorting\MetascoreComparer.cs" />
+    <Compile Include="Sorting\NameComparer.cs" />
+    <Compile Include="Sorting\OfficialRatingComparer.cs" />
+    <Compile Include="Sorting\PlayCountComparer.cs" />
+    <Compile Include="Sorting\PlayersComparer.cs" />
+    <Compile Include="Sorting\PremiereDateComparer.cs" />
+    <Compile Include="Sorting\ProductionYearComparer.cs" />
+    <Compile Include="Sorting\RandomComparer.cs" />
+    <Compile Include="Sorting\RevenueComparer.cs" />
+    <Compile Include="Sorting\RuntimeComparer.cs" />
+    <Compile Include="Sorting\SeriesSortNameComparer.cs" />
+    <Compile Include="Sorting\SortNameComparer.cs" />
+    <Compile Include="Sorting\StartDateComparer.cs" />
+    <Compile Include="Sorting\StudioComparer.cs" />
+    <Compile Include="Sync\AppSyncProvider.cs" />
+    <Compile Include="Sync\CloudSyncProfile.cs" />
+    <Compile Include="Sync\IHasSyncQuality.cs" />
+    <Compile Include="Sync\MediaSync.cs" />
+    <Compile Include="Sync\MultiProviderSync.cs" />
+    <Compile Include="Sync\ServerSyncScheduledTask.cs" />
+    <Compile Include="Sync\SyncConfig.cs" />
+    <Compile Include="Sync\SyncConvertScheduledTask.cs" />
+    <Compile Include="Sync\SyncedMediaSourceProvider.cs" />
+    <Compile Include="Sync\SyncHelper.cs" />
+    <Compile Include="Sync\SyncJobOptions.cs" />
+    <Compile Include="Sync\SyncJobProcessor.cs" />
+    <Compile Include="Sync\SyncManager.cs" />
+    <Compile Include="Sync\SyncNotificationEntryPoint.cs" />
+    <Compile Include="Sync\SyncRegistrationInfo.cs" />
+    <Compile Include="Sync\TargetDataProvider.cs" />
+    <Compile Include="TV\SeriesPostScanTask.cs" />
+    <Compile Include="TV\TVSeriesManager.cs" />
+    <Compile Include="Updates\InstallationManager.cs" />
+    <Compile Include="UserViews\CollectionFolderImageProvider.cs" />
+    <Compile Include="UserViews\DynamicImageProvider.cs" />
+  </ItemGroup>
+  <ItemGroup />
+  <ItemGroup>
+    <ProjectReference Include="..\MediaBrowser.Common\MediaBrowser.Common.csproj">
+      <Project>{9142eefa-7570-41e1-bfcc-468bb571af2f}</Project>
+      <Name>MediaBrowser.Common</Name>
+    </ProjectReference>
+    <ProjectReference Include="..\MediaBrowser.Controller\MediaBrowser.Controller.csproj">
+      <Project>{17e1f4e6-8abd-4fe5-9ecf-43d4b6087ba2}</Project>
+      <Name>MediaBrowser.Controller</Name>
+    </ProjectReference>
+    <ProjectReference Include="..\MediaBrowser.Model\MediaBrowser.Model.csproj">
+      <Project>{7eeeb4bb-f3e8-48fc-b4c5-70f0fff8329b}</Project>
+      <Name>MediaBrowser.Model</Name>
+    </ProjectReference>
+    <ProjectReference Include="..\MediaBrowser.Providers\MediaBrowser.Providers.csproj">
+      <Project>{442b5058-dcaf-4263-bb6a-f21e31120a1b}</Project>
+      <Name>MediaBrowser.Providers</Name>
+    </ProjectReference>
+  </ItemGroup>
+  <Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />
+  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
+       Other similar extension points exist, see Microsoft.Common.targets.
+  <Target Name="BeforeBuild">
+  </Target>
+  <Target Name="AfterBuild">
+  </Target>
+  -->
+</Project>

+ 7 - 4
MediaBrowser.Server.Implementations/EntryPoints/AutomaticRestartEntryPoint.cs → Emby.Server.Implementations/EntryPoints/AutomaticRestartEntryPoint.cs

@@ -10,8 +10,9 @@ using System.Threading;
 using System.Threading.Tasks;
 using System.Threading.Tasks;
 using MediaBrowser.Controller.LiveTv;
 using MediaBrowser.Controller.LiveTv;
 using MediaBrowser.Model.LiveTv;
 using MediaBrowser.Model.LiveTv;
+using MediaBrowser.Model.Threading;
 
 
-namespace MediaBrowser.Server.Implementations.EntryPoints
+namespace Emby.Server.Implementations.EntryPoints
 {
 {
     public class AutomaticRestartEntryPoint : IServerEntryPoint
     public class AutomaticRestartEntryPoint : IServerEntryPoint
     {
     {
@@ -21,10 +22,11 @@ namespace MediaBrowser.Server.Implementations.EntryPoints
         private readonly ISessionManager _sessionManager;
         private readonly ISessionManager _sessionManager;
         private readonly IServerConfigurationManager _config;
         private readonly IServerConfigurationManager _config;
         private readonly ILiveTvManager _liveTvManager;
         private readonly ILiveTvManager _liveTvManager;
+        private readonly ITimerFactory _timerFactory;
 
 
-        private Timer _timer;
+        private ITimer _timer;
 
 
-        public AutomaticRestartEntryPoint(IServerApplicationHost appHost, ILogger logger, ITaskManager iTaskManager, ISessionManager sessionManager, IServerConfigurationManager config, ILiveTvManager liveTvManager)
+        public AutomaticRestartEntryPoint(IServerApplicationHost appHost, ILogger logger, ITaskManager iTaskManager, ISessionManager sessionManager, IServerConfigurationManager config, ILiveTvManager liveTvManager, ITimerFactory timerFactory)
         {
         {
             _appHost = appHost;
             _appHost = appHost;
             _logger = logger;
             _logger = logger;
@@ -32,6 +34,7 @@ namespace MediaBrowser.Server.Implementations.EntryPoints
             _sessionManager = sessionManager;
             _sessionManager = sessionManager;
             _config = config;
             _config = config;
             _liveTvManager = liveTvManager;
             _liveTvManager = liveTvManager;
+            _timerFactory = timerFactory;
         }
         }
 
 
         public void Run()
         public void Run()
@@ -48,7 +51,7 @@ namespace MediaBrowser.Server.Implementations.EntryPoints
 
 
             if (_appHost.HasPendingRestart)
             if (_appHost.HasPendingRestart)
             {
             {
-                _timer = new Timer(TimerCallback, null, TimeSpan.FromMinutes(10), TimeSpan.FromMinutes(10));
+                _timer = _timerFactory.Create(TimerCallback, null, TimeSpan.FromMinutes(10), TimeSpan.FromMinutes(10));
             }
             }
         }
         }
 
 

+ 9 - 6
MediaBrowser.Server.Implementations/EntryPoints/LibraryChangedNotifier.cs → Emby.Server.Implementations/EntryPoints/LibraryChangedNotifier.cs

@@ -10,8 +10,9 @@ using System.Linq;
 using System.Threading;
 using System.Threading;
 using MediaBrowser.Controller.Entities.Audio;
 using MediaBrowser.Controller.Entities.Audio;
 using MediaBrowser.Model.Extensions;
 using MediaBrowser.Model.Extensions;
+using MediaBrowser.Model.Threading;
 
 
-namespace MediaBrowser.Server.Implementations.EntryPoints
+namespace Emby.Server.Implementations.EntryPoints
 {
 {
     public class LibraryChangedNotifier : IServerEntryPoint
     public class LibraryChangedNotifier : IServerEntryPoint
     {
     {
@@ -23,6 +24,7 @@ namespace MediaBrowser.Server.Implementations.EntryPoints
         private readonly ISessionManager _sessionManager;
         private readonly ISessionManager _sessionManager;
         private readonly IUserManager _userManager;
         private readonly IUserManager _userManager;
         private readonly ILogger _logger;
         private readonly ILogger _logger;
+        private readonly ITimerFactory _timerFactory;
 
 
         /// <summary>
         /// <summary>
         /// The _library changed sync lock
         /// The _library changed sync lock
@@ -40,19 +42,20 @@ namespace MediaBrowser.Server.Implementations.EntryPoints
         /// Gets or sets the library update timer.
         /// Gets or sets the library update timer.
         /// </summary>
         /// </summary>
         /// <value>The library update timer.</value>
         /// <value>The library update timer.</value>
-        private Timer LibraryUpdateTimer { get; set; }
+        private ITimer LibraryUpdateTimer { get; set; }
 
 
         /// <summary>
         /// <summary>
         /// The library update duration
         /// The library update duration
         /// </summary>
         /// </summary>
         private const int LibraryUpdateDuration = 5000;
         private const int LibraryUpdateDuration = 5000;
 
 
-        public LibraryChangedNotifier(ILibraryManager libraryManager, ISessionManager sessionManager, IUserManager userManager, ILogger logger)
+        public LibraryChangedNotifier(ILibraryManager libraryManager, ISessionManager sessionManager, IUserManager userManager, ILogger logger, ITimerFactory timerFactory)
         {
         {
             _libraryManager = libraryManager;
             _libraryManager = libraryManager;
             _sessionManager = sessionManager;
             _sessionManager = sessionManager;
             _userManager = userManager;
             _userManager = userManager;
             _logger = logger;
             _logger = logger;
+            _timerFactory = timerFactory;
         }
         }
 
 
         public void Run()
         public void Run()
@@ -79,7 +82,7 @@ namespace MediaBrowser.Server.Implementations.EntryPoints
             {
             {
                 if (LibraryUpdateTimer == null)
                 if (LibraryUpdateTimer == null)
                 {
                 {
-                    LibraryUpdateTimer = new Timer(LibraryUpdateTimerCallback, null, LibraryUpdateDuration,
+                    LibraryUpdateTimer = _timerFactory.Create(LibraryUpdateTimerCallback, null, LibraryUpdateDuration,
                                                    Timeout.Infinite);
                                                    Timeout.Infinite);
                 }
                 }
                 else
                 else
@@ -112,7 +115,7 @@ namespace MediaBrowser.Server.Implementations.EntryPoints
             {
             {
                 if (LibraryUpdateTimer == null)
                 if (LibraryUpdateTimer == null)
                 {
                 {
-                    LibraryUpdateTimer = new Timer(LibraryUpdateTimerCallback, null, LibraryUpdateDuration,
+                    LibraryUpdateTimer = _timerFactory.Create(LibraryUpdateTimerCallback, null, LibraryUpdateDuration,
                                                    Timeout.Infinite);
                                                    Timeout.Infinite);
                 }
                 }
                 else
                 else
@@ -140,7 +143,7 @@ namespace MediaBrowser.Server.Implementations.EntryPoints
             {
             {
                 if (LibraryUpdateTimer == null)
                 if (LibraryUpdateTimer == null)
                 {
                 {
-                    LibraryUpdateTimer = new Timer(LibraryUpdateTimerCallback, null, LibraryUpdateDuration,
+                    LibraryUpdateTimer = _timerFactory.Create(LibraryUpdateTimerCallback, null, LibraryUpdateDuration,
                                                    Timeout.Infinite);
                                                    Timeout.Infinite);
                 }
                 }
                 else
                 else

+ 7 - 5
MediaBrowser.Server.Implementations/EntryPoints/LoadRegistrations.cs → Emby.Server.Implementations/EntryPoints/LoadRegistrations.cs

@@ -3,9 +3,9 @@ using MediaBrowser.Controller.Plugins;
 using MediaBrowser.Model.Logging;
 using MediaBrowser.Model.Logging;
 using System;
 using System;
 using System.Threading.Tasks;
 using System.Threading.Tasks;
-using MediaBrowser.Server.Implementations.Threading;
+using MediaBrowser.Model.Threading;
 
 
-namespace MediaBrowser.Server.Implementations.EntryPoints
+namespace Emby.Server.Implementations.EntryPoints
 {
 {
     /// <summary>
     /// <summary>
     /// Class LoadRegistrations
     /// Class LoadRegistrations
@@ -22,16 +22,18 @@ namespace MediaBrowser.Server.Implementations.EntryPoints
         /// </summary>
         /// </summary>
         private readonly ILogger _logger;
         private readonly ILogger _logger;
 
 
-        private PeriodicTimer _timer;
+        private ITimer _timer;
+        private readonly ITimerFactory _timerFactory;
 
 
         /// <summary>
         /// <summary>
         /// Initializes a new instance of the <see cref="LoadRegistrations" /> class.
         /// Initializes a new instance of the <see cref="LoadRegistrations" /> class.
         /// </summary>
         /// </summary>
         /// <param name="securityManager">The security manager.</param>
         /// <param name="securityManager">The security manager.</param>
         /// <param name="logManager">The log manager.</param>
         /// <param name="logManager">The log manager.</param>
-        public LoadRegistrations(ISecurityManager securityManager, ILogManager logManager)
+        public LoadRegistrations(ISecurityManager securityManager, ILogManager logManager, ITimerFactory timerFactory)
         {
         {
             _securityManager = securityManager;
             _securityManager = securityManager;
+            _timerFactory = timerFactory;
 
 
             _logger = logManager.GetLogger("Registration Loader");
             _logger = logManager.GetLogger("Registration Loader");
         }
         }
@@ -41,7 +43,7 @@ namespace MediaBrowser.Server.Implementations.EntryPoints
         /// </summary>
         /// </summary>
         public void Run()
         public void Run()
         {
         {
-            _timer = new PeriodicTimer(s => LoadAllRegistrations(), null, TimeSpan.FromMilliseconds(100), TimeSpan.FromHours(12));
+            _timer = _timerFactory.Create(s => LoadAllRegistrations(), null, TimeSpan.FromMilliseconds(100), TimeSpan.FromHours(12));
         }
         }
 
 
         private async Task LoadAllRegistrations()
         private async Task LoadAllRegistrations()

+ 5 - 5
MediaBrowser.Server.Implementations/EntryPoints/RecordingNotifier.cs → Emby.Server.Implementations/EntryPoints/RecordingNotifier.cs

@@ -7,7 +7,7 @@ using MediaBrowser.Controller.Plugins;
 using MediaBrowser.Controller.Session;
 using MediaBrowser.Controller.Session;
 using MediaBrowser.Model.Logging;
 using MediaBrowser.Model.Logging;
 
 
-namespace MediaBrowser.Server.Implementations.EntryPoints
+namespace Emby.Server.Implementations.EntryPoints
 {
 {
     public class RecordingNotifier : IServerEntryPoint
     public class RecordingNotifier : IServerEntryPoint
     {
     {
@@ -32,22 +32,22 @@ namespace MediaBrowser.Server.Implementations.EntryPoints
             _liveTvManager.SeriesTimerCreated += _liveTvManager_SeriesTimerCreated;
             _liveTvManager.SeriesTimerCreated += _liveTvManager_SeriesTimerCreated;
         }
         }
 
 
-        private void _liveTvManager_SeriesTimerCreated(object sender, Model.Events.GenericEventArgs<TimerEventInfo> e)
+        private void _liveTvManager_SeriesTimerCreated(object sender, MediaBrowser.Model.Events.GenericEventArgs<TimerEventInfo> e)
         {
         {
             SendMessage("SeriesTimerCreated", e.Argument);
             SendMessage("SeriesTimerCreated", e.Argument);
         }
         }
 
 
-        private void _liveTvManager_TimerCreated(object sender, Model.Events.GenericEventArgs<TimerEventInfo> e)
+        private void _liveTvManager_TimerCreated(object sender, MediaBrowser.Model.Events.GenericEventArgs<TimerEventInfo> e)
         {
         {
             SendMessage("TimerCreated", e.Argument);
             SendMessage("TimerCreated", e.Argument);
         }
         }
 
 
-        private void _liveTvManager_SeriesTimerCancelled(object sender, Model.Events.GenericEventArgs<TimerEventInfo> e)
+        private void _liveTvManager_SeriesTimerCancelled(object sender, MediaBrowser.Model.Events.GenericEventArgs<TimerEventInfo> e)
         {
         {
             SendMessage("SeriesTimerCancelled", e.Argument);
             SendMessage("SeriesTimerCancelled", e.Argument);
         }
         }
 
 
-        private void _liveTvManager_TimerCancelled(object sender, Model.Events.GenericEventArgs<TimerEventInfo> e)
+        private void _liveTvManager_TimerCancelled(object sender, MediaBrowser.Model.Events.GenericEventArgs<TimerEventInfo> e)
         {
         {
             SendMessage("TimerCancelled", e.Argument);
             SendMessage("TimerCancelled", e.Argument);
         }
         }

+ 1 - 1
MediaBrowser.Server.Implementations/EntryPoints/RefreshUsersMetadata.cs → Emby.Server.Implementations/EntryPoints/RefreshUsersMetadata.cs

@@ -2,7 +2,7 @@
 using MediaBrowser.Controller.Plugins;
 using MediaBrowser.Controller.Plugins;
 using System.Threading;
 using System.Threading;
 
 
-namespace MediaBrowser.Server.Implementations.EntryPoints
+namespace Emby.Server.Implementations.EntryPoints
 {
 {
     /// <summary>
     /// <summary>
     /// Class RefreshUsersMetadata
     /// Class RefreshUsersMetadata

+ 1 - 1
MediaBrowser.Server.Implementations/EntryPoints/ServerEventNotifier.cs → Emby.Server.Implementations/EntryPoints/ServerEventNotifier.cs

@@ -14,7 +14,7 @@ using System.Collections.Generic;
 using System.Threading;
 using System.Threading;
 using MediaBrowser.Model.Tasks;
 using MediaBrowser.Model.Tasks;
 
 
-namespace MediaBrowser.Server.Implementations.EntryPoints
+namespace Emby.Server.Implementations.EntryPoints
 {
 {
     /// <summary>
     /// <summary>
     /// Class WebSocketEvents
     /// Class WebSocketEvents

+ 1 - 1
MediaBrowser.Server.Implementations/EntryPoints/UsageEntryPoint.cs → Emby.Server.Implementations/EntryPoints/UsageEntryPoint.cs

@@ -12,7 +12,7 @@ using System.Threading;
 using System.Threading.Tasks;
 using System.Threading.Tasks;
 using MediaBrowser.Controller.Configuration;
 using MediaBrowser.Controller.Configuration;
 
 
-namespace MediaBrowser.Server.Implementations.EntryPoints
+namespace Emby.Server.Implementations.EntryPoints
 {
 {
     /// <summary>
     /// <summary>
     /// Class UsageEntryPoint
     /// Class UsageEntryPoint

+ 1 - 1
MediaBrowser.Server.Implementations/EntryPoints/UsageReporter.cs → Emby.Server.Implementations/EntryPoints/UsageReporter.cs

@@ -10,7 +10,7 @@ using System.Threading;
 using System.Threading.Tasks;
 using System.Threading.Tasks;
 using MediaBrowser.Model.Logging;
 using MediaBrowser.Model.Logging;
 
 
-namespace MediaBrowser.Server.Implementations.EntryPoints
+namespace Emby.Server.Implementations.EntryPoints
 {
 {
     public class UsageReporter
     public class UsageReporter
     {
     {

+ 7 - 4
MediaBrowser.Server.Implementations/EntryPoints/UserDataChangeNotifier.cs → Emby.Server.Implementations/EntryPoints/UserDataChangeNotifier.cs

@@ -11,8 +11,9 @@ using System.Linq;
 using System.Threading;
 using System.Threading;
 using System.Threading.Tasks;
 using System.Threading.Tasks;
 using MediaBrowser.Model.Extensions;
 using MediaBrowser.Model.Extensions;
+using MediaBrowser.Model.Threading;
 
 
-namespace MediaBrowser.Server.Implementations.EntryPoints
+namespace Emby.Server.Implementations.EntryPoints
 {
 {
     class UserDataChangeNotifier : IServerEntryPoint
     class UserDataChangeNotifier : IServerEntryPoint
     {
     {
@@ -22,17 +23,19 @@ namespace MediaBrowser.Server.Implementations.EntryPoints
         private readonly IUserManager _userManager;
         private readonly IUserManager _userManager;
 
 
         private readonly object _syncLock = new object();
         private readonly object _syncLock = new object();
-        private Timer UpdateTimer { get; set; }
+        private ITimer UpdateTimer { get; set; }
+        private readonly ITimerFactory _timerFactory;
         private const int UpdateDuration = 500;
         private const int UpdateDuration = 500;
 
 
         private readonly Dictionary<Guid, List<IHasUserData>> _changedItems = new Dictionary<Guid, List<IHasUserData>>();
         private readonly Dictionary<Guid, List<IHasUserData>> _changedItems = new Dictionary<Guid, List<IHasUserData>>();
 
 
-        public UserDataChangeNotifier(IUserDataManager userDataManager, ISessionManager sessionManager, ILogger logger, IUserManager userManager)
+        public UserDataChangeNotifier(IUserDataManager userDataManager, ISessionManager sessionManager, ILogger logger, IUserManager userManager, ITimerFactory timerFactory)
         {
         {
             _userDataManager = userDataManager;
             _userDataManager = userDataManager;
             _sessionManager = sessionManager;
             _sessionManager = sessionManager;
             _logger = logger;
             _logger = logger;
             _userManager = userManager;
             _userManager = userManager;
+            _timerFactory = timerFactory;
         }
         }
 
 
         public void Run()
         public void Run()
@@ -51,7 +54,7 @@ namespace MediaBrowser.Server.Implementations.EntryPoints
             {
             {
                 if (UpdateTimer == null)
                 if (UpdateTimer == null)
                 {
                 {
-                    UpdateTimer = new Timer(UpdateTimerCallback, null, UpdateDuration,
+                    UpdateTimer = _timerFactory.Create(UpdateTimerCallback, null, UpdateDuration,
                                                    Timeout.Infinite);
                                                    Timeout.Infinite);
                 }
                 }
                 else
                 else

+ 15 - 12
MediaBrowser.Server.Implementations/FileOrganization/EpisodeFileOrganizer.cs → Emby.Server.Implementations/FileOrganization/EpisodeFileOrganizer.cs

@@ -7,8 +7,6 @@ using MediaBrowser.Model.Entities;
 using MediaBrowser.Model.Extensions;
 using MediaBrowser.Model.Extensions;
 using MediaBrowser.Model.FileOrganization;
 using MediaBrowser.Model.FileOrganization;
 using MediaBrowser.Model.Logging;
 using MediaBrowser.Model.Logging;
-using MediaBrowser.Server.Implementations.Library;
-using MediaBrowser.Server.Implementations.Logging;
 using System;
 using System;
 using System.Collections.Generic;
 using System.Collections.Generic;
 using System.Globalization;
 using System.Globalization;
@@ -16,11 +14,16 @@ using System.IO;
 using System.Linq;
 using System.Linq;
 using System.Threading;
 using System.Threading;
 using System.Threading.Tasks;
 using System.Threading.Tasks;
+using Emby.Server.Implementations.Library;
+using Emby.Server.Implementations.Logging;
 using MediaBrowser.Common.IO;
 using MediaBrowser.Common.IO;
+using MediaBrowser.Controller.Entities;
 using MediaBrowser.Controller.IO;
 using MediaBrowser.Controller.IO;
 using MediaBrowser.Model.IO;
 using MediaBrowser.Model.IO;
+using MediaBrowser.Naming.TV;
+using EpisodeInfo = MediaBrowser.Controller.Providers.EpisodeInfo;
 
 
-namespace MediaBrowser.Server.Implementations.FileOrganization
+namespace Emby.Server.Implementations.FileOrganization
 {
 {
     public class EpisodeFileOrganizer
     public class EpisodeFileOrganizer
     {
     {
@@ -55,7 +58,7 @@ namespace MediaBrowser.Server.Implementations.FileOrganization
                 OriginalPath = path,
                 OriginalPath = path,
                 OriginalFileName = Path.GetFileName(path),
                 OriginalFileName = Path.GetFileName(path),
                 Type = FileOrganizerType.Episode,
                 Type = FileOrganizerType.Episode,
-                FileSize = new FileInfo(path).Length
+                FileSize = _fileSystem.GetFileInfo(path).Length
             };
             };
 
 
             try
             try
@@ -68,10 +71,10 @@ namespace MediaBrowser.Server.Implementations.FileOrganization
             }
             }
 
 
             var namingOptions = ((LibraryManager)_libraryManager).GetNamingOptions();
             var namingOptions = ((LibraryManager)_libraryManager).GetNamingOptions();
-            var resolver = new Naming.TV.EpisodeResolver(namingOptions, new PatternsLogger());
+            var resolver = new EpisodeResolver(namingOptions, new PatternsLogger());
 
 
             var episodeInfo = resolver.Resolve(path, false) ??
             var episodeInfo = resolver.Resolve(path, false) ??
-                new Naming.TV.EpisodeInfo();
+                new MediaBrowser.Naming.TV.EpisodeInfo();
 
 
             var seriesName = episodeInfo.SeriesName;
             var seriesName = episodeInfo.SeriesName;
 
 
@@ -505,7 +508,7 @@ namespace MediaBrowser.Server.Implementations.FileOrganization
 
 
                 episodePaths.AddRange(filesOfOtherExtensions);
                 episodePaths.AddRange(filesOfOtherExtensions);
             }
             }
-            catch (DirectoryNotFoundException)
+            catch (IOException)
             {
             {
                 // No big deal. Maybe the season folder doesn't already exist.
                 // No big deal. Maybe the season folder doesn't already exist.
             }
             }
@@ -575,7 +578,7 @@ namespace MediaBrowser.Server.Implementations.FileOrganization
             result.ExtractedName = nameWithoutYear;
             result.ExtractedName = nameWithoutYear;
             result.ExtractedYear = yearInName;
             result.ExtractedYear = yearInName;
 
 
-            var series = _libraryManager.GetItemList(new Controller.Entities.InternalItemsQuery
+            var series = _libraryManager.GetItemList(new InternalItemsQuery
             {
             {
                 IncludeItemTypes = new[] { typeof(Series).Name },
                 IncludeItemTypes = new[] { typeof(Series).Name },
                 Recursive = true
                 Recursive = true
@@ -593,7 +596,7 @@ namespace MediaBrowser.Server.Implementations.FileOrganization
 
 
                 if (info != null)
                 if (info != null)
                 {
                 {
-                    series = _libraryManager.GetItemList(new Controller.Entities.InternalItemsQuery
+                    series = _libraryManager.GetItemList(new InternalItemsQuery
                     {
                     {
                         IncludeItemTypes = new[] { typeof(Series).Name },
                         IncludeItemTypes = new[] { typeof(Series).Name },
                         Recursive = true,
                         Recursive = true,
@@ -808,8 +811,8 @@ namespace MediaBrowser.Server.Implementations.FileOrganization
         {
         {
             try
             try
             {
             {
-                var sourceFileInfo = new FileInfo(sourcePath);
-                var destinationFileInfo = new FileInfo(newPath);
+                var sourceFileInfo = _fileSystem.GetFileInfo(sourcePath);
+                var destinationFileInfo = _fileSystem.GetFileInfo(newPath);
 
 
                 if (sourceFileInfo.Length == destinationFileInfo.Length)
                 if (sourceFileInfo.Length == destinationFileInfo.Length)
                 {
                 {
@@ -820,7 +823,7 @@ namespace MediaBrowser.Server.Implementations.FileOrganization
             {
             {
                 return false;
                 return false;
             }
             }
-            catch (DirectoryNotFoundException)
+            catch (IOException)
             {
             {
                 return false;
                 return false;
             }
             }

+ 1 - 1
MediaBrowser.Server.Implementations/FileOrganization/Extensions.cs → Emby.Server.Implementations/FileOrganization/Extensions.cs

@@ -2,7 +2,7 @@
 using MediaBrowser.Model.FileOrganization;
 using MediaBrowser.Model.FileOrganization;
 using System.Collections.Generic;
 using System.Collections.Generic;
 
 
-namespace MediaBrowser.Server.Implementations.FileOrganization
+namespace Emby.Server.Implementations.FileOrganization
 {
 {
     public static class ConfigurationExtension
     public static class ConfigurationExtension
     {
     {

+ 1 - 1
MediaBrowser.Server.Implementations/FileOrganization/FileOrganizationNotifier.cs → Emby.Server.Implementations/FileOrganization/FileOrganizationNotifier.cs

@@ -8,7 +8,7 @@ using System;
 using System.Threading;
 using System.Threading;
 using MediaBrowser.Model.Tasks;
 using MediaBrowser.Model.Tasks;
 
 
-namespace MediaBrowser.Server.Implementations.FileOrganization
+namespace Emby.Server.Implementations.FileOrganization
 {
 {
     /// <summary>
     /// <summary>
     /// Class SessionInfoWebSocketListener
     /// Class SessionInfoWebSocketListener

+ 1 - 1
MediaBrowser.Server.Implementations/FileOrganization/FileOrganizationService.cs → Emby.Server.Implementations/FileOrganization/FileOrganizationService.cs

@@ -21,7 +21,7 @@ using MediaBrowser.Common.IO;
 using MediaBrowser.Controller.IO;
 using MediaBrowser.Controller.IO;
 using MediaBrowser.Model.Tasks;
 using MediaBrowser.Model.Tasks;
 
 
-namespace MediaBrowser.Server.Implementations.FileOrganization
+namespace Emby.Server.Implementations.FileOrganization
 {
 {
     public class FileOrganizationService : IFileOrganizationService
     public class FileOrganizationService : IFileOrganizationService
     {
     {

+ 3 - 18
MediaBrowser.Server.Implementations/FileOrganization/NameUtils.cs → Emby.Server.Implementations/FileOrganization/NameUtils.cs

@@ -2,10 +2,9 @@
 using MediaBrowser.Controller.Entities;
 using MediaBrowser.Controller.Entities;
 using System;
 using System;
 using System.Globalization;
 using System.Globalization;
-using System.Linq;
-using System.Text;
+using MediaBrowser.Controller.Extensions;
 
 
-namespace MediaBrowser.Server.Implementations.FileOrganization
+namespace Emby.Server.Implementations.FileOrganization
 {
 {
     public static class NameUtils
     public static class NameUtils
     {
     {
@@ -54,7 +53,7 @@ namespace MediaBrowser.Server.Implementations.FileOrganization
 
 
         private static string GetComparableName(string name)
         private static string GetComparableName(string name)
         {
         {
-            name = RemoveDiacritics(name);
+            name = name.RemoveDiacritics();
 
 
             name = " " + name + " ";
             name = " " + name + " ";
 
 
@@ -78,19 +77,5 @@ namespace MediaBrowser.Server.Implementations.FileOrganization
 
 
             return name.Trim();
             return name.Trim();
         }
         }
-
-        /// <summary>
-        /// Removes the diacritics.
-        /// </summary>
-        /// <param name="text">The text.</param>
-        /// <returns>System.String.</returns>
-        private static string RemoveDiacritics(string text)
-        {
-            return String.Concat(
-                text.Normalize(NormalizationForm.FormD)
-                .Where(ch => CharUnicodeInfo.GetUnicodeCategory(ch) !=
-                                              UnicodeCategory.NonSpacingMark)
-              ).Normalize(NormalizationForm.FormC);
-        }
     }
     }
 }
 }

+ 1 - 1
MediaBrowser.Server.Implementations/FileOrganization/OrganizerScheduledTask.cs → Emby.Server.Implementations/FileOrganization/OrganizerScheduledTask.cs

@@ -13,7 +13,7 @@ using MediaBrowser.Controller.IO;
 using MediaBrowser.Model.IO;
 using MediaBrowser.Model.IO;
 using MediaBrowser.Model.Tasks;
 using MediaBrowser.Model.Tasks;
 
 
-namespace MediaBrowser.Server.Implementations.FileOrganization
+namespace Emby.Server.Implementations.FileOrganization
 {
 {
     public class OrganizerScheduledTask : IScheduledTask, IConfigurableScheduledTask
     public class OrganizerScheduledTask : IScheduledTask, IConfigurableScheduledTask
     {
     {

+ 2 - 2
MediaBrowser.Server.Implementations/FileOrganization/TvFolderOrganizer.cs → Emby.Server.Implementations/FileOrganization/TvFolderOrganizer.cs

@@ -14,7 +14,7 @@ using MediaBrowser.Common.IO;
 using MediaBrowser.Controller.IO;
 using MediaBrowser.Controller.IO;
 using MediaBrowser.Model.IO;
 using MediaBrowser.Model.IO;
 
 
-namespace MediaBrowser.Server.Implementations.FileOrganization
+namespace Emby.Server.Implementations.FileOrganization
 {
 {
     public class TvFolderOrganizer
     public class TvFolderOrganizer
     {
     {
@@ -191,7 +191,7 @@ namespace MediaBrowser.Server.Implementations.FileOrganization
                         _fileSystem.DeleteDirectory(path, false);
                         _fileSystem.DeleteDirectory(path, false);
                     }
                     }
                     catch (UnauthorizedAccessException) { }
                     catch (UnauthorizedAccessException) { }
-                    catch (DirectoryNotFoundException) { }
+                    catch (IOException) { }
                 }
                 }
             }
             }
             catch (UnauthorizedAccessException) { }
             catch (UnauthorizedAccessException) { }

+ 4 - 3
MediaBrowser.Server.Implementations/IO/ThrottledStream.cs → Emby.Server.Implementations/IO/ThrottledStream.cs

@@ -3,7 +3,7 @@ using System.IO;
 using System.Threading;
 using System.Threading;
 using System.Threading.Tasks;
 using System.Threading.Tasks;
 
 
-namespace MediaBrowser.Server.Implementations.IO
+namespace Emby.Server.Implementations.IO
 {
 {
     /// <summary>
     /// <summary>
     /// Class for streaming data with throttling support.
     /// Class for streaming data with throttling support.
@@ -326,9 +326,10 @@ namespace MediaBrowser.Server.Implementations.IO
                         try
                         try
                         {
                         {
                             // The time to sleep is more then a millisecond, so sleep.
                             // The time to sleep is more then a millisecond, so sleep.
-                            Thread.Sleep(toSleep);
+                            var task = Task.Delay(toSleep);
+                            Task.WaitAll(task);
                         }
                         }
-                        catch (ThreadAbortException)
+                        catch
                         {
                         {
                             // Eatup ThreadAbortException.
                             // Eatup ThreadAbortException.
                         }
                         }

+ 2 - 2
MediaBrowser.Server.Implementations/Photos/BaseDynamicImageProvider.cs → Emby.Server.Implementations/Images/BaseDynamicImageProvider.cs

@@ -18,7 +18,7 @@ using MediaBrowser.Controller.Entities.Audio;
 using MediaBrowser.Controller.IO;
 using MediaBrowser.Controller.IO;
 using MediaBrowser.Model.Configuration;
 using MediaBrowser.Model.Configuration;
 
 
-namespace MediaBrowser.Server.Implementations.Photos
+namespace Emby.Server.Implementations.Images
 {
 {
     public abstract class BaseDynamicImageProvider<T> : IHasItemChangeMonitor, IForcedProvider, ICustomMetadataProvider<T>, IHasOrder
     public abstract class BaseDynamicImageProvider<T> : IHasItemChangeMonitor, IForcedProvider, ICustomMetadataProvider<T>, IHasOrder
         where T : IHasMetadata
         where T : IHasMetadata
@@ -353,7 +353,7 @@ namespace MediaBrowser.Server.Implementations.Photos
             var ext = Path.GetExtension(image);
             var ext = Path.GetExtension(image);
 
 
             var outputPath = Path.ChangeExtension(outputPathWithoutExtension, ext);
             var outputPath = Path.ChangeExtension(outputPathWithoutExtension, ext);
-            File.Copy(image, outputPath);
+            FileSystem.CopyFile(image, outputPath, true);
 
 
             return outputPath;
             return outputPath;
         }
         }

+ 1 - 3
MediaBrowser.Server.Implementations/Intros/DefaultIntroProvider.cs → Emby.Server.Implementations/Intros/DefaultIntroProvider.cs

@@ -11,13 +11,11 @@ using System.Collections.Generic;
 using System.IO;
 using System.IO;
 using System.Linq;
 using System.Linq;
 using System.Threading.Tasks;
 using System.Threading.Tasks;
-using MediaBrowser.Common.IO;
-using MediaBrowser.Controller.IO;
 using MediaBrowser.Model.IO;
 using MediaBrowser.Model.IO;
 using MediaBrowser.Model.Extensions;
 using MediaBrowser.Model.Extensions;
 using MediaBrowser.Model.Globalization;
 using MediaBrowser.Model.Globalization;
 
 
-namespace MediaBrowser.Server.Implementations.Intros
+namespace Emby.Server.Implementations.Intros
 {
 {
     public class DefaultIntroProvider : IIntroProvider
     public class DefaultIntroProvider : IIntroProvider
     {
     {

+ 1 - 1
MediaBrowser.Server.Implementations/Library/CoreResolutionIgnoreRule.cs → Emby.Server.Implementations/Library/CoreResolutionIgnoreRule.cs

@@ -10,7 +10,7 @@ using MediaBrowser.Common.IO;
 using MediaBrowser.Controller.IO;
 using MediaBrowser.Controller.IO;
 using MediaBrowser.Model.IO;
 using MediaBrowser.Model.IO;
 
 
-namespace MediaBrowser.Server.Implementations.Library
+namespace Emby.Server.Implementations.Library
 {
 {
     /// <summary>
     /// <summary>
     /// Provides the core resolver ignore rules
     /// Provides the core resolver ignore rules

+ 27 - 28
MediaBrowser.Server.Implementations/Library/LibraryManager.cs → Emby.Server.Implementations/Library/LibraryManager.cs

@@ -18,9 +18,6 @@ using MediaBrowser.Naming.Audio;
 using MediaBrowser.Naming.Common;
 using MediaBrowser.Naming.Common;
 using MediaBrowser.Naming.TV;
 using MediaBrowser.Naming.TV;
 using MediaBrowser.Naming.Video;
 using MediaBrowser.Naming.Video;
-using MediaBrowser.Server.Implementations.Library.Validators;
-using MediaBrowser.Server.Implementations.Logging;
-using MediaBrowser.Server.Implementations.ScheduledTasks;
 using System;
 using System;
 using System.Collections.Concurrent;
 using System.Collections.Concurrent;
 using System.Collections.Generic;
 using System.Collections.Generic;
@@ -30,6 +27,10 @@ using System.Linq;
 using System.Net;
 using System.Net;
 using System.Threading;
 using System.Threading;
 using System.Threading.Tasks;
 using System.Threading.Tasks;
+using Emby.Server.Implementations.Library.Resolvers;
+using Emby.Server.Implementations.Library.Validators;
+using Emby.Server.Implementations.Logging;
+using Emby.Server.Implementations.ScheduledTasks;
 using MediaBrowser.Model.IO;
 using MediaBrowser.Model.IO;
 using MediaBrowser.Controller.Channels;
 using MediaBrowser.Controller.Channels;
 using MediaBrowser.Model.Channels;
 using MediaBrowser.Model.Channels;
@@ -37,14 +38,13 @@ using MediaBrowser.Model.Dto;
 using MediaBrowser.Model.Extensions;
 using MediaBrowser.Model.Extensions;
 using MediaBrowser.Model.Library;
 using MediaBrowser.Model.Library;
 using MediaBrowser.Model.Net;
 using MediaBrowser.Model.Net;
-using MediaBrowser.Server.Implementations.Library.Resolvers;
 using SortOrder = MediaBrowser.Model.Entities.SortOrder;
 using SortOrder = MediaBrowser.Model.Entities.SortOrder;
 using VideoResolver = MediaBrowser.Naming.Video.VideoResolver;
 using VideoResolver = MediaBrowser.Naming.Video.VideoResolver;
 using MediaBrowser.Common.Configuration;
 using MediaBrowser.Common.Configuration;
 using MediaBrowser.Common.IO;
 using MediaBrowser.Common.IO;
 using MediaBrowser.Model.Tasks;
 using MediaBrowser.Model.Tasks;
 
 
-namespace MediaBrowser.Server.Implementations.Library
+namespace Emby.Server.Implementations.Library
 {
 {
     /// <summary>
     /// <summary>
     /// Class LibraryManager
     /// Class LibraryManager
@@ -403,7 +403,7 @@ namespace MediaBrowser.Server.Implementations.Library
                 {
                 {
                     _fileSystem.DeleteDirectory(metadataPath, true);
                     _fileSystem.DeleteDirectory(metadataPath, true);
                 }
                 }
-                catch (DirectoryNotFoundException)
+                catch (IOException)
                 {
                 {
 
 
                 }
                 }
@@ -1189,7 +1189,8 @@ namespace MediaBrowser.Server.Implementations.Library
             {
             {
                 Name = Path.GetFileName(dir),
                 Name = Path.GetFileName(dir),
 
 
-                Locations = Directory.EnumerateFiles(dir, "*.mblink", SearchOption.TopDirectoryOnly)
+                Locations = _fileSystem.GetFilePaths(dir, false)
+                .Where(i => string.Equals(ShortcutFileExtension, Path.GetExtension(i), StringComparison.OrdinalIgnoreCase))
                     .Select(_fileSystem.ResolveShortcut)
                     .Select(_fileSystem.ResolveShortcut)
                     .OrderBy(i => i)
                     .OrderBy(i => i)
                     .ToList(),
                     .ToList(),
@@ -2302,11 +2303,11 @@ namespace MediaBrowser.Server.Implementations.Library
 
 
             var episodeInfo = locationType == LocationType.FileSystem || locationType == LocationType.Offline ?
             var episodeInfo = locationType == LocationType.FileSystem || locationType == LocationType.Offline ?
                 resolver.Resolve(episode.Path, isFolder) :
                 resolver.Resolve(episode.Path, isFolder) :
-                new Naming.TV.EpisodeInfo();
+                new MediaBrowser.Naming.TV.EpisodeInfo();
 
 
             if (episodeInfo == null)
             if (episodeInfo == null)
             {
             {
-                episodeInfo = new Naming.TV.EpisodeInfo();
+                episodeInfo = new MediaBrowser.Naming.TV.EpisodeInfo();
             }
             }
 
 
             var changed = false;
             var changed = false;
@@ -2787,10 +2788,7 @@ namespace MediaBrowser.Server.Implementations.Library
                 {
                 {
                     var path = Path.Combine(virtualFolderPath, collectionType + ".collection");
                     var path = Path.Combine(virtualFolderPath, collectionType + ".collection");
 
 
-                    using (File.Create(path))
-                    {
-
-                    }
+                    _fileSystem.WriteAllBytes(path, new byte[] {});
                 }
                 }
 
 
                 CollectionFolder.SaveLibraryOptions(virtualFolderPath, options);
                 CollectionFolder.SaveLibraryOptions(virtualFolderPath, options);
@@ -2827,21 +2825,20 @@ namespace MediaBrowser.Server.Implementations.Library
 
 
         private bool ValidateNetworkPath(string path)
         private bool ValidateNetworkPath(string path)
         {
         {
-            if (Environment.OSVersion.Platform == PlatformID.Win32NT)
-            {
-                // We can't validate protocol-based paths, so just allow them
-                if (path.IndexOf("://", StringComparison.OrdinalIgnoreCase) == -1)
-                {
-                    return Directory.Exists(path);
-                }
-            }
+            //if (Environment.OSVersion.Platform == PlatformID.Win32NT)
+            //{
+            //    // We can't validate protocol-based paths, so just allow them
+            //    if (path.IndexOf("://", StringComparison.OrdinalIgnoreCase) == -1)
+            //    {
+            //        return _fileSystem.DirectoryExists(path);
+            //    }
+            //}
 
 
             // Without native support for unc, we cannot validate this when running under mono
             // Without native support for unc, we cannot validate this when running under mono
             return true;
             return true;
         }
         }
 
 
         private const string ShortcutFileExtension = ".mblink";
         private const string ShortcutFileExtension = ".mblink";
-        private const string ShortcutFileSearch = "*" + ShortcutFileExtension;
         public void AddMediaPath(string virtualFolderName, MediaPathInfo pathInfo)
         public void AddMediaPath(string virtualFolderName, MediaPathInfo pathInfo)
         {
         {
             AddMediaPathInternal(virtualFolderName, pathInfo, true);
             AddMediaPathInternal(virtualFolderName, pathInfo, true);
@@ -2863,12 +2860,12 @@ namespace MediaBrowser.Server.Implementations.Library
 
 
             if (!_fileSystem.DirectoryExists(path))
             if (!_fileSystem.DirectoryExists(path))
             {
             {
-                throw new DirectoryNotFoundException("The path does not exist.");
+                throw new FileNotFoundException("The path does not exist.");
             }
             }
 
 
             if (!string.IsNullOrWhiteSpace(pathInfo.NetworkPath) && !ValidateNetworkPath(pathInfo.NetworkPath))
             if (!string.IsNullOrWhiteSpace(pathInfo.NetworkPath) && !ValidateNetworkPath(pathInfo.NetworkPath))
             {
             {
-                throw new DirectoryNotFoundException("The network path does not exist.");
+                throw new FileNotFoundException("The network path does not exist.");
             }
             }
 
 
             var rootFolderPath = ConfigurationManager.ApplicationPaths.DefaultUserViewsPath;
             var rootFolderPath = ConfigurationManager.ApplicationPaths.DefaultUserViewsPath;
@@ -2911,7 +2908,7 @@ namespace MediaBrowser.Server.Implementations.Library
 
 
             if (!string.IsNullOrWhiteSpace(pathInfo.NetworkPath) && !ValidateNetworkPath(pathInfo.NetworkPath))
             if (!string.IsNullOrWhiteSpace(pathInfo.NetworkPath) && !ValidateNetworkPath(pathInfo.NetworkPath))
             {
             {
-                throw new DirectoryNotFoundException("The network path does not exist.");
+                throw new FileNotFoundException("The network path does not exist.");
             }
             }
 
 
             var rootFolderPath = ConfigurationManager.ApplicationPaths.DefaultUserViewsPath;
             var rootFolderPath = ConfigurationManager.ApplicationPaths.DefaultUserViewsPath;
@@ -2973,7 +2970,7 @@ namespace MediaBrowser.Server.Implementations.Library
 
 
             if (!_fileSystem.DirectoryExists(path))
             if (!_fileSystem.DirectoryExists(path))
             {
             {
-                throw new DirectoryNotFoundException("The media folder does not exist");
+                throw new FileNotFoundException("The media folder does not exist");
             }
             }
 
 
             _libraryMonitorFactory().Stop();
             _libraryMonitorFactory().Stop();
@@ -3044,10 +3041,12 @@ namespace MediaBrowser.Server.Implementations.Library
 
 
             if (!_fileSystem.DirectoryExists(virtualFolderPath))
             if (!_fileSystem.DirectoryExists(virtualFolderPath))
             {
             {
-                throw new DirectoryNotFoundException(string.Format("The media collection {0} does not exist", virtualFolderName));
+                throw new FileNotFoundException(string.Format("The media collection {0} does not exist", virtualFolderName));
             }
             }
 
 
-            var shortcut = Directory.EnumerateFiles(virtualFolderPath, ShortcutFileSearch, SearchOption.AllDirectories).FirstOrDefault(f => _fileSystem.ResolveShortcut(f).Equals(mediaPath, StringComparison.OrdinalIgnoreCase));
+            var shortcut = _fileSystem.GetFilePaths(virtualFolderPath, true)
+                .Where(i => string.Equals(ShortcutFileExtension, Path.GetExtension(i), StringComparison.OrdinalIgnoreCase))
+                .FirstOrDefault(f => _fileSystem.ResolveShortcut(f).Equals(mediaPath, StringComparison.OrdinalIgnoreCase));
 
 
             if (!string.IsNullOrEmpty(shortcut))
             if (!string.IsNullOrEmpty(shortcut))
             {
             {

+ 1 - 1
MediaBrowser.Server.Implementations/Library/LocalTrailerPostScanTask.cs → Emby.Server.Implementations/Library/LocalTrailerPostScanTask.cs

@@ -9,7 +9,7 @@ using System.Threading.Tasks;
 using MediaBrowser.Controller.Entities.Movies;
 using MediaBrowser.Controller.Entities.Movies;
 using MediaBrowser.Controller.Entities.TV;
 using MediaBrowser.Controller.Entities.TV;
 
 
-namespace MediaBrowser.Server.Implementations.Library
+namespace Emby.Server.Implementations.Library
 {
 {
     public class LocalTrailerPostScanTask : ILibraryPostScanTask
     public class LocalTrailerPostScanTask : ILibraryPostScanTask
     {
     {

+ 7 - 4
MediaBrowser.Server.Implementations/Library/MediaSourceManager.cs → Emby.Server.Implementations/Library/MediaSourceManager.cs

@@ -18,8 +18,9 @@ using MediaBrowser.Common.IO;
 using MediaBrowser.Controller.IO;
 using MediaBrowser.Controller.IO;
 using MediaBrowser.Model.IO;
 using MediaBrowser.Model.IO;
 using MediaBrowser.Model.Configuration;
 using MediaBrowser.Model.Configuration;
+using MediaBrowser.Model.Threading;
 
 
-namespace MediaBrowser.Server.Implementations.Library
+namespace Emby.Server.Implementations.Library
 {
 {
     public class MediaSourceManager : IMediaSourceManager, IDisposable
     public class MediaSourceManager : IMediaSourceManager, IDisposable
     {
     {
@@ -32,8 +33,9 @@ namespace MediaBrowser.Server.Implementations.Library
         private IMediaSourceProvider[] _providers;
         private IMediaSourceProvider[] _providers;
         private readonly ILogger _logger;
         private readonly ILogger _logger;
         private readonly IUserDataManager _userDataManager;
         private readonly IUserDataManager _userDataManager;
+        private readonly ITimerFactory _timerFactory;
 
 
-        public MediaSourceManager(IItemRepository itemRepo, IUserManager userManager, ILibraryManager libraryManager, ILogger logger, IJsonSerializer jsonSerializer, IFileSystem fileSystem, IUserDataManager userDataManager)
+        public MediaSourceManager(IItemRepository itemRepo, IUserManager userManager, ILibraryManager libraryManager, ILogger logger, IJsonSerializer jsonSerializer, IFileSystem fileSystem, IUserDataManager userDataManager, ITimerFactory timerFactory)
         {
         {
             _itemRepo = itemRepo;
             _itemRepo = itemRepo;
             _userManager = userManager;
             _userManager = userManager;
@@ -42,6 +44,7 @@ namespace MediaBrowser.Server.Implementations.Library
             _jsonSerializer = jsonSerializer;
             _jsonSerializer = jsonSerializer;
             _fileSystem = fileSystem;
             _fileSystem = fileSystem;
             _userDataManager = userDataManager;
             _userDataManager = userDataManager;
+            _timerFactory = timerFactory;
         }
         }
 
 
         public void AddParts(IEnumerable<IMediaSourceProvider> providers)
         public void AddParts(IEnumerable<IMediaSourceProvider> providers)
@@ -551,14 +554,14 @@ namespace MediaBrowser.Server.Implementations.Library
             return new Tuple<IMediaSourceProvider, string>(provider, keyId);
             return new Tuple<IMediaSourceProvider, string>(provider, keyId);
         }
         }
 
 
-        private Timer _closeTimer;
+        private ITimer _closeTimer;
         private readonly TimeSpan _openStreamMaxAge = TimeSpan.FromSeconds(180);
         private readonly TimeSpan _openStreamMaxAge = TimeSpan.FromSeconds(180);
 
 
         private void StartCloseTimer()
         private void StartCloseTimer()
         {
         {
             StopCloseTimer();
             StopCloseTimer();
 
 
-            _closeTimer = new Timer(CloseTimerCallback, null, _openStreamMaxAge, _openStreamMaxAge);
+            _closeTimer = _timerFactory.Create(CloseTimerCallback, null, _openStreamMaxAge, _openStreamMaxAge);
         }
         }
 
 
         private void StopCloseTimer()
         private void StopCloseTimer()

+ 1 - 1
MediaBrowser.Server.Implementations/Library/MusicManager.cs → Emby.Server.Implementations/Library/MusicManager.cs

@@ -6,7 +6,7 @@ using System;
 using System.Collections.Generic;
 using System.Collections.Generic;
 using System.Linq;
 using System.Linq;
 
 
-namespace MediaBrowser.Server.Implementations.Library
+namespace Emby.Server.Implementations.Library
 {
 {
     public class MusicManager : IMusicManager
     public class MusicManager : IMusicManager
     {
     {

+ 1 - 1
MediaBrowser.Server.Implementations/Library/PathExtensions.cs → Emby.Server.Implementations/Library/PathExtensions.cs

@@ -1,7 +1,7 @@
 using System;
 using System;
 using System.Text.RegularExpressions;
 using System.Text.RegularExpressions;
 
 
-namespace MediaBrowser.Server.Implementations.Library
+namespace Emby.Server.Implementations.Library
 {
 {
     public static class PathExtensions
     public static class PathExtensions
     {
     {

+ 2 - 2
MediaBrowser.Server.Implementations/Library/ResolverHelper.cs → Emby.Server.Implementations/Library/ResolverHelper.cs

@@ -9,7 +9,7 @@ using MediaBrowser.Common.IO;
 using MediaBrowser.Controller.IO;
 using MediaBrowser.Controller.IO;
 using MediaBrowser.Model.IO;
 using MediaBrowser.Model.IO;
 
 
-namespace MediaBrowser.Server.Implementations.Library
+namespace Emby.Server.Implementations.Library
 {
 {
     /// <summary>
     /// <summary>
     /// Class ResolverHelper
     /// Class ResolverHelper
@@ -112,7 +112,7 @@ namespace MediaBrowser.Server.Implementations.Library
         /// <summary>
         /// <summary>
         /// The MB name regex
         /// The MB name regex
         /// </summary>
         /// </summary>
-        private static readonly Regex MbNameRegex = new Regex(@"(\[.*?\])", RegexOptions.Compiled);
+        private static readonly Regex MbNameRegex = new Regex(@"(\[.*?\])");
 
 
         internal static string StripBrackets(string inputString)
         internal static string StripBrackets(string inputString)
         {
         {

+ 4 - 4
MediaBrowser.Server.Implementations/Library/Resolvers/Audio/AudioResolver.cs → Emby.Server.Implementations/Library/Resolvers/Audio/AudioResolver.cs

@@ -3,12 +3,12 @@ using MediaBrowser.Controller.Resolvers;
 using MediaBrowser.Model.Entities;
 using MediaBrowser.Model.Entities;
 using System;
 using System;
 
 
-namespace MediaBrowser.Server.Implementations.Library.Resolvers.Audio
+namespace Emby.Server.Implementations.Library.Resolvers.Audio
 {
 {
     /// <summary>
     /// <summary>
     /// Class AudioResolver
     /// Class AudioResolver
     /// </summary>
     /// </summary>
-    public class AudioResolver : ItemResolver<Controller.Entities.Audio.Audio>
+    public class AudioResolver : ItemResolver<MediaBrowser.Controller.Entities.Audio.Audio>
     {
     {
         private readonly ILibraryManager _libraryManager;
         private readonly ILibraryManager _libraryManager;
 
 
@@ -31,7 +31,7 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Audio
         /// </summary>
         /// </summary>
         /// <param name="args">The args.</param>
         /// <param name="args">The args.</param>
         /// <returns>Entities.Audio.Audio.</returns>
         /// <returns>Entities.Audio.Audio.</returns>
-        protected override Controller.Entities.Audio.Audio Resolve(ItemResolveArgs args)
+        protected override MediaBrowser.Controller.Entities.Audio.Audio Resolve(ItemResolveArgs args)
         {
         {
             // Return audio if the path is a file and has a matching extension
             // Return audio if the path is a file and has a matching extension
 
 
@@ -57,7 +57,7 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Audio
                         string.Equals(collectionType, CollectionType.Music, StringComparison.OrdinalIgnoreCase) ||
                         string.Equals(collectionType, CollectionType.Music, StringComparison.OrdinalIgnoreCase) ||
                         isMixed)
                         isMixed)
                     {
                     {
-                        return new Controller.Entities.Audio.Audio();
+                        return new MediaBrowser.Controller.Entities.Audio.Audio();
                     }
                     }
                 }
                 }
             }
             }

+ 2 - 2
MediaBrowser.Server.Implementations/Library/Resolvers/Audio/MusicAlbumResolver.cs → Emby.Server.Implementations/Library/Resolvers/Audio/MusicAlbumResolver.cs

@@ -5,17 +5,17 @@ using MediaBrowser.Controller.Resolvers;
 using MediaBrowser.Model.Entities;
 using MediaBrowser.Model.Entities;
 using MediaBrowser.Model.Logging;
 using MediaBrowser.Model.Logging;
 using MediaBrowser.Naming.Audio;
 using MediaBrowser.Naming.Audio;
-using MediaBrowser.Server.Implementations.Logging;
 using System;
 using System;
 using System.Collections.Generic;
 using System.Collections.Generic;
 using System.IO;
 using System.IO;
+using Emby.Server.Implementations.Logging;
 using MediaBrowser.Common.IO;
 using MediaBrowser.Common.IO;
 using MediaBrowser.Model.IO;
 using MediaBrowser.Model.IO;
 using MediaBrowser.Controller.Configuration;
 using MediaBrowser.Controller.Configuration;
 using MediaBrowser.Controller.IO;
 using MediaBrowser.Controller.IO;
 using MediaBrowser.Model.Configuration;
 using MediaBrowser.Model.Configuration;
 
 
-namespace MediaBrowser.Server.Implementations.Library.Resolvers.Audio
+namespace Emby.Server.Implementations.Library.Resolvers.Audio
 {
 {
     /// <summary>
     /// <summary>
     /// Class MusicAlbumResolver
     /// Class MusicAlbumResolver

+ 1 - 1
MediaBrowser.Server.Implementations/Library/Resolvers/Audio/MusicArtistResolver.cs → Emby.Server.Implementations/Library/Resolvers/Audio/MusicArtistResolver.cs

@@ -11,7 +11,7 @@ using MediaBrowser.Model.IO;
 using MediaBrowser.Controller.Configuration;
 using MediaBrowser.Controller.Configuration;
 using MediaBrowser.Controller.IO;
 using MediaBrowser.Controller.IO;
 
 
-namespace MediaBrowser.Server.Implementations.Library.Resolvers.Audio
+namespace Emby.Server.Implementations.Library.Resolvers.Audio
 {
 {
     /// <summary>
     /// <summary>
     /// Class MusicArtistResolver
     /// Class MusicArtistResolver

+ 4 - 4
MediaBrowser.Server.Implementations/Library/Resolvers/BaseVideoResolver.cs → Emby.Server.Implementations/Library/Resolvers/BaseVideoResolver.cs

@@ -2,17 +2,17 @@
 using MediaBrowser.Controller.Library;
 using MediaBrowser.Controller.Library;
 using MediaBrowser.Model.Entities;
 using MediaBrowser.Model.Entities;
 using MediaBrowser.Naming.Video;
 using MediaBrowser.Naming.Video;
-using MediaBrowser.Server.Implementations.Logging;
 using System;
 using System;
 using System.IO;
 using System.IO;
+using Emby.Server.Implementations.Logging;
 
 
-namespace MediaBrowser.Server.Implementations.Library.Resolvers
+namespace Emby.Server.Implementations.Library.Resolvers
 {
 {
     /// <summary>
     /// <summary>
     /// Resolves a Path into a Video or Video subclass
     /// Resolves a Path into a Video or Video subclass
     /// </summary>
     /// </summary>
     /// <typeparam name="T"></typeparam>
     /// <typeparam name="T"></typeparam>
-    public abstract class BaseVideoResolver<T> : Controller.Resolvers.ItemResolver<T>
+    public abstract class BaseVideoResolver<T> : MediaBrowser.Controller.Resolvers.ItemResolver<T>
         where T : Video, new()
         where T : Video, new()
     {
     {
         protected readonly ILibraryManager LibraryManager;
         protected readonly ILibraryManager LibraryManager;
@@ -45,7 +45,7 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers
             var namingOptions = ((LibraryManager)LibraryManager).GetNamingOptions();
             var namingOptions = ((LibraryManager)LibraryManager).GetNamingOptions();
             
             
             // If the path is a file check for a matching extensions
             // If the path is a file check for a matching extensions
-            var parser = new Naming.Video.VideoResolver(namingOptions, new PatternsLogger());
+            var parser = new MediaBrowser.Naming.Video.VideoResolver(namingOptions, new PatternsLogger());
 
 
             if (args.IsDirectory)
             if (args.IsDirectory)
             {
             {

+ 1 - 1
MediaBrowser.Server.Implementations/Library/Resolvers/FolderResolver.cs → Emby.Server.Implementations/Library/Resolvers/FolderResolver.cs

@@ -2,7 +2,7 @@
 using MediaBrowser.Controller.Library;
 using MediaBrowser.Controller.Library;
 using MediaBrowser.Controller.Resolvers;
 using MediaBrowser.Controller.Resolvers;
 
 
-namespace MediaBrowser.Server.Implementations.Library.Resolvers
+namespace Emby.Server.Implementations.Library.Resolvers
 {
 {
     /// <summary>
     /// <summary>
     /// Class FolderResolver
     /// Class FolderResolver

+ 1 - 1
MediaBrowser.Server.Implementations/Library/Resolvers/ItemResolver.cs → Emby.Server.Implementations/Library/Resolvers/ItemResolver.cs

@@ -2,7 +2,7 @@
 using MediaBrowser.Controller.Library;
 using MediaBrowser.Controller.Library;
 using MediaBrowser.Controller.Resolvers;
 using MediaBrowser.Controller.Resolvers;
 
 
-namespace MediaBrowser.Server.Implementations.Library.Resolvers
+namespace Emby.Server.Implementations.Library.Resolvers
 {
 {
     /// <summary>
     /// <summary>
     /// Class ItemResolver
     /// Class ItemResolver

+ 1 - 1
MediaBrowser.Server.Implementations/Library/Resolvers/Movies/BoxSetResolver.cs → Emby.Server.Implementations/Library/Resolvers/Movies/BoxSetResolver.cs

@@ -5,7 +5,7 @@ using MediaBrowser.Model.Entities;
 using System;
 using System;
 using System.IO;
 using System.IO;
 
 
-namespace MediaBrowser.Server.Implementations.Library.Resolvers.Movies
+namespace Emby.Server.Implementations.Library.Resolvers.Movies
 {
 {
     /// <summary>
     /// <summary>
     /// Class BoxSetResolver
     /// Class BoxSetResolver

+ 2 - 2
MediaBrowser.Server.Implementations/Library/Resolvers/Movies/MovieResolver.cs → Emby.Server.Implementations/Library/Resolvers/Movies/MovieResolver.cs

@@ -7,16 +7,16 @@ using MediaBrowser.Controller.Resolvers;
 using MediaBrowser.Model.Entities;
 using MediaBrowser.Model.Entities;
 using MediaBrowser.Model.Extensions;
 using MediaBrowser.Model.Extensions;
 using MediaBrowser.Naming.Video;
 using MediaBrowser.Naming.Video;
-using MediaBrowser.Server.Implementations.Logging;
 using System;
 using System;
 using System.Collections.Generic;
 using System.Collections.Generic;
 using System.IO;
 using System.IO;
 using System.Linq;
 using System.Linq;
+using Emby.Server.Implementations.Logging;
 using MediaBrowser.Common.IO;
 using MediaBrowser.Common.IO;
 using MediaBrowser.Controller.IO;
 using MediaBrowser.Controller.IO;
 using MediaBrowser.Model.IO;
 using MediaBrowser.Model.IO;
 
 
-namespace MediaBrowser.Server.Implementations.Library.Resolvers.Movies
+namespace Emby.Server.Implementations.Library.Resolvers.Movies
 {
 {
     /// <summary>
     /// <summary>
     /// Class MovieResolver
     /// Class MovieResolver

+ 1 - 1
MediaBrowser.Server.Implementations/Library/Resolvers/PhotoAlbumResolver.cs → Emby.Server.Implementations/Library/Resolvers/PhotoAlbumResolver.cs

@@ -7,7 +7,7 @@ using System;
 using System.IO;
 using System.IO;
 using System.Linq;
 using System.Linq;
 
 
-namespace MediaBrowser.Server.Implementations.Library.Resolvers
+namespace Emby.Server.Implementations.Library.Resolvers
 {
 {
     public class PhotoAlbumResolver : FolderResolver<PhotoAlbum>
     public class PhotoAlbumResolver : FolderResolver<PhotoAlbum>
     {
     {

+ 1 - 1
MediaBrowser.Server.Implementations/Library/Resolvers/PhotoResolver.cs → Emby.Server.Implementations/Library/Resolvers/PhotoResolver.cs

@@ -11,7 +11,7 @@ using MediaBrowser.Controller.Configuration;
 using MediaBrowser.Controller.IO;
 using MediaBrowser.Controller.IO;
 using MediaBrowser.Model.Configuration;
 using MediaBrowser.Model.Configuration;
 
 
-namespace MediaBrowser.Server.Implementations.Library.Resolvers
+namespace Emby.Server.Implementations.Library.Resolvers
 {
 {
     public class PhotoResolver : ItemResolver<Photo>
     public class PhotoResolver : ItemResolver<Photo>
     {
     {

+ 1 - 1
MediaBrowser.Server.Implementations/Library/Resolvers/PlaylistResolver.cs → Emby.Server.Implementations/Library/Resolvers/PlaylistResolver.cs

@@ -3,7 +3,7 @@ using MediaBrowser.Controller.Playlists;
 using System;
 using System;
 using System.IO;
 using System.IO;
 
 
-namespace MediaBrowser.Server.Implementations.Library.Resolvers
+namespace Emby.Server.Implementations.Library.Resolvers
 {
 {
     public class PlaylistResolver : FolderResolver<Playlist>
     public class PlaylistResolver : FolderResolver<Playlist>
     {
     {

+ 1 - 1
MediaBrowser.Server.Implementations/Library/Resolvers/SpecialFolderResolver.cs → Emby.Server.Implementations/Library/Resolvers/SpecialFolderResolver.cs

@@ -9,7 +9,7 @@ using MediaBrowser.Common.IO;
 using MediaBrowser.Controller.IO;
 using MediaBrowser.Controller.IO;
 using MediaBrowser.Model.IO;
 using MediaBrowser.Model.IO;
 
 
-namespace MediaBrowser.Server.Implementations.Library.Resolvers
+namespace Emby.Server.Implementations.Library.Resolvers
 {
 {
     class SpecialFolderResolver : FolderResolver<Folder>
     class SpecialFolderResolver : FolderResolver<Folder>
     {
     {

+ 1 - 1
MediaBrowser.Server.Implementations/Library/Resolvers/TV/EpisodeResolver.cs → Emby.Server.Implementations/Library/Resolvers/TV/EpisodeResolver.cs

@@ -4,7 +4,7 @@ using MediaBrowser.Controller.Library;
 using System.Linq;
 using System.Linq;
 using MediaBrowser.Model.Entities;
 using MediaBrowser.Model.Entities;
 
 
-namespace MediaBrowser.Server.Implementations.Library.Resolvers.TV
+namespace Emby.Server.Implementations.Library.Resolvers.TV
 {
 {
     /// <summary>
     /// <summary>
     /// Class EpisodeResolver
     /// Class EpisodeResolver

+ 1 - 1
MediaBrowser.Server.Implementations/Library/Resolvers/TV/SeasonResolver.cs → Emby.Server.Implementations/Library/Resolvers/TV/SeasonResolver.cs

@@ -4,7 +4,7 @@ using MediaBrowser.Controller.Library;
 using MediaBrowser.Naming.Common;
 using MediaBrowser.Naming.Common;
 using MediaBrowser.Naming.TV;
 using MediaBrowser.Naming.TV;
 
 
-namespace MediaBrowser.Server.Implementations.Library.Resolvers.TV
+namespace Emby.Server.Implementations.Library.Resolvers.TV
 {
 {
     /// <summary>
     /// <summary>
     /// Class SeasonResolver
     /// Class SeasonResolver

+ 3 - 3
MediaBrowser.Server.Implementations/Library/Resolvers/TV/SeriesResolver.cs → Emby.Server.Implementations/Library/Resolvers/TV/SeriesResolver.cs

@@ -6,18 +6,18 @@ using MediaBrowser.Model.Entities;
 using MediaBrowser.Model.Logging;
 using MediaBrowser.Model.Logging;
 using MediaBrowser.Naming.Common;
 using MediaBrowser.Naming.Common;
 using MediaBrowser.Naming.TV;
 using MediaBrowser.Naming.TV;
-using MediaBrowser.Server.Implementations.Logging;
 using System;
 using System;
 using System.Collections.Generic;
 using System.Collections.Generic;
 using System.IO;
 using System.IO;
 using System.Linq;
 using System.Linq;
+using Emby.Server.Implementations.Logging;
 using MediaBrowser.Common.IO;
 using MediaBrowser.Common.IO;
 using MediaBrowser.Model.IO;
 using MediaBrowser.Model.IO;
 using MediaBrowser.Controller.Configuration;
 using MediaBrowser.Controller.Configuration;
 using MediaBrowser.Controller.IO;
 using MediaBrowser.Controller.IO;
 using MediaBrowser.Model.Configuration;
 using MediaBrowser.Model.Configuration;
 
 
-namespace MediaBrowser.Server.Implementations.Library.Resolvers.TV
+namespace Emby.Server.Implementations.Library.Resolvers.TV
 {
 {
     /// <summary>
     /// <summary>
     /// Class SeriesResolver
     /// Class SeriesResolver
@@ -171,7 +171,7 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.TV
                                 .ToList();
                                 .ToList();
                         }
                         }
 
 
-                        var episodeResolver = new Naming.TV.EpisodeResolver(namingOptions, new PatternsLogger());
+                        var episodeResolver = new MediaBrowser.Naming.TV.EpisodeResolver(namingOptions, new PatternsLogger());
                         var episodeInfo = episodeResolver.Resolve(fullName, false, false);
                         var episodeInfo = episodeResolver.Resolve(fullName, false, false);
                         if (episodeInfo != null && episodeInfo.EpisodeNumber.HasValue)
                         if (episodeInfo != null && episodeInfo.EpisodeNumber.HasValue)
                         {
                         {

+ 1 - 1
MediaBrowser.Server.Implementations/Library/Resolvers/VideoResolver.cs → Emby.Server.Implementations/Library/Resolvers/VideoResolver.cs

@@ -2,7 +2,7 @@
 using MediaBrowser.Controller.Library;
 using MediaBrowser.Controller.Library;
 using MediaBrowser.Controller.Resolvers;
 using MediaBrowser.Controller.Resolvers;
 
 
-namespace MediaBrowser.Server.Implementations.Library.Resolvers
+namespace Emby.Server.Implementations.Library.Resolvers
 {
 {
     /// <summary>
     /// <summary>
     /// Resolves a Path into a Video
     /// Resolves a Path into a Video

+ 2 - 7
MediaBrowser.Server.Implementations/Library/SearchEngine.cs → Emby.Server.Implementations/Library/SearchEngine.cs

@@ -1,7 +1,5 @@
-using MediaBrowser.Common.Extensions;
-using MediaBrowser.Controller.Entities;
+using MediaBrowser.Controller.Entities;
 using MediaBrowser.Controller.Entities.Audio;
 using MediaBrowser.Controller.Entities.Audio;
-using MediaBrowser.Controller.Entities.TV;
 using MediaBrowser.Controller.Library;
 using MediaBrowser.Controller.Library;
 using MediaBrowser.Model.Logging;
 using MediaBrowser.Model.Logging;
 using MediaBrowser.Model.Querying;
 using MediaBrowser.Model.Querying;
@@ -11,13 +9,10 @@ using System.Collections.Generic;
 using System.Linq;
 using System.Linq;
 using System.Threading.Tasks;
 using System.Threading.Tasks;
 using MediaBrowser.Controller.Extensions;
 using MediaBrowser.Controller.Extensions;
-using MediaBrowser.Model.Extensions;
 
 
-namespace MediaBrowser.Server.Implementations.Library
+namespace Emby.Server.Implementations.Library
 {
 {
     /// <summary>
     /// <summary>
-    /// Class LuceneSearchEngine
-    /// http://www.codeproject.com/Articles/320219/Lucene-Net-ultra-fast-search-for-MVC-or-WebForms
     /// </summary>
     /// </summary>
     public class SearchEngine : ISearchEngine
     public class SearchEngine : ISearchEngine
     {
     {

+ 1 - 1
MediaBrowser.Server.Implementations/Library/UserDataManager.cs → Emby.Server.Implementations/Library/UserDataManager.cs

@@ -13,7 +13,7 @@ using System.Collections.Generic;
 using System.Threading;
 using System.Threading;
 using System.Threading.Tasks;
 using System.Threading.Tasks;
 
 
-namespace MediaBrowser.Server.Implementations.Library
+namespace Emby.Server.Implementations.Library
 {
 {
     /// <summary>
     /// <summary>
     /// Class UserDataManager
     /// Class UserDataManager

+ 31 - 23
MediaBrowser.Server.Implementations/Library/UserManager.cs → Emby.Server.Implementations/Library/UserManager.cs

@@ -23,15 +23,13 @@ using System.Collections.Generic;
 using System.Globalization;
 using System.Globalization;
 using System.IO;
 using System.IO;
 using System.Linq;
 using System.Linq;
-using System.Security.Cryptography;
 using System.Text;
 using System.Text;
 using System.Threading;
 using System.Threading;
 using System.Threading.Tasks;
 using System.Threading.Tasks;
-using MediaBrowser.Common.IO;
-using MediaBrowser.Controller.IO;
+using MediaBrowser.Model.Cryptography;
 using MediaBrowser.Model.IO;
 using MediaBrowser.Model.IO;
 
 
-namespace MediaBrowser.Server.Implementations.Library
+namespace Emby.Server.Implementations.Library
 {
 {
     /// <summary>
     /// <summary>
     /// Class UserManager
     /// Class UserManager
@@ -72,8 +70,10 @@ namespace MediaBrowser.Server.Implementations.Library
         private readonly Func<IConnectManager> _connectFactory;
         private readonly Func<IConnectManager> _connectFactory;
         private readonly IServerApplicationHost _appHost;
         private readonly IServerApplicationHost _appHost;
         private readonly IFileSystem _fileSystem;
         private readonly IFileSystem _fileSystem;
+        private readonly ICryptographyProvider _cryptographyProvider;
+        private readonly string _defaultUserName;
 
 
-        public UserManager(ILogger logger, IServerConfigurationManager configurationManager, IUserRepository userRepository, IXmlSerializer xmlSerializer, INetworkManager networkManager, Func<IImageProcessor> imageProcessorFactory, Func<IDtoService> dtoServiceFactory, Func<IConnectManager> connectFactory, IServerApplicationHost appHost, IJsonSerializer jsonSerializer, IFileSystem fileSystem)
+        public UserManager(ILogger logger, IServerConfigurationManager configurationManager, IUserRepository userRepository, IXmlSerializer xmlSerializer, INetworkManager networkManager, Func<IImageProcessor> imageProcessorFactory, Func<IDtoService> dtoServiceFactory, Func<IConnectManager> connectFactory, IServerApplicationHost appHost, IJsonSerializer jsonSerializer, IFileSystem fileSystem, ICryptographyProvider cryptographyProvider, string defaultUserName)
         {
         {
             _logger = logger;
             _logger = logger;
             UserRepository = userRepository;
             UserRepository = userRepository;
@@ -85,6 +85,8 @@ namespace MediaBrowser.Server.Implementations.Library
             _appHost = appHost;
             _appHost = appHost;
             _jsonSerializer = jsonSerializer;
             _jsonSerializer = jsonSerializer;
             _fileSystem = fileSystem;
             _fileSystem = fileSystem;
+            _cryptographyProvider = cryptographyProvider;
+            _defaultUserName = defaultUserName;
             ConfigurationManager = configurationManager;
             ConfigurationManager = configurationManager;
             Users = new List<User>();
             Users = new List<User>();
 
 
@@ -188,7 +190,14 @@ namespace MediaBrowser.Server.Implementations.Library
         public bool IsValidUsername(string username)
         public bool IsValidUsername(string username)
         {
         {
             // Usernames can contain letters (a-z), numbers (0-9), dashes (-), underscores (_), apostrophes ('), and periods (.)
             // Usernames can contain letters (a-z), numbers (0-9), dashes (-), underscores (_), apostrophes ('), and periods (.)
-            return username.All(IsValidUsernameCharacter);
+            foreach (var currentChar in username)
+            {
+                if (!IsValidUsernameCharacter(currentChar))
+                {
+                    return false;
+                }
+            }
+            return true;
         }
         }
 
 
         private bool IsValidUsernameCharacter(char i)
         private bool IsValidUsernameCharacter(char i)
@@ -273,8 +282,8 @@ namespace MediaBrowser.Server.Implementations.Library
             {
             {
                 user.Policy.InvalidLoginAttemptCount = newValue;
                 user.Policy.InvalidLoginAttemptCount = newValue;
 
 
-                var maxCount = user.Policy.IsAdministrator ? 
-                    3 : 
+                var maxCount = user.Policy.IsAdministrator ?
+                    3 :
                     5;
                     5;
 
 
                 var fireLockout = false;
                 var fireLockout = false;
@@ -323,13 +332,9 @@ namespace MediaBrowser.Server.Implementations.Library
         /// </summary>
         /// </summary>
         /// <param name="str">The STR.</param>
         /// <param name="str">The STR.</param>
         /// <returns>System.String.</returns>
         /// <returns>System.String.</returns>
-        private static string GetSha1String(string str)
+        private string GetSha1String(string str)
         {
         {
-            using (var provider = SHA1.Create())
-            {
-                var hash = provider.ComputeHash(Encoding.UTF8.GetBytes(str));
-                return BitConverter.ToString(hash).Replace("-", string.Empty);
-            }
+            return BitConverter.ToString(_cryptographyProvider.GetSHA1Bytes(Encoding.UTF8.GetBytes(str))).Replace("-", string.Empty);
         }
         }
 
 
         /// <summary>
         /// <summary>
@@ -343,7 +348,7 @@ namespace MediaBrowser.Server.Implementations.Library
             // There always has to be at least one user.
             // There always has to be at least one user.
             if (users.Count == 0)
             if (users.Count == 0)
             {
             {
-                var name = MakeValidUsername(Environment.UserName);
+                var name = MakeValidUsername(_defaultUserName);
 
 
                 var user = InstantiateNewUser(name);
                 var user = InstantiateNewUser(name);
 
 
@@ -741,9 +746,12 @@ namespace MediaBrowser.Server.Implementations.Library
             text.AppendLine(string.Empty);
             text.AppendLine(string.Empty);
             text.AppendLine(pin);
             text.AppendLine(pin);
             text.AppendLine(string.Empty);
             text.AppendLine(string.Empty);
-            text.AppendLine("The pin code will expire at " + expiration.ToLocalTime().ToShortDateString() + " " + expiration.ToLocalTime().ToShortTimeString());
 
 
-			_fileSystem.WriteAllText(path, text.ToString(), Encoding.UTF8);
+            var localExpirationTime = expiration.ToLocalTime();
+            // Tuesday, 22 August 2006 06:30 AM
+            text.AppendLine("The pin code will expire at " + localExpirationTime.ToString("f1", CultureInfo.CurrentCulture));
+
+            _fileSystem.WriteAllText(path, text.ToString(), Encoding.UTF8);
 
 
             var result = new PasswordPinCreationResult
             var result = new PasswordPinCreationResult
             {
             {
@@ -875,11 +883,11 @@ namespace MediaBrowser.Server.Implementations.Library
                     return (UserPolicy)_xmlSerializer.DeserializeFromFile(typeof(UserPolicy), path);
                     return (UserPolicy)_xmlSerializer.DeserializeFromFile(typeof(UserPolicy), path);
                 }
                 }
             }
             }
-            catch (DirectoryNotFoundException)
+            catch (FileNotFoundException)
             {
             {
                 return GetDefaultPolicy(user);
                 return GetDefaultPolicy(user);
             }
             }
-            catch (FileNotFoundException)
+            catch (IOException)
             {
             {
                 return GetDefaultPolicy(user);
                 return GetDefaultPolicy(user);
             }
             }
@@ -917,7 +925,7 @@ namespace MediaBrowser.Server.Implementations.Library
 
 
             var path = GetPolifyFilePath(user);
             var path = GetPolifyFilePath(user);
 
 
-			_fileSystem.CreateDirectory(Path.GetDirectoryName(path));
+            _fileSystem.CreateDirectory(Path.GetDirectoryName(path));
 
 
             lock (_policySyncLock)
             lock (_policySyncLock)
             {
             {
@@ -970,11 +978,11 @@ namespace MediaBrowser.Server.Implementations.Library
                     return (UserConfiguration)_xmlSerializer.DeserializeFromFile(typeof(UserConfiguration), path);
                     return (UserConfiguration)_xmlSerializer.DeserializeFromFile(typeof(UserConfiguration), path);
                 }
                 }
             }
             }
-            catch (DirectoryNotFoundException)
+            catch (FileNotFoundException)
             {
             {
                 return new UserConfiguration();
                 return new UserConfiguration();
             }
             }
-            catch (FileNotFoundException)
+            catch (IOException)
             {
             {
                 return new UserConfiguration();
                 return new UserConfiguration();
             }
             }
@@ -1004,7 +1012,7 @@ namespace MediaBrowser.Server.Implementations.Library
                 config = _jsonSerializer.DeserializeFromString<UserConfiguration>(json);
                 config = _jsonSerializer.DeserializeFromString<UserConfiguration>(json);
             }
             }
 
 
-			_fileSystem.CreateDirectory(Path.GetDirectoryName(path));
+            _fileSystem.CreateDirectory(Path.GetDirectoryName(path));
 
 
             lock (_configSyncLock)
             lock (_configSyncLock)
             {
             {

+ 1 - 1
MediaBrowser.Server.Implementations/Library/UserViewManager.cs → Emby.Server.Implementations/Library/UserViewManager.cs

@@ -15,7 +15,7 @@ using System.Threading.Tasks;
 using MediaBrowser.Controller.Entities.Audio;
 using MediaBrowser.Controller.Entities.Audio;
 using MediaBrowser.Model.Globalization;
 using MediaBrowser.Model.Globalization;
 
 
-namespace MediaBrowser.Server.Implementations.Library
+namespace Emby.Server.Implementations.Library
 {
 {
     public class UserViewManager : IUserViewManager
     public class UserViewManager : IUserViewManager
     {
     {

+ 1 - 1
MediaBrowser.Server.Implementations/Library/Validators/ArtistsPostScanTask.cs → Emby.Server.Implementations/Library/Validators/ArtistsPostScanTask.cs

@@ -5,7 +5,7 @@ using System.Threading;
 using System.Threading.Tasks;
 using System.Threading.Tasks;
 using MediaBrowser.Controller.Persistence;
 using MediaBrowser.Controller.Persistence;
 
 
-namespace MediaBrowser.Server.Implementations.Library.Validators
+namespace Emby.Server.Implementations.Library.Validators
 {
 {
     /// <summary>
     /// <summary>
     /// Class ArtistsPostScanTask
     /// Class ArtistsPostScanTask

+ 1 - 1
MediaBrowser.Server.Implementations/Library/Validators/ArtistsValidator.cs → Emby.Server.Implementations/Library/Validators/ArtistsValidator.cs

@@ -9,7 +9,7 @@ using System.Threading.Tasks;
 using MediaBrowser.Controller.Entities;
 using MediaBrowser.Controller.Entities;
 using MediaBrowser.Controller.Persistence;
 using MediaBrowser.Controller.Persistence;
 
 
-namespace MediaBrowser.Server.Implementations.Library.Validators
+namespace Emby.Server.Implementations.Library.Validators
 {
 {
     /// <summary>
     /// <summary>
     /// Class ArtistsValidator
     /// Class ArtistsValidator

+ 1 - 1
MediaBrowser.Server.Implementations/Library/Validators/GameGenresPostScanTask.cs → Emby.Server.Implementations/Library/Validators/GameGenresPostScanTask.cs

@@ -5,7 +5,7 @@ using System.Threading;
 using System.Threading.Tasks;
 using System.Threading.Tasks;
 using MediaBrowser.Controller.Persistence;
 using MediaBrowser.Controller.Persistence;
 
 
-namespace MediaBrowser.Server.Implementations.Library.Validators
+namespace Emby.Server.Implementations.Library.Validators
 {
 {
     /// <summary>
     /// <summary>
     /// Class GameGenresPostScanTask
     /// Class GameGenresPostScanTask

+ 1 - 1
MediaBrowser.Server.Implementations/Library/Validators/GameGenresValidator.cs → Emby.Server.Implementations/Library/Validators/GameGenresValidator.cs

@@ -7,7 +7,7 @@ using System.Threading;
 using System.Threading.Tasks;
 using System.Threading.Tasks;
 using MediaBrowser.Controller.Persistence;
 using MediaBrowser.Controller.Persistence;
 
 
-namespace MediaBrowser.Server.Implementations.Library.Validators
+namespace Emby.Server.Implementations.Library.Validators
 {
 {
     class GameGenresValidator
     class GameGenresValidator
     {
     {

+ 1 - 1
MediaBrowser.Server.Implementations/Library/Validators/GenresPostScanTask.cs → Emby.Server.Implementations/Library/Validators/GenresPostScanTask.cs

@@ -5,7 +5,7 @@ using System.Threading.Tasks;
 using MediaBrowser.Controller.Persistence;
 using MediaBrowser.Controller.Persistence;
 using MediaBrowser.Model.Logging;
 using MediaBrowser.Model.Logging;
 
 
-namespace MediaBrowser.Server.Implementations.Library.Validators
+namespace Emby.Server.Implementations.Library.Validators
 {
 {
     public class GenresPostScanTask : ILibraryPostScanTask
     public class GenresPostScanTask : ILibraryPostScanTask
     {
     {

+ 1 - 1
MediaBrowser.Server.Implementations/Library/Validators/GenresValidator.cs → Emby.Server.Implementations/Library/Validators/GenresValidator.cs

@@ -8,7 +8,7 @@ using System.Threading;
 using System.Threading.Tasks;
 using System.Threading.Tasks;
 using MediaBrowser.Controller.Persistence;
 using MediaBrowser.Controller.Persistence;
 
 
-namespace MediaBrowser.Server.Implementations.Library.Validators
+namespace Emby.Server.Implementations.Library.Validators
 {
 {
     class GenresValidator
     class GenresValidator
     {
     {

+ 1 - 1
MediaBrowser.Server.Implementations/Library/Validators/MusicGenresPostScanTask.cs → Emby.Server.Implementations/Library/Validators/MusicGenresPostScanTask.cs

@@ -5,7 +5,7 @@ using System.Threading;
 using System.Threading.Tasks;
 using System.Threading.Tasks;
 using MediaBrowser.Controller.Persistence;
 using MediaBrowser.Controller.Persistence;
 
 
-namespace MediaBrowser.Server.Implementations.Library.Validators
+namespace Emby.Server.Implementations.Library.Validators
 {
 {
     /// <summary>
     /// <summary>
     /// Class MusicGenresPostScanTask
     /// Class MusicGenresPostScanTask

+ 1 - 1
MediaBrowser.Server.Implementations/Library/Validators/MusicGenresValidator.cs → Emby.Server.Implementations/Library/Validators/MusicGenresValidator.cs

@@ -8,7 +8,7 @@ using System.Threading.Tasks;
 using MediaBrowser.Controller.Entities;
 using MediaBrowser.Controller.Entities;
 using MediaBrowser.Controller.Persistence;
 using MediaBrowser.Controller.Persistence;
 
 
-namespace MediaBrowser.Server.Implementations.Library.Validators
+namespace Emby.Server.Implementations.Library.Validators
 {
 {
     class MusicGenresValidator
     class MusicGenresValidator
     {
     {

+ 1 - 1
MediaBrowser.Server.Implementations/Library/Validators/PeopleValidator.cs → Emby.Server.Implementations/Library/Validators/PeopleValidator.cs

@@ -15,7 +15,7 @@ using MediaBrowser.Common.IO;
 using MediaBrowser.Controller.IO;
 using MediaBrowser.Controller.IO;
 using MediaBrowser.Model.IO;
 using MediaBrowser.Model.IO;
 
 
-namespace MediaBrowser.Server.Implementations.Library.Validators
+namespace Emby.Server.Implementations.Library.Validators
 {
 {
     /// <summary>
     /// <summary>
     /// Class PeopleValidator
     /// Class PeopleValidator

+ 1 - 1
MediaBrowser.Server.Implementations/Library/Validators/StudiosPostScanTask.cs → Emby.Server.Implementations/Library/Validators/StudiosPostScanTask.cs

@@ -5,7 +5,7 @@ using System.Threading;
 using System.Threading.Tasks;
 using System.Threading.Tasks;
 using MediaBrowser.Controller.Persistence;
 using MediaBrowser.Controller.Persistence;
 
 
-namespace MediaBrowser.Server.Implementations.Library.Validators
+namespace Emby.Server.Implementations.Library.Validators
 {
 {
     /// <summary>
     /// <summary>
     /// Class MusicGenresPostScanTask
     /// Class MusicGenresPostScanTask

+ 1 - 1
MediaBrowser.Server.Implementations/Library/Validators/StudiosValidator.cs → Emby.Server.Implementations/Library/Validators/StudiosValidator.cs

@@ -7,7 +7,7 @@ using System.Threading.Tasks;
 using MediaBrowser.Controller.Entities;
 using MediaBrowser.Controller.Entities;
 using MediaBrowser.Controller.Persistence;
 using MediaBrowser.Controller.Persistence;
 
 
-namespace MediaBrowser.Server.Implementations.Library.Validators
+namespace Emby.Server.Implementations.Library.Validators
 {
 {
     class StudiosValidator
     class StudiosValidator
     {
     {

+ 1 - 1
MediaBrowser.Server.Implementations/Library/Validators/YearsPostScanTask.cs → Emby.Server.Implementations/Library/Validators/YearsPostScanTask.cs

@@ -4,7 +4,7 @@ using System;
 using System.Threading;
 using System.Threading;
 using System.Threading.Tasks;
 using System.Threading.Tasks;
 
 
-namespace MediaBrowser.Server.Implementations.Library.Validators
+namespace Emby.Server.Implementations.Library.Validators
 {
 {
     public class YearsPostScanTask : ILibraryPostScanTask
     public class YearsPostScanTask : ILibraryPostScanTask
     {
     {

+ 1 - 1
MediaBrowser.Server.Implementations/LiveTv/ChannelImageProvider.cs → Emby.Server.Implementations/LiveTv/ChannelImageProvider.cs

@@ -11,7 +11,7 @@ using System.Linq;
 using System.Threading;
 using System.Threading;
 using System.Threading.Tasks;
 using System.Threading.Tasks;
 
 
-namespace MediaBrowser.Server.Implementations.LiveTv
+namespace Emby.Server.Implementations.LiveTv
 {
 {
     public class ChannelImageProvider : IDynamicImageProvider, IHasItemChangeMonitor
     public class ChannelImageProvider : IDynamicImageProvider, IHasItemChangeMonitor
     {
     {

+ 1 - 1
MediaBrowser.Server.Implementations/LiveTv/EmbyTV/DirectRecorder.cs → Emby.Server.Implementations/LiveTv/EmbyTV/DirectRecorder.cs

@@ -9,7 +9,7 @@ using MediaBrowser.Controller.IO;
 using MediaBrowser.Model.Dto;
 using MediaBrowser.Model.Dto;
 using MediaBrowser.Model.Logging;
 using MediaBrowser.Model.Logging;
 
 
-namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
+namespace Emby.Server.Implementations.LiveTv.EmbyTV
 {
 {
     public class DirectRecorder : IRecorder
     public class DirectRecorder : IRecorder
     {
     {

+ 50 - 54
MediaBrowser.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs → Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs

@@ -15,7 +15,6 @@ using MediaBrowser.Model.Events;
 using MediaBrowser.Model.LiveTv;
 using MediaBrowser.Model.LiveTv;
 using MediaBrowser.Model.Logging;
 using MediaBrowser.Model.Logging;
 using MediaBrowser.Model.Serialization;
 using MediaBrowser.Model.Serialization;
-using MediaBrowser.Server.Implementations.FileOrganization;
 using System;
 using System;
 using System.Collections.Concurrent;
 using System.Collections.Concurrent;
 using System.Collections.Generic;
 using System.Collections.Generic;
@@ -35,10 +34,12 @@ using MediaBrowser.Controller.Entities;
 using MediaBrowser.Controller.Entities.TV;
 using MediaBrowser.Controller.Entities.TV;
 using MediaBrowser.Controller.IO;
 using MediaBrowser.Controller.IO;
 using MediaBrowser.Model.Configuration;
 using MediaBrowser.Model.Configuration;
+using MediaBrowser.Model.Diagnostics;
 using MediaBrowser.Model.FileOrganization;
 using MediaBrowser.Model.FileOrganization;
-using Microsoft.Win32;
+using MediaBrowser.Model.System;
+using MediaBrowser.Model.Threading;
 
 
-namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
+namespace Emby.Server.Implementations.LiveTv.EmbyTV
 {
 {
     public class EmbyTV : ILiveTvService, ISupportsDirectStreamProvider, ISupportsNewTimerIds, IDisposable
     public class EmbyTV : ILiveTvService, ISupportsDirectStreamProvider, ISupportsNewTimerIds, IDisposable
     {
     {
@@ -59,6 +60,8 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
         private readonly IProviderManager _providerManager;
         private readonly IProviderManager _providerManager;
         private readonly IFileOrganizationService _organizationService;
         private readonly IFileOrganizationService _organizationService;
         private readonly IMediaEncoder _mediaEncoder;
         private readonly IMediaEncoder _mediaEncoder;
+        private readonly IProcessFactory _processFactory;
+        private readonly ISystemEvents _systemEvents;
 
 
         public static EmbyTV Current;
         public static EmbyTV Current;
 
 
@@ -68,7 +71,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
         private readonly ConcurrentDictionary<string, ActiveRecordingInfo> _activeRecordings =
         private readonly ConcurrentDictionary<string, ActiveRecordingInfo> _activeRecordings =
             new ConcurrentDictionary<string, ActiveRecordingInfo>(StringComparer.OrdinalIgnoreCase);
             new ConcurrentDictionary<string, ActiveRecordingInfo>(StringComparer.OrdinalIgnoreCase);
 
 
-        public EmbyTV(IServerApplicationHost appHost, ILogger logger, IJsonSerializer jsonSerializer, IHttpClient httpClient, IServerConfigurationManager config, ILiveTvManager liveTvManager, IFileSystem fileSystem, ILibraryManager libraryManager, ILibraryMonitor libraryMonitor, IProviderManager providerManager, IFileOrganizationService organizationService, IMediaEncoder mediaEncoder)
+        public EmbyTV(IServerApplicationHost appHost, ILogger logger, IJsonSerializer jsonSerializer, IHttpClient httpClient, IServerConfigurationManager config, ILiveTvManager liveTvManager, IFileSystem fileSystem, ILibraryManager libraryManager, ILibraryMonitor libraryMonitor, IProviderManager providerManager, IFileOrganizationService organizationService, IMediaEncoder mediaEncoder, ITimerFactory timerFactory, IProcessFactory processFactory, ISystemEvents systemEvents)
         {
         {
             Current = this;
             Current = this;
 
 
@@ -82,11 +85,13 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
             _providerManager = providerManager;
             _providerManager = providerManager;
             _organizationService = organizationService;
             _organizationService = organizationService;
             _mediaEncoder = mediaEncoder;
             _mediaEncoder = mediaEncoder;
+            _processFactory = processFactory;
+            _systemEvents = systemEvents;
             _liveTvManager = (LiveTvManager)liveTvManager;
             _liveTvManager = (LiveTvManager)liveTvManager;
             _jsonSerializer = jsonSerializer;
             _jsonSerializer = jsonSerializer;
 
 
             _seriesTimerProvider = new SeriesTimerManager(fileSystem, jsonSerializer, _logger, Path.Combine(DataPath, "seriestimers"));
             _seriesTimerProvider = new SeriesTimerManager(fileSystem, jsonSerializer, _logger, Path.Combine(DataPath, "seriestimers"));
-            _timerProvider = new TimerManager(fileSystem, jsonSerializer, _logger, Path.Combine(DataPath, "timers"), _logger);
+            _timerProvider = new TimerManager(fileSystem, jsonSerializer, _logger, Path.Combine(DataPath, "timers"), _logger, timerFactory);
             _timerProvider.TimerFired += _timerProvider_TimerFired;
             _timerProvider.TimerFired += _timerProvider_TimerFired;
 
 
             _config.NamedConfigurationUpdated += _config_NamedConfigurationUpdated;
             _config.NamedConfigurationUpdated += _config_NamedConfigurationUpdated;
@@ -104,10 +109,15 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
         {
         {
             _timerProvider.RestartTimers();
             _timerProvider.RestartTimers();
 
 
-            SystemEvents.PowerModeChanged += SystemEvents_PowerModeChanged;
+            _systemEvents.Resume += _systemEvents_Resume;
             CreateRecordingFolders();
             CreateRecordingFolders();
         }
         }
 
 
+        private void _systemEvents_Resume(object sender, EventArgs e)
+        {
+            _timerProvider.RestartTimers();
+        }
+
         private void OnRecordingFoldersChanged()
         private void OnRecordingFoldersChanged()
         {
         {
             CreateRecordingFolders();
             CreateRecordingFolders();
@@ -231,16 +241,6 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
             }
             }
         }
         }
 
 
-        void SystemEvents_PowerModeChanged(object sender, PowerModeChangedEventArgs e)
-        {
-            _logger.Info("Power mode changed to {0}", e.Mode);
-
-            if (e.Mode == PowerModes.Resume)
-            {
-                _timerProvider.RestartTimers();
-            }
-        }
-
         public string Name
         public string Name
         {
         {
             get { return "Emby"; }
             get { return "Emby"; }
@@ -988,7 +988,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
                 _liveStreamsSemaphore.Release();
                 _liveStreamsSemaphore.Release();
             }
             }
 
 
-            throw new ApplicationException("Tuner not found.");
+            throw new Exception("Tuner not found.");
         }
         }
 
 
         public async Task<List<MediaSourceInfo>> GetChannelStreamMediaSources(string channelId, CancellationToken cancellationToken)
         public async Task<List<MediaSourceInfo>> GetChannelStreamMediaSources(string channelId, CancellationToken cancellationToken)
@@ -1031,7 +1031,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
                     IsInfiniteStream = true,
                     IsInfiniteStream = true,
                     RequiresOpening = false,
                     RequiresOpening = false,
                     RequiresClosing = false,
                     RequiresClosing = false,
-                    Protocol = Model.MediaInfo.MediaProtocol.Http,
+                    Protocol = MediaBrowser.Model.MediaInfo.MediaProtocol.Http,
                     BufferMs = 0
                     BufferMs = 0
                 };
                 };
 
 
@@ -1353,7 +1353,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
                 timer.StartDate = DateTime.UtcNow.AddSeconds(retryIntervalSeconds);
                 timer.StartDate = DateTime.UtcNow.AddSeconds(retryIntervalSeconds);
                 _timerProvider.AddOrUpdate(timer);
                 _timerProvider.AddOrUpdate(timer);
             }
             }
-            else if (File.Exists(recordPath))
+            else if (_fileSystem.FileExists(recordPath))
             {
             {
                 timer.RecordingPath = recordPath;
                 timer.RecordingPath = recordPath;
                 timer.Status = RecordingStatus.Completed;
                 timer.Status = RecordingStatus.Completed;
@@ -1409,7 +1409,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
                     .Where(i => i.Status == RecordingStatus.Completed && !string.IsNullOrWhiteSpace(i.RecordingPath))
                     .Where(i => i.Status == RecordingStatus.Completed && !string.IsNullOrWhiteSpace(i.RecordingPath))
                     .Where(i => string.Equals(i.SeriesTimerId, seriesTimerId, StringComparison.OrdinalIgnoreCase))
                     .Where(i => string.Equals(i.SeriesTimerId, seriesTimerId, StringComparison.OrdinalIgnoreCase))
                     .OrderByDescending(i => i.EndDate)
                     .OrderByDescending(i => i.EndDate)
-                    .Where(i => File.Exists(i.RecordingPath))
+                    .Where(i => _fileSystem.FileExists(i.RecordingPath))
                     .Skip(seriesTimer.KeepUpTo - 1)
                     .Skip(seriesTimer.KeepUpTo - 1)
                     .ToList();
                     .ToList();
 
 
@@ -1457,13 +1457,9 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
             {
             {
                 try
                 try
                 {
                 {
-                    File.Delete(timer.RecordingPath);
+                    _fileSystem.DeleteFile(timer.RecordingPath);
                 }
                 }
-                catch (DirectoryNotFoundException)
-                {
-
-                }
-                catch (FileNotFoundException)
+                catch (IOException)
                 {
                 {
 
 
                 }
                 }
@@ -1519,7 +1515,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
 
 
                 if (regInfo.IsValid)
                 if (regInfo.IsValid)
                 {
                 {
-                    return new EncodedRecorder(_logger, _fileSystem, _mediaEncoder, _config.ApplicationPaths, _jsonSerializer, config, _httpClient);
+                    return new EncodedRecorder(_logger, _fileSystem, _mediaEncoder, _config.ApplicationPaths, _jsonSerializer, config, _httpClient, _processFactory);
                 }
                 }
             }
             }
 
 
@@ -1528,28 +1524,28 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
 
 
         private async void OnSuccessfulRecording(TimerInfo timer, string path)
         private async void OnSuccessfulRecording(TimerInfo timer, string path)
         {
         {
-            if (timer.IsProgramSeries && GetConfiguration().EnableAutoOrganize)
-            {
-                try
-                {
-                    // this is to account for the library monitor holding a lock for additional time after the change is complete.
-                    // ideally this shouldn't be hard-coded
-                    await Task.Delay(30000).ConfigureAwait(false);
-
-                    var organize = new EpisodeFileOrganizer(_organizationService, _config, _fileSystem, _logger, _libraryManager, _libraryMonitor, _providerManager);
-
-                    var result = await organize.OrganizeEpisodeFile(path, _config.GetAutoOrganizeOptions(), false, CancellationToken.None).ConfigureAwait(false);
-
-                    if (result.Status == FileSortingStatus.Success)
-                    {
-                        return;
-                    }
-                }
-                catch (Exception ex)
-                {
-                    _logger.ErrorException("Error processing new recording", ex);
-                }
-            }
+            //if (timer.IsProgramSeries && GetConfiguration().EnableAutoOrganize)
+            //{
+            //    try
+            //    {
+            //        // this is to account for the library monitor holding a lock for additional time after the change is complete.
+            //        // ideally this shouldn't be hard-coded
+            //        await Task.Delay(30000).ConfigureAwait(false);
+
+            //        var organize = new EpisodeFileOrganizer(_organizationService, _config, _fileSystem, _logger, _libraryManager, _libraryMonitor, _providerManager);
+
+            //        var result = await organize.OrganizeEpisodeFile(path, _config.GetAutoOrganizeOptions(), false, CancellationToken.None).ConfigureAwait(false);
+
+            //        if (result.Status == FileSortingStatus.Success)
+            //        {
+            //            return;
+            //        }
+            //    }
+            //    catch (Exception ex)
+            //    {
+            //        _logger.ErrorException("Error processing new recording", ex);
+            //    }
+            //}
         }
         }
 
 
         private void SaveNfo(TimerInfo timer, string recordingPath, string seriesPath)
         private void SaveNfo(TimerInfo timer, string recordingPath, string seriesPath)
@@ -1575,7 +1571,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
         {
         {
             var nfoPath = Path.Combine(seriesPath, "tvshow.nfo");
             var nfoPath = Path.Combine(seriesPath, "tvshow.nfo");
 
 
-            if (File.Exists(nfoPath))
+            if (_fileSystem.FileExists(nfoPath))
             {
             {
                 return;
                 return;
             }
             }
@@ -1610,7 +1606,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
         {
         {
             var nfoPath = Path.ChangeExtension(recordingPath, ".nfo");
             var nfoPath = Path.ChangeExtension(recordingPath, ".nfo");
 
 
-            if (File.Exists(nfoPath))
+            if (_fileSystem.FileExists(nfoPath))
             {
             {
                 return;
                 return;
             }
             }
@@ -1931,7 +1927,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
             var defaultFolder = RecordingPath;
             var defaultFolder = RecordingPath;
             var defaultName = "Recordings";
             var defaultName = "Recordings";
 
 
-            if (Directory.Exists(defaultFolder))
+            if (_fileSystem.DirectoryExists(defaultFolder))
             {
             {
                 list.Add(new VirtualFolderInfo
                 list.Add(new VirtualFolderInfo
                 {
                 {
@@ -1941,7 +1937,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
             }
             }
 
 
             var customPath = GetConfiguration().MovieRecordingPath;
             var customPath = GetConfiguration().MovieRecordingPath;
-            if ((!string.IsNullOrWhiteSpace(customPath) && !string.Equals(customPath, defaultFolder, StringComparison.OrdinalIgnoreCase)) && Directory.Exists(customPath))
+            if ((!string.IsNullOrWhiteSpace(customPath) && !string.Equals(customPath, defaultFolder, StringComparison.OrdinalIgnoreCase)) && _fileSystem.DirectoryExists(customPath))
             {
             {
                 list.Add(new VirtualFolderInfo
                 list.Add(new VirtualFolderInfo
                 {
                 {
@@ -1952,7 +1948,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
             }
             }
 
 
             customPath = GetConfiguration().SeriesRecordingPath;
             customPath = GetConfiguration().SeriesRecordingPath;
-            if ((!string.IsNullOrWhiteSpace(customPath) && !string.Equals(customPath, defaultFolder, StringComparison.OrdinalIgnoreCase)) && Directory.Exists(customPath))
+            if ((!string.IsNullOrWhiteSpace(customPath) && !string.Equals(customPath, defaultFolder, StringComparison.OrdinalIgnoreCase)) && _fileSystem.DirectoryExists(customPath))
             {
             {
                 list.Add(new VirtualFolderInfo
                 list.Add(new VirtualFolderInfo
                 {
                 {

+ 1 - 1
MediaBrowser.Server.Implementations/LiveTv/EmbyTV/EmbyTVRegistration.cs → Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTVRegistration.cs

@@ -1,7 +1,7 @@
 using System.Threading.Tasks;
 using System.Threading.Tasks;
 using MediaBrowser.Common.Security;
 using MediaBrowser.Common.Security;
 
 
-namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
+namespace Emby.Server.Implementations.LiveTv.EmbyTV
 {
 {
     public class EmbyTVRegistration : IRequiresRegistration
     public class EmbyTVRegistration : IRequiresRegistration
     {
     {

+ 19 - 20
MediaBrowser.Server.Implementations/LiveTv/EmbyTV/EncodedRecorder.cs → Emby.Server.Implementations/LiveTv/EmbyTV/EncodedRecorder.cs

@@ -13,13 +13,14 @@ using MediaBrowser.Common.Net;
 using MediaBrowser.Controller;
 using MediaBrowser.Controller;
 using MediaBrowser.Controller.IO;
 using MediaBrowser.Controller.IO;
 using MediaBrowser.Controller.MediaEncoding;
 using MediaBrowser.Controller.MediaEncoding;
+using MediaBrowser.Model.Diagnostics;
 using MediaBrowser.Model.Dto;
 using MediaBrowser.Model.Dto;
 using MediaBrowser.Model.Entities;
 using MediaBrowser.Model.Entities;
 using MediaBrowser.Model.LiveTv;
 using MediaBrowser.Model.LiveTv;
 using MediaBrowser.Model.Logging;
 using MediaBrowser.Model.Logging;
 using MediaBrowser.Model.Serialization;
 using MediaBrowser.Model.Serialization;
 
 
-namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
+namespace Emby.Server.Implementations.LiveTv.EmbyTV
 {
 {
     public class EncodedRecorder : IRecorder
     public class EncodedRecorder : IRecorder
     {
     {
@@ -32,11 +33,12 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
         private bool _hasExited;
         private bool _hasExited;
         private Stream _logFileStream;
         private Stream _logFileStream;
         private string _targetPath;
         private string _targetPath;
-        private Process _process;
+        private IProcess _process;
+        private readonly IProcessFactory _processFactory;
         private readonly IJsonSerializer _json;
         private readonly IJsonSerializer _json;
         private readonly TaskCompletionSource<bool> _taskCompletionSource = new TaskCompletionSource<bool>();
         private readonly TaskCompletionSource<bool> _taskCompletionSource = new TaskCompletionSource<bool>();
 
 
-        public EncodedRecorder(ILogger logger, IFileSystem fileSystem, IMediaEncoder mediaEncoder, IServerApplicationPaths appPaths, IJsonSerializer json, LiveTvOptions liveTvOptions, IHttpClient httpClient)
+        public EncodedRecorder(ILogger logger, IFileSystem fileSystem, IMediaEncoder mediaEncoder, IServerApplicationPaths appPaths, IJsonSerializer json, LiveTvOptions liveTvOptions, IHttpClient httpClient, IProcessFactory processFactory)
         {
         {
             _logger = logger;
             _logger = logger;
             _fileSystem = fileSystem;
             _fileSystem = fileSystem;
@@ -45,6 +47,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
             _json = json;
             _json = json;
             _liveTvOptions = liveTvOptions;
             _liveTvOptions = liveTvOptions;
             _httpClient = httpClient;
             _httpClient = httpClient;
+            _processFactory = processFactory;
         }
         }
 
 
         private string OutputFormat
         private string OutputFormat
@@ -82,27 +85,23 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
             _targetPath = targetFile;
             _targetPath = targetFile;
             _fileSystem.CreateDirectory(Path.GetDirectoryName(targetFile));
             _fileSystem.CreateDirectory(Path.GetDirectoryName(targetFile));
 
 
-            var process = new Process
+            var process = _processFactory.Create(new ProcessOptions
             {
             {
-                StartInfo = new ProcessStartInfo
-                {
-                    CreateNoWindow = true,
-                    UseShellExecute = false,
-
-                    // Must consume both stdout and stderr or deadlocks may occur
-                    //RedirectStandardOutput = true,
-                    RedirectStandardError = true,
-                    RedirectStandardInput = true,
+                CreateNoWindow = true,
+                UseShellExecute = false,
 
 
-                    FileName = _mediaEncoder.EncoderPath,
-                    Arguments = GetCommandLineArgs(mediaSource, inputFile, targetFile, duration),
+                // Must consume both stdout and stderr or deadlocks may occur
+                //RedirectStandardOutput = true,
+                RedirectStandardError = true,
+                RedirectStandardInput = true,
 
 
-                    WindowStyle = ProcessWindowStyle.Hidden,
-                    ErrorDialog = false
-                },
+                FileName = _mediaEncoder.EncoderPath,
+                Arguments = GetCommandLineArgs(mediaSource, inputFile, targetFile, duration),
 
 
+                IsHidden = true,
+                ErrorDialog = false,
                 EnableRaisingEvents = true
                 EnableRaisingEvents = true
-            };
+            });
 
 
             _process = process;
             _process = process;
 
 
@@ -251,7 +250,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
         /// <summary>
         /// <summary>
         /// Processes the exited.
         /// Processes the exited.
         /// </summary>
         /// </summary>
-        private void OnFfMpegProcessExited(Process process, string inputFile)
+        private void OnFfMpegProcessExited(IProcess process, string inputFile)
         {
         {
             _hasExited = true;
             _hasExited = true;
 
 

+ 1 - 1
MediaBrowser.Server.Implementations/LiveTv/EmbyTV/EntryPoint.cs → Emby.Server.Implementations/LiveTv/EmbyTV/EntryPoint.cs

@@ -1,6 +1,6 @@
 using MediaBrowser.Controller.Plugins;
 using MediaBrowser.Controller.Plugins;
 
 
-namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
+namespace Emby.Server.Implementations.LiveTv.EmbyTV
 {
 {
     public class EntryPoint : IServerEntryPoint
     public class EntryPoint : IServerEntryPoint
     {
     {

+ 1 - 1
MediaBrowser.Server.Implementations/LiveTv/EmbyTV/IRecorder.cs → Emby.Server.Implementations/LiveTv/EmbyTV/IRecorder.cs

@@ -3,7 +3,7 @@ using System.Threading;
 using System.Threading.Tasks;
 using System.Threading.Tasks;
 using MediaBrowser.Model.Dto;
 using MediaBrowser.Model.Dto;
 
 
-namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
+namespace Emby.Server.Implementations.LiveTv.EmbyTV
 {
 {
     public interface IRecorder
     public interface IRecorder
     {
     {

+ 1 - 4
MediaBrowser.Server.Implementations/LiveTv/EmbyTV/ItemDataProvider.cs → Emby.Server.Implementations/LiveTv/EmbyTV/ItemDataProvider.cs

@@ -8,7 +8,7 @@ using MediaBrowser.Common.IO;
 using MediaBrowser.Controller.IO;
 using MediaBrowser.Controller.IO;
 using MediaBrowser.Model.IO;
 using MediaBrowser.Model.IO;
 
 
-namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
+namespace Emby.Server.Implementations.LiveTv.EmbyTV
 {
 {
     public class ItemDataProvider<T>
     public class ItemDataProvider<T>
         where T : class
         where T : class
@@ -54,9 +54,6 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
             catch (FileNotFoundException)
             catch (FileNotFoundException)
             {
             {
             }
             }
-            catch (DirectoryNotFoundException)
-            {
-            }
             catch (IOException ex)
             catch (IOException ex)
             {
             {
                 Logger.ErrorException("Error deserializing {0}", ex, jsonFile);
                 Logger.ErrorException("Error deserializing {0}", ex, jsonFile);

+ 1 - 1
MediaBrowser.Server.Implementations/LiveTv/EmbyTV/RecordingHelper.cs → Emby.Server.Implementations/LiveTv/EmbyTV/RecordingHelper.cs

@@ -4,7 +4,7 @@ using System;
 using System.Globalization;
 using System.Globalization;
 using MediaBrowser.Model.LiveTv;
 using MediaBrowser.Model.LiveTv;
 
 
-namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
+namespace Emby.Server.Implementations.LiveTv.EmbyTV
 {
 {
     internal class RecordingHelper
     internal class RecordingHelper
     {
     {

+ 1 - 1
MediaBrowser.Server.Implementations/LiveTv/EmbyTV/SeriesTimerManager.cs → Emby.Server.Implementations/LiveTv/EmbyTV/SeriesTimerManager.cs

@@ -6,7 +6,7 @@ using MediaBrowser.Common.IO;
 using MediaBrowser.Controller.IO;
 using MediaBrowser.Controller.IO;
 using MediaBrowser.Model.IO;
 using MediaBrowser.Model.IO;
 
 
-namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
+namespace Emby.Server.Implementations.LiveTv.EmbyTV
 {
 {
     public class SeriesTimerManager : ItemDataProvider<SeriesTimerInfo>
     public class SeriesTimerManager : ItemDataProvider<SeriesTimerInfo>
     {
     {

+ 8 - 5
MediaBrowser.Server.Implementations/LiveTv/EmbyTV/TimerManager.cs → Emby.Server.Implementations/LiveTv/EmbyTV/TimerManager.cs

@@ -12,20 +12,23 @@ using MediaBrowser.Common.IO;
 using MediaBrowser.Controller.IO;
 using MediaBrowser.Controller.IO;
 using MediaBrowser.Model.IO;
 using MediaBrowser.Model.IO;
 using MediaBrowser.Model.LiveTv;
 using MediaBrowser.Model.LiveTv;
+using MediaBrowser.Model.Threading;
 
 
-namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
+namespace Emby.Server.Implementations.LiveTv.EmbyTV
 {
 {
     public class TimerManager : ItemDataProvider<TimerInfo>
     public class TimerManager : ItemDataProvider<TimerInfo>
     {
     {
-        private readonly ConcurrentDictionary<string, Timer> _timers = new ConcurrentDictionary<string, Timer>(StringComparer.OrdinalIgnoreCase);
+        private readonly ConcurrentDictionary<string, ITimer> _timers = new ConcurrentDictionary<string, ITimer>(StringComparer.OrdinalIgnoreCase);
         private readonly ILogger _logger;
         private readonly ILogger _logger;
 
 
         public event EventHandler<GenericEventArgs<TimerInfo>> TimerFired;
         public event EventHandler<GenericEventArgs<TimerInfo>> TimerFired;
+        private readonly ITimerFactory _timerFactory;
 
 
-        public TimerManager(IFileSystem fileSystem, IJsonSerializer jsonSerializer, ILogger logger, string dataPath, ILogger logger1)
+        public TimerManager(IFileSystem fileSystem, IJsonSerializer jsonSerializer, ILogger logger, string dataPath, ILogger logger1, ITimerFactory timerFactory)
             : base(fileSystem, jsonSerializer, logger, dataPath, (r1, r2) => string.Equals(r1.Id, r2.Id, StringComparison.OrdinalIgnoreCase))
             : base(fileSystem, jsonSerializer, logger, dataPath, (r1, r2) => string.Equals(r1.Id, r2.Id, StringComparison.OrdinalIgnoreCase))
         {
         {
             _logger = logger1;
             _logger = logger1;
+            _timerFactory = timerFactory;
         }
         }
 
 
         public void RestartTimers()
         public void RestartTimers()
@@ -126,7 +129,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
 
 
         private void StartTimer(TimerInfo item, TimeSpan dueTime)
         private void StartTimer(TimerInfo item, TimeSpan dueTime)
         {
         {
-            var timer = new Timer(TimerCallback, item.Id, dueTime, TimeSpan.Zero);
+            var timer = _timerFactory.Create(TimerCallback, item.Id, dueTime, TimeSpan.Zero);
 
 
             if (_timers.TryAdd(item.Id, timer))
             if (_timers.TryAdd(item.Id, timer))
             {
             {
@@ -141,7 +144,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
 
 
         private void StopTimer(TimerInfo item)
         private void StopTimer(TimerInfo item)
         {
         {
-            Timer timer;
+            ITimer timer;
             if (_timers.TryRemove(item.Id, out timer))
             if (_timers.TryRemove(item.Id, out timer))
             {
             {
                 timer.Dispose();
                 timer.Dispose();

+ 5 - 4
MediaBrowser.Server.Implementations/LiveTv/Listings/SchedulesDirect.cs → Emby.Server.Implementations/LiveTv/Listings/SchedulesDirect.cs

@@ -16,7 +16,7 @@ using System.Linq;
 using System.Threading;
 using System.Threading;
 using System.Threading.Tasks;
 using System.Threading.Tasks;
 
 
-namespace MediaBrowser.Server.Implementations.LiveTv.Listings
+namespace Emby.Server.Implementations.LiveTv.Listings
 {
 {
     public class SchedulesDirect : IListingsProvider
     public class SchedulesDirect : IListingsProvider
     {
     {
@@ -589,13 +589,14 @@ namespace MediaBrowser.Server.Implementations.LiveTv.Listings
         {
         {
             var imageIdString = "[";
             var imageIdString = "[";
 
 
-            programIds.ForEach(i =>
+            foreach (var i in programIds)
             {
             {
                 if (!imageIdString.Contains(i.Substring(0, 10)))
                 if (!imageIdString.Contains(i.Substring(0, 10)))
                 {
                 {
                     imageIdString += "\"" + i.Substring(0, 10) + "\",";
                     imageIdString += "\"" + i.Substring(0, 10) + "\",";
                 }
                 }
-            });
+            }
+
             imageIdString = imageIdString.TrimEnd(',') + "]";
             imageIdString = imageIdString.TrimEnd(',') + "]";
 
 
             var httpOptions = new HttpRequestOptions()
             var httpOptions = new HttpRequestOptions()
@@ -822,7 +823,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv.Listings
                     return root.token;
                     return root.token;
                 }
                 }
 
 
-                throw new ApplicationException("Could not authenticate with Schedules Direct Error: " + root.message);
+                throw new Exception("Could not authenticate with Schedules Direct Error: " + root.message);
             }
             }
         }
         }
 
 

+ 17 - 14
MediaBrowser.Server.Implementations/LiveTv/Listings/XmlTvListingsProvider.cs → Emby.Server.Implementations/LiveTv/Listings/XmlTvListingsProvider.cs

@@ -15,21 +15,24 @@ using Emby.XmlTv.Entities;
 using MediaBrowser.Common.Extensions;
 using MediaBrowser.Common.Extensions;
 using MediaBrowser.Common.Net;
 using MediaBrowser.Common.Net;
 using MediaBrowser.Controller.Configuration;
 using MediaBrowser.Controller.Configuration;
+using MediaBrowser.Model.IO;
 using MediaBrowser.Model.Logging;
 using MediaBrowser.Model.Logging;
 
 
-namespace MediaBrowser.Server.Implementations.LiveTv.Listings
+namespace Emby.Server.Implementations.LiveTv.Listings
 {
 {
     public class XmlTvListingsProvider : IListingsProvider
     public class XmlTvListingsProvider : IListingsProvider
     {
     {
         private readonly IServerConfigurationManager _config;
         private readonly IServerConfigurationManager _config;
         private readonly IHttpClient _httpClient;
         private readonly IHttpClient _httpClient;
         private readonly ILogger _logger;
         private readonly ILogger _logger;
+        private readonly IFileSystem _fileSystem;
 
 
-        public XmlTvListingsProvider(IServerConfigurationManager config, IHttpClient httpClient, ILogger logger)
+        public XmlTvListingsProvider(IServerConfigurationManager config, IHttpClient httpClient, ILogger logger, IFileSystem fileSystem)
         {
         {
             _config = config;
             _config = config;
             _httpClient = httpClient;
             _httpClient = httpClient;
             _logger = logger;
             _logger = logger;
+            _fileSystem = fileSystem;
         }
         }
 
 
         public string Name
         public string Name
@@ -58,7 +61,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv.Listings
 
 
             var cacheFilename = DateTime.UtcNow.DayOfYear.ToString(CultureInfo.InvariantCulture) + "-" + DateTime.UtcNow.Hour.ToString(CultureInfo.InvariantCulture) + ".xml";
             var cacheFilename = DateTime.UtcNow.DayOfYear.ToString(CultureInfo.InvariantCulture) + "-" + DateTime.UtcNow.Hour.ToString(CultureInfo.InvariantCulture) + ".xml";
             var cacheFile = Path.Combine(_config.ApplicationPaths.CachePath, "xmltv", cacheFilename);
             var cacheFile = Path.Combine(_config.ApplicationPaths.CachePath, "xmltv", cacheFilename);
-            if (File.Exists(cacheFile))
+            if (_fileSystem.FileExists(cacheFile))
             {
             {
                 return cacheFile;
                 return cacheFile;
             }
             }
@@ -70,7 +73,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv.Listings
                 CancellationToken = cancellationToken,
                 CancellationToken = cancellationToken,
                 Url = path,
                 Url = path,
                 Progress = new Progress<Double>(),
                 Progress = new Progress<Double>(),
-                DecompressionMethod = DecompressionMethods.GZip,
+                DecompressionMethod = CompressionMethod.Gzip,
 
 
                 // It's going to come back gzipped regardless of this value
                 // It's going to come back gzipped regardless of this value
                 // So we need to make sure the decompression method is set to gzip
                 // So we need to make sure the decompression method is set to gzip
@@ -78,13 +81,13 @@ namespace MediaBrowser.Server.Implementations.LiveTv.Listings
 
 
             }).ConfigureAwait(false);
             }).ConfigureAwait(false);
 
 
-            Directory.CreateDirectory(Path.GetDirectoryName(cacheFile));
+            _fileSystem.CreateDirectory(Path.GetDirectoryName(cacheFile));
 
 
-            using (var stream = File.OpenRead(tempFile))
+            using (var stream = _fileSystem.OpenRead(tempFile))
             {
             {
                 using (var reader = new StreamReader(stream, Encoding.UTF8))
                 using (var reader = new StreamReader(stream, Encoding.UTF8))
                 {
                 {
-                    using (var fileStream = File.OpenWrite(cacheFile))
+                    using (var fileStream = _fileSystem.GetFileStream(cacheFile, FileOpenMode.Create, FileAccessMode.Write, FileShareMode.Read))
                     {
                     {
                         using (var writer = new StreamWriter(fileStream))
                         using (var writer = new StreamWriter(fileStream))
                         {
                         {
@@ -138,10 +141,10 @@ namespace MediaBrowser.Server.Implementations.LiveTv.Listings
                 IsSeries = p.Episode != null,
                 IsSeries = p.Episode != null,
                 IsRepeat = p.IsRepeat,
                 IsRepeat = p.IsRepeat,
                 IsPremiere = p.Premiere != null,
                 IsPremiere = p.Premiere != null,
-                IsKids = p.Categories.Any(c => info.KidsCategories.Contains(c, StringComparer.InvariantCultureIgnoreCase)),
-                IsMovie = p.Categories.Any(c => info.MovieCategories.Contains(c, StringComparer.InvariantCultureIgnoreCase)),
-                IsNews = p.Categories.Any(c => info.NewsCategories.Contains(c, StringComparer.InvariantCultureIgnoreCase)),
-                IsSports = p.Categories.Any(c => info.SportsCategories.Contains(c, StringComparer.InvariantCultureIgnoreCase)),
+                IsKids = p.Categories.Any(c => info.KidsCategories.Contains(c, StringComparer.OrdinalIgnoreCase)),
+                IsMovie = p.Categories.Any(c => info.MovieCategories.Contains(c, StringComparer.OrdinalIgnoreCase)),
+                IsNews = p.Categories.Any(c => info.NewsCategories.Contains(c, StringComparer.OrdinalIgnoreCase)),
+                IsSports = p.Categories.Any(c => info.SportsCategories.Contains(c, StringComparer.OrdinalIgnoreCase)),
                 ImageUrl = p.Icon != null && !String.IsNullOrEmpty(p.Icon.Source) ? p.Icon.Source : null,
                 ImageUrl = p.Icon != null && !String.IsNullOrEmpty(p.Icon.Source) ? p.Icon.Source : null,
                 HasImage = p.Icon != null && !String.IsNullOrEmpty(p.Icon.Source),
                 HasImage = p.Icon != null && !String.IsNullOrEmpty(p.Icon.Source),
                 OfficialRating = p.Rating != null && !String.IsNullOrEmpty(p.Rating.Value) ? p.Rating.Value : null,
                 OfficialRating = p.Rating != null && !String.IsNullOrEmpty(p.Rating.Value) ? p.Rating.Value : null,
@@ -177,7 +180,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv.Listings
 
 
             if (channels != null)
             if (channels != null)
             {
             {
-                channels.ForEach(c =>
+                foreach (var c in channels)
                 {
                 {
                     var channelNumber = info.GetMappedChannel(c.Number);
                     var channelNumber = info.GetMappedChannel(c.Number);
                     var match = results.FirstOrDefault(r => string.Equals(r.Id, channelNumber, StringComparison.OrdinalIgnoreCase));
                     var match = results.FirstOrDefault(r => string.Equals(r.Id, channelNumber, StringComparison.OrdinalIgnoreCase));
@@ -186,14 +189,14 @@ namespace MediaBrowser.Server.Implementations.LiveTv.Listings
                     {
                     {
                         c.ImageUrl = match.Icon.Source;
                         c.ImageUrl = match.Icon.Source;
                     }
                     }
-                });
+                }
             }
             }
         }
         }
 
 
         public Task Validate(ListingsProviderInfo info, bool validateLogin, bool validateListings)
         public Task Validate(ListingsProviderInfo info, bool validateLogin, bool validateListings)
         {
         {
             // Assume all urls are valid. check files for existence
             // Assume all urls are valid. check files for existence
-            if (!info.Path.StartsWith("http", StringComparison.OrdinalIgnoreCase) && !File.Exists(info.Path))
+            if (!info.Path.StartsWith("http", StringComparison.OrdinalIgnoreCase) && !_fileSystem.FileExists(info.Path))
             {
             {
                 throw new FileNotFoundException("Could not find the XmlTv file specified:", info.Path);
                 throw new FileNotFoundException("Could not find the XmlTv file specified:", info.Path);
             }
             }

+ 3 - 3
MediaBrowser.Server.Implementations/LiveTv/LiveStreamHelper.cs → Emby.Server.Implementations/LiveTv/LiveStreamHelper.cs

@@ -8,7 +8,7 @@ using MediaBrowser.Model.Dlna;
 using MediaBrowser.Model.Dto;
 using MediaBrowser.Model.Dto;
 using MediaBrowser.Model.Logging;
 using MediaBrowser.Model.Logging;
 
 
-namespace MediaBrowser.Server.Implementations.LiveTv
+namespace Emby.Server.Implementations.LiveTv
 {
 {
     public class LiveStreamHelper
     public class LiveStreamHelper
     {
     {
@@ -57,7 +57,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv
                 mediaSource.RunTimeTicks = null;
                 mediaSource.RunTimeTicks = null;
             }
             }
 
 
-            var audioStream = mediaSource.MediaStreams.FirstOrDefault(i => i.Type == Model.Entities.MediaStreamType.Audio);
+            var audioStream = mediaSource.MediaStreams.FirstOrDefault(i => i.Type == MediaBrowser.Model.Entities.MediaStreamType.Audio);
 
 
             if (audioStream == null || audioStream.Index == -1)
             if (audioStream == null || audioStream.Index == -1)
             {
             {
@@ -68,7 +68,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv
                 mediaSource.DefaultAudioStreamIndex = audioStream.Index;
                 mediaSource.DefaultAudioStreamIndex = audioStream.Index;
             }
             }
 
 
-            var videoStream = mediaSource.MediaStreams.FirstOrDefault(i => i.Type == Model.Entities.MediaStreamType.Video);
+            var videoStream = mediaSource.MediaStreams.FirstOrDefault(i => i.Type == MediaBrowser.Model.Entities.MediaStreamType.Video);
             if (videoStream != null)
             if (videoStream != null)
             {
             {
                 if (!videoStream.BitRate.HasValue)
                 if (!videoStream.BitRate.HasValue)

+ 1 - 1
MediaBrowser.Server.Implementations/LiveTv/LiveTvConfigurationFactory.cs → Emby.Server.Implementations/LiveTv/LiveTvConfigurationFactory.cs

@@ -2,7 +2,7 @@
 using MediaBrowser.Model.LiveTv;
 using MediaBrowser.Model.LiveTv;
 using System.Collections.Generic;
 using System.Collections.Generic;
 
 
-namespace MediaBrowser.Server.Implementations.LiveTv
+namespace Emby.Server.Implementations.LiveTv
 {
 {
     public class LiveTvConfigurationFactory : IConfigurationFactory
     public class LiveTvConfigurationFactory : IConfigurationFactory
     {
     {

+ 1 - 1
MediaBrowser.Server.Implementations/LiveTv/LiveTvDtoService.cs → Emby.Server.Implementations/LiveTv/LiveTvDtoService.cs

@@ -14,7 +14,7 @@ using System.Linq;
 using System.Threading;
 using System.Threading;
 using System.Threading.Tasks;
 using System.Threading.Tasks;
 
 
-namespace MediaBrowser.Server.Implementations.LiveTv
+namespace Emby.Server.Implementations.LiveTv
 {
 {
     public class LiveTvDtoService
     public class LiveTvDtoService
     {
     {

+ 33 - 32
MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs → Emby.Server.Implementations/LiveTv/LiveTvManager.cs

@@ -25,8 +25,6 @@ using System.Linq;
 using System.Threading;
 using System.Threading;
 using System.Threading.Tasks;
 using System.Threading.Tasks;
 using MediaBrowser.Model.IO;
 using MediaBrowser.Model.IO;
-using IniParser;
-using IniParser.Model;
 using MediaBrowser.Common.Events;
 using MediaBrowser.Common.Events;
 using MediaBrowser.Common.IO;
 using MediaBrowser.Common.IO;
 using MediaBrowser.Common.Security;
 using MediaBrowser.Common.Security;
@@ -37,9 +35,9 @@ using MediaBrowser.Model.Events;
 using MediaBrowser.Model.Extensions;
 using MediaBrowser.Model.Extensions;
 using MediaBrowser.Model.Globalization;
 using MediaBrowser.Model.Globalization;
 using MediaBrowser.Model.Tasks;
 using MediaBrowser.Model.Tasks;
-using MediaBrowser.Server.Implementations.LiveTv.Listings;
+using Emby.Server.Implementations.LiveTv.Listings;
 
 
-namespace MediaBrowser.Server.Implementations.LiveTv
+namespace Emby.Server.Implementations.LiveTv
 {
 {
     /// <summary>
     /// <summary>
     /// Class LiveTvManager
     /// Class LiveTvManager
@@ -2967,43 +2965,46 @@ namespace MediaBrowser.Server.Implementations.LiveTv
 
 
         public List<NameValuePair> GetSatIniMappings()
         public List<NameValuePair> GetSatIniMappings()
         {
         {
-            var names = GetType().Assembly.GetManifestResourceNames().Where(i => i.IndexOf("SatIp.ini", StringComparison.OrdinalIgnoreCase) != -1).ToList();
+            return new List<NameValuePair>();
+            //var names = GetType().Assembly.GetManifestResourceNames().Where(i => i.IndexOf("SatIp.ini", StringComparison.OrdinalIgnoreCase) != -1).ToList();
 
 
-            return names.Select(GetSatIniMappings).Where(i => i != null).DistinctBy(i => i.Value.Split('|')[0]).ToList();
+            //return names.Select(GetSatIniMappings).Where(i => i != null).DistinctBy(i => i.Value.Split('|')[0]).ToList();
         }
         }
 
 
         public NameValuePair GetSatIniMappings(string resource)
         public NameValuePair GetSatIniMappings(string resource)
         {
         {
-            using (var stream = GetType().Assembly.GetManifestResourceStream(resource))
-            {
-                using (var reader = new StreamReader(stream))
-                {
-                    var parser = new StreamIniDataParser();
-                    IniData data = parser.ReadData(reader);
-
-                    var satType1 = data["SATTYPE"]["1"];
-                    var satType2 = data["SATTYPE"]["2"];
-
-                    if (string.IsNullOrWhiteSpace(satType2))
-                    {
-                        return null;
-                    }
-
-                    var srch = "SatIp.ini.";
-                    var filename = Path.GetFileName(resource);
-
-                    return new NameValuePair
-                    {
-                        Name = satType1 + " " + satType2,
-                        Value = satType2 + "|" + filename.Substring(filename.IndexOf(srch) + srch.Length)
-                    };
-                }
-            }
+            return new NameValuePair();
+            //using (var stream = GetType().Assembly.GetManifestResourceStream(resource))
+            //{
+            //    using (var reader = new StreamReader(stream))
+            //    {
+            //        var parser = new StreamIniDataParser();
+            //        IniData data = parser.ReadData(reader);
+
+            //        var satType1 = data["SATTYPE"]["1"];
+            //        var satType2 = data["SATTYPE"]["2"];
+
+            //        if (string.IsNullOrWhiteSpace(satType2))
+            //        {
+            //            return null;
+            //        }
+
+            //        var srch = "SatIp.ini.";
+            //        var filename = Path.GetFileName(resource);
+
+            //        return new NameValuePair
+            //        {
+            //            Name = satType1 + " " + satType2,
+            //            Value = satType2 + "|" + filename.Substring(filename.IndexOf(srch) + srch.Length)
+            //        };
+            //    }
+            //}
         }
         }
 
 
         public Task<List<ChannelInfo>> GetSatChannelScanResult(TunerHostInfo info, CancellationToken cancellationToken)
         public Task<List<ChannelInfo>> GetSatChannelScanResult(TunerHostInfo info, CancellationToken cancellationToken)
         {
         {
-            return new TunerHosts.SatIp.ChannelScan(_logger).Scan(info, cancellationToken);
+            return Task.FromResult(new List<ChannelInfo>());
+            //return new TunerHosts.SatIp.ChannelScan(_logger).Scan(info, cancellationToken);
         }
         }
 
 
         public Task<List<ChannelInfo>> GetChannelsForListingsProvider(string id, CancellationToken cancellationToken)
         public Task<List<ChannelInfo>> GetChannelsForListingsProvider(string id, CancellationToken cancellationToken)

+ 3 - 3
MediaBrowser.Server.Implementations/LiveTv/LiveTvMediaSourceProvider.cs → Emby.Server.Implementations/LiveTv/LiveTvMediaSourceProvider.cs

@@ -15,7 +15,7 @@ using System.Threading;
 using System.Threading.Tasks;
 using System.Threading.Tasks;
 using MediaBrowser.Model.Dlna;
 using MediaBrowser.Model.Dlna;
 
 
-namespace MediaBrowser.Server.Implementations.LiveTv
+namespace Emby.Server.Implementations.LiveTv
 {
 {
     public class LiveTvMediaSourceProvider : IMediaSourceProvider
     public class LiveTvMediaSourceProvider : IMediaSourceProvider
     {
     {
@@ -164,7 +164,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv
             // Null this out so that it will be treated like a live stream
             // Null this out so that it will be treated like a live stream
             mediaSource.RunTimeTicks = null;
             mediaSource.RunTimeTicks = null;
 
 
-            var audioStream = mediaSource.MediaStreams.FirstOrDefault(i => i.Type == Model.Entities.MediaStreamType.Audio);
+            var audioStream = mediaSource.MediaStreams.FirstOrDefault(i => i.Type == MediaBrowser.Model.Entities.MediaStreamType.Audio);
 
 
             if (audioStream == null || audioStream.Index == -1)
             if (audioStream == null || audioStream.Index == -1)
             {
             {
@@ -175,7 +175,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv
                 mediaSource.DefaultAudioStreamIndex = audioStream.Index;
                 mediaSource.DefaultAudioStreamIndex = audioStream.Index;
             }
             }
 
 
-            var videoStream = mediaSource.MediaStreams.FirstOrDefault(i => i.Type == Model.Entities.MediaStreamType.Video);
+            var videoStream = mediaSource.MediaStreams.FirstOrDefault(i => i.Type == MediaBrowser.Model.Entities.MediaStreamType.Video);
             if (videoStream != null)
             if (videoStream != null)
             {
             {
                 if (!videoStream.BitRate.HasValue)
                 if (!videoStream.BitRate.HasValue)

部分文件因为文件数量过多而无法显示