Merge pull request #2267 from MediaBrowser/dev

Dev
This commit is contained in:
Luke 2016-11-03 19:59:50 -04:00 committed by GitHub
commit c53745548a
231 changed files with 1770 additions and 1366 deletions

View File

@ -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);
} }

View File

@ -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);
}
}
} }
} }

View File

@ -169,9 +169,23 @@ namespace Emby.Common.Implementations.HttpClientManager
AddRequestHeaders(httpWebRequest, options); AddRequestHeaders(httpWebRequest, options);
#if NET46 #if NET46
httpWebRequest.AutomaticDecompression = options.EnableHttpCompression ? if (options.EnableHttpCompression)
(options.DecompressionMethod ?? DecompressionMethods.Deflate) : {
DecompressionMethods.None; 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
} }

View File

@ -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);
} }
} }
} }

View File

@ -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 null;
return Encoding.Default;
} }
} }
} }

View File

@ -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;

View File

@ -23,26 +23,19 @@
"System.Xml.Serialization": "4.0.0.0" "System.Xml.Serialization": "4.0.0.0"
}, },
"dependencies": { "dependencies": {
"MediaBrowser.Common": { "SimpleInjector": "3.2.4",
"target": "project" "NLog": "4.4.0-betaV15",
},
"MediaBrowser.Model": { "MediaBrowser.Model": {
"target": "project" "target": "project"
}, },
"SimpleInjector": "3.2.4", "MediaBrowser.Common": {
"NLog": "4.4.0-betaV15" "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",
@ -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"
} }
} }
} }
} }

View File

@ -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();

View File

@ -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>

View File

@ -32,5 +32,3 @@ 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.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@ -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
{ {

View File

@ -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
{ {

View File

@ -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
{ {

View File

@ -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
{ {

View File

@ -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
{ {

View File

@ -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
{ {

View File

@ -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)
{ {
} }

View File

@ -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
{ {

View File

@ -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
{ {

View File

@ -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 Emby.Server.Implementations.Images;
using MediaBrowser.Controller.IO;
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>
{ {

View File

@ -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
{ {

View File

@ -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
{ {

View File

@ -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
{ {

View File

@ -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>

View File

@ -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));
} }
} }

View File

@ -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

View File

@ -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()

View File

@ -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);
} }

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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
{ {

View File

@ -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

View File

@ -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 sourceFileInfo = _fileSystem.GetFileInfo(sourcePath);
var destinationFileInfo = new FileInfo(newPath); 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;
} }

View File

@ -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
{ {

View File

@ -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

View File

@ -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
{ {

View File

@ -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 MediaBrowser.Controller.Extensions;
using System.Text;
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);
}
} }
} }

View File

@ -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
{ {

View File

@ -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) { }

View File

@ -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.
} }

View File

@ -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;
} }

View File

@ -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
{ {

View File

@ -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

View File

@ -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) //if (Environment.OSVersion.Platform == PlatformID.Win32NT)
{ //{
// We can't validate protocol-based paths, so just allow them // // We can't validate protocol-based paths, so just allow them
if (path.IndexOf("://", StringComparison.OrdinalIgnoreCase) == -1) // if (path.IndexOf("://", StringComparison.OrdinalIgnoreCase) == -1)
{ // {
return Directory.Exists(path); // 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))
{ {

View File

@ -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
{ {

View File

@ -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()

View File

@ -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
{ {

View File

@ -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
{ {

View File

@ -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)
{ {

View File

@ -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();
} }
} }
} }

View File

@ -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

View File

@ -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

View File

@ -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)
{ {

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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>
{ {

View File

@ -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>
{ {

View File

@ -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>
{ {

View File

@ -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>
{ {

View File

@ -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

View File

@ -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

View File

@ -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)
{ {

View File

@ -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

View File

@ -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
{ {

View File

@ -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

View File

@ -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.Model.Cryptography;
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 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)
@ -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()) return BitConverter.ToString(_cryptographyProvider.GetSHA1Bytes(Encoding.UTF8.GetBytes(str))).Replace("-", string.Empty);
{
var hash = provider.ComputeHash(Encoding.UTF8.GetBytes(str));
return BitConverter.ToString(hash).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,7 +746,10 @@ 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());
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); _fileSystem.WriteAllText(path, text.ToString(), Encoding.UTF8);
@ -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);
} }
@ -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();
} }

View File

@ -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
{ {

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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
{ {

View File

@ -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
{ {

View File

@ -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
{ {

View File

@ -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

View File

@ -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
{ {

View File

@ -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

View File

@ -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

View File

@ -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
{ {

View File

@ -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
{ {

View File

@ -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
{ {

View File

@ -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
{ {

View File

@ -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 (IOException)
{
}
catch (FileNotFoundException)
{ {
} }
@ -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) //if (timer.IsProgramSeries && GetConfiguration().EnableAutoOrganize)
{ //{
try // try
{ // {
// this is to account for the library monitor holding a lock for additional time after the change is complete. // // 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 // // ideally this shouldn't be hard-coded
await Task.Delay(30000).ConfigureAwait(false); // await Task.Delay(30000).ConfigureAwait(false);
var organize = new EpisodeFileOrganizer(_organizationService, _config, _fileSystem, _logger, _libraryManager, _libraryMonitor, _providerManager); // var organize = new EpisodeFileOrganizer(_organizationService, _config, _fileSystem, _logger, _libraryManager, _libraryMonitor, _providerManager);
var result = await organize.OrganizeEpisodeFile(path, _config.GetAutoOrganizeOptions(), false, CancellationToken.None).ConfigureAwait(false); // var result = await organize.OrganizeEpisodeFile(path, _config.GetAutoOrganizeOptions(), false, CancellationToken.None).ConfigureAwait(false);
if (result.Status == FileSortingStatus.Success) // if (result.Status == FileSortingStatus.Success)
{ // {
return; // return;
} // }
} // }
catch (Exception ex) // catch (Exception ex)
{ // {
_logger.ErrorException("Error processing new recording", 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
{ {

View File

@ -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
{ {

View File

@ -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,9 +85,7 @@ 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, CreateNoWindow = true,
UseShellExecute = false, UseShellExecute = false,
@ -97,12 +98,10 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
FileName = _mediaEncoder.EncoderPath, FileName = _mediaEncoder.EncoderPath,
Arguments = GetCommandLineArgs(mediaSource, inputFile, targetFile, duration), Arguments = GetCommandLineArgs(mediaSource, inputFile, targetFile, duration),
WindowStyle = ProcessWindowStyle.Hidden, IsHidden = true,
ErrorDialog = false 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;

View File

@ -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
{ {

View File

@ -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
{ {

View File

@ -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);

View File

@ -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
{ {

View File

@ -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>
{ {

View File

@ -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();

View File

@ -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);
} }
} }

View File

@ -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)), IsKids = p.Categories.Any(c => info.KidsCategories.Contains(c, StringComparer.OrdinalIgnoreCase)),
IsMovie = p.Categories.Any(c => info.MovieCategories.Contains(c, StringComparer.InvariantCultureIgnoreCase)), IsMovie = p.Categories.Any(c => info.MovieCategories.Contains(c, StringComparer.OrdinalIgnoreCase)),
IsNews = p.Categories.Any(c => info.NewsCategories.Contains(c, StringComparer.InvariantCultureIgnoreCase)), IsNews = p.Categories.Any(c => info.NewsCategories.Contains(c, StringComparer.OrdinalIgnoreCase)),
IsSports = p.Categories.Any(c => info.SportsCategories.Contains(c, StringComparer.InvariantCultureIgnoreCase)), 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);
} }

View File

@ -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)

View File

@ -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
{ {

View File

@ -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
{ {

View File

@ -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)) return new NameValuePair();
{ //using (var stream = GetType().Assembly.GetManifestResourceStream(resource))
using (var reader = new StreamReader(stream)) //{
{ // using (var reader = new StreamReader(stream))
var parser = new StreamIniDataParser(); // {
IniData data = parser.ReadData(reader); // var parser = new StreamIniDataParser();
// IniData data = parser.ReadData(reader);
var satType1 = data["SATTYPE"]["1"]; // var satType1 = data["SATTYPE"]["1"];
var satType2 = data["SATTYPE"]["2"]; // var satType2 = data["SATTYPE"]["2"];
if (string.IsNullOrWhiteSpace(satType2)) // if (string.IsNullOrWhiteSpace(satType2))
{ // {
return null; // return null;
} // }
var srch = "SatIp.ini."; // var srch = "SatIp.ini.";
var filename = Path.GetFileName(resource); // var filename = Path.GetFileName(resource);
return new NameValuePair // return new NameValuePair
{ // {
Name = satType1 + " " + satType2, // Name = satType1 + " " + satType2,
Value = satType2 + "|" + filename.Substring(filename.IndexOf(srch) + srch.Length) // 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)

View File

@ -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)

Some files were not shown because too many files have changed in this diff Show More