Esempio n. 1
0
        /// <summary>
        /// Adds an additional mediaPath to an existing virtual folder, within either the default view or a user view
        /// </summary>
        /// <param name="fileSystem">The file system.</param>
        /// <param name="virtualFolderName">Name of the virtual folder.</param>
        /// <param name="path">The path.</param>
        /// <param name="appPaths">The app paths.</param>
        public static void AddMediaPath(IFileSystem fileSystem, string virtualFolderName, string path, IServerApplicationPaths appPaths)
        {
            if (string.IsNullOrWhiteSpace(path))
            {
                throw new ArgumentNullException("path");
            }

			if (!fileSystem.DirectoryExists(path))
            {
                throw new DirectoryNotFoundException("The path does not exist.");
            }

            var rootFolderPath = appPaths.DefaultUserViewsPath;
            var virtualFolderPath = Path.Combine(rootFolderPath, virtualFolderName);

            var shortcutFilename = fileSystem.GetFileNameWithoutExtension(path);

            var lnk = Path.Combine(virtualFolderPath, shortcutFilename + ShortcutFileExtension);

			while (fileSystem.FileExists(lnk))
            {
                shortcutFilename += "1";
                lnk = Path.Combine(virtualFolderPath, shortcutFilename + ShortcutFileExtension);
            }

            fileSystem.CreateShortcut(lnk, path);
        }
Esempio n. 2
0
 public AppThemeManager(IServerApplicationPaths appPaths, IFileSystem fileSystem, IJsonSerializer json, ILogger logger)
 {
     _appPaths = appPaths;
     _fileSystem = fileSystem;
     _json = json;
     _logger = logger;
 }
Esempio n. 3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ApiEntryPoint" /> class.
        /// </summary>
        /// <param name="logger">The logger.</param>
        /// <param name="appPaths">The application paths.</param>
        public ApiEntryPoint(ILogger logger, IServerApplicationPaths appPaths)
        {
            Logger = logger;
            AppPaths = appPaths;

            Instance = this;
        }
Esempio n. 4
0
        public SqliteUserRepository(ILogManager logManager, IServerApplicationPaths appPaths, IJsonSerializer jsonSerializer, IDbConnector dbConnector, IMemoryStreamProvider memoryStreamProvider) : base(logManager, dbConnector)
        {
            _jsonSerializer = jsonSerializer;
            _memoryStreamProvider = memoryStreamProvider;

            DbFilePath = Path.Combine(appPaths.DataPath, "users.db");
        }
Esempio n. 5
0
        /// <summary>
        /// Adds an additional mediaPath to an existing virtual folder, within either the default view or a user view
        /// </summary>
        /// <param name="fileSystem">The file system.</param>
        /// <param name="virtualFolderName">Name of the virtual folder.</param>
        /// <param name="path">The path.</param>
        /// <param name="user">The user.</param>
        /// <param name="appPaths">The app paths.</param>
        /// <exception cref="System.ArgumentException">The path is not valid.</exception>
        /// <exception cref="System.IO.DirectoryNotFoundException">The path does not exist.</exception>
        public static void AddMediaPath(IFileSystem fileSystem, string virtualFolderName, string path, User user, IServerApplicationPaths appPaths)
        {
            if (!Directory.Exists(path))
            {
                throw new DirectoryNotFoundException("The path does not exist.");
            }

            // Strip off trailing slash, but not on drives
            path = path.TrimEnd(Path.DirectorySeparatorChar);
            if (path.EndsWith(":", StringComparison.OrdinalIgnoreCase))
            {
                path += Path.DirectorySeparatorChar;
            }

            var rootFolderPath = user != null ? user.RootFolderPath : appPaths.DefaultUserViewsPath;
            var virtualFolderPath = Path.Combine(rootFolderPath, virtualFolderName);

            ValidateNewMediaPath(fileSystem, rootFolderPath, path, appPaths);

            var shortcutFilename = Path.GetFileNameWithoutExtension(path);

            var lnk = Path.Combine(virtualFolderPath, shortcutFilename + ShortcutFileExtension);

            while (File.Exists(lnk))
            {
                shortcutFilename += "1";
                lnk = Path.Combine(virtualFolderPath, shortcutFilename + ShortcutFileExtension);
            }

            fileSystem.CreateShortcut(lnk, path);
        }
Esempio n. 6
0
        /// <summary>
        /// Renames the virtual folder.
        /// </summary>
        /// <param name="name">The name.</param>
        /// <param name="newName">The new name.</param>
        /// <param name="user">The user.</param>
        /// <param name="appPaths">The app paths.</param>
        /// <exception cref="System.IO.DirectoryNotFoundException">The media collection does not exist</exception>
        /// <exception cref="System.ArgumentException">There is already a media collection with the name  + newPath + .</exception>
        public static void RenameVirtualFolder(string name, string newName, User user, IServerApplicationPaths appPaths)
        {
            var rootFolderPath = user != null ? user.RootFolderPath : appPaths.DefaultUserViewsPath;

            var currentPath = Path.Combine(rootFolderPath, name);
            var newPath = Path.Combine(rootFolderPath, newName);

            if (!Directory.Exists(currentPath))
            {
                throw new DirectoryNotFoundException("The media collection does not exist");
            }

            if (!string.Equals(currentPath, newPath, StringComparison.OrdinalIgnoreCase) && Directory.Exists(newPath))
            {
                throw new ArgumentException("There is already a media collection with the name " + newPath + ".");
            }
            //Only make a two-phase move when changing capitalization
            if (string.Equals(currentPath, newPath, StringComparison.OrdinalIgnoreCase))
            {
                //Create an unique name
                var temporaryName = Guid.NewGuid().ToString();
                var temporaryPath = Path.Combine(rootFolderPath, temporaryName);
                Directory.Move(currentPath,temporaryPath);
                currentPath = temporaryPath;
            }

            Directory.Move(currentPath, newPath);
        }
Esempio n. 7
0
        public ImageProcessor(ILogger logger, IServerApplicationPaths appPaths, IFileSystem fileSystem, IJsonSerializer jsonSerializer)
        {
            _logger = logger;
            _fileSystem = fileSystem;
            _jsonSerializer = jsonSerializer;
            _appPaths = appPaths;

            _saveImageSizeTimer = new Timer(SaveImageSizeCallback, null, Timeout.Infinite, Timeout.Infinite);

            Dictionary<Guid, ImageSize> sizeDictionary;

            try
            {
                sizeDictionary = jsonSerializer.DeserializeFromFile<Dictionary<Guid, ImageSize>>(ImageSizeFile) ?? 
                    new Dictionary<Guid, ImageSize>();
            }
            catch (FileNotFoundException)
            {
                // No biggie
                sizeDictionary = new Dictionary<Guid, ImageSize>();
            }
            catch (Exception ex)
            {
                logger.ErrorException("Error parsing image size cache file", ex);

                sizeDictionary = new Dictionary<Guid, ImageSize>();
            }

            _cachedImagedSizes = new ConcurrentDictionary<Guid, ImageSize>(sizeDictionary);
        }
Esempio n. 8
0
 public BifService(IServerApplicationPaths appPaths, ILibraryManager libraryManager, IMediaEncoder mediaEncoder, IFileSystem fileSystem)
 {
     _appPaths = appPaths;
     _libraryManager = libraryManager;
     _mediaEncoder = mediaEncoder;
     _fileSystem = fileSystem;
 }
Esempio n. 9
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ApiEntryPoint" /> class.
        /// </summary>
        /// <param name="logger">The logger.</param>
        /// <param name="appPaths">The application paths.</param>
        /// <param name="sessionManager">The session manager.</param>
        public ApiEntryPoint(ILogger logger, IServerApplicationPaths appPaths, ISessionManager sessionManager)
        {
            Logger = logger;
            _appPaths = appPaths;
            _sessionManager = sessionManager;

            Instance = this;
        }
Esempio n. 10
0
 public LiveTvManager(IServerApplicationPaths appPaths, IFileSystem fileSystem, ILogger logger, IItemRepository itemRepo, IImageProcessor imageProcessor)
 {
     _appPaths = appPaths;
     _fileSystem = fileSystem;
     _logger = logger;
     _itemRepo = itemRepo;
     _imageProcessor = imageProcessor;
 }
Esempio n. 11
0
 /// <summary>
 /// Initializes a new instance of the <see cref="BaseStreamingService" /> class.
 /// </summary>
 /// <param name="appPaths">The app paths.</param>
 /// <param name="userManager">The user manager.</param>
 /// <param name="libraryManager">The library manager.</param>
 /// <param name="isoManager">The iso manager.</param>
 /// <param name="mediaEncoder">The media encoder.</param>
 protected BaseStreamingService(IServerApplicationPaths appPaths, IUserManager userManager, ILibraryManager libraryManager, IIsoManager isoManager, IMediaEncoder mediaEncoder)
 {
     ApplicationPaths = appPaths;
     UserManager = userManager;
     LibraryManager = libraryManager;
     IsoManager = isoManager;
     MediaEncoder = mediaEncoder;
 }
Esempio n. 12
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ImageCleanupTask" /> class.
 /// </summary>
 /// <param name="kernel">The kernel.</param>
 /// <param name="logger">The logger.</param>
 /// <param name="libraryManager">The library manager.</param>
 /// <param name="appPaths">The app paths.</param>
 public ImageCleanupTask(Kernel kernel, ILogger logger, ILibraryManager libraryManager, IServerApplicationPaths appPaths, IItemRepository itemRepo)
 {
     _kernel = kernel;
     _logger = logger;
     _libraryManager = libraryManager;
     _appPaths = appPaths;
     _itemRepo = itemRepo;
 }
Esempio n. 13
0
        /// <summary>
        /// Initializes a new instance of the <see cref="LocalizedStrings" /> class.
        /// </summary>
        public LocalizedStrings(IServerApplicationPaths appPaths)
        {
            _appPaths = appPaths;

            foreach (var stringObject in StringFiles)
            {
                AddStringData(LoadFromFile(GetFileName(stringObject),stringObject.GetType()));
            }
        }
Esempio n. 14
0
        public ImageProcessor(ILogger logger, IServerApplicationPaths appPaths)
        {
            _logger = logger;
            _appPaths = appPaths;

            _imageSizeCachePath = Path.Combine(_appPaths.ImageCachePath, "image-sizes");
            _croppedWhitespaceImageCachePath = Path.Combine(_appPaths.ImageCachePath, "cropped-images");
            _enhancedImageCachePath = Path.Combine(_appPaths.ImageCachePath, "enhanced-images");
            _resizedImageCachePath = Path.Combine(_appPaths.ImageCachePath, "resized-images");
        }
Esempio n. 15
0
 public EncodedRecorder(ILogger logger, IFileSystem fileSystem, IMediaEncoder mediaEncoder, IServerApplicationPaths appPaths, IJsonSerializer json, LiveTvOptions liveTvOptions, IHttpClient httpClient)
 {
     _logger = logger;
     _fileSystem = fileSystem;
     _mediaEncoder = mediaEncoder;
     _appPaths = appPaths;
     _json = json;
     _liveTvOptions = liveTvOptions;
     _httpClient = httpClient;
 }
Esempio n. 16
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ImageManager" /> class.
        /// </summary>
        /// <param name="logger">The logger.</param>
        /// <param name="appPaths">The app paths.</param>
        /// <param name="itemRepo">The item repo.</param>
        public ImageManager(ILogger logger, IServerApplicationPaths appPaths, IItemRepository itemRepo)
        {
            _logger = logger;
            _itemRepo = itemRepo;

            ImageSizeCache = new FileSystemRepository(Path.Combine(appPaths.ImageCachePath, "image-sizes"));
            ResizedImageCache = new FileSystemRepository(Path.Combine(appPaths.ImageCachePath, "resized-images"));
            CroppedImageCache = new FileSystemRepository(Path.Combine(appPaths.ImageCachePath, "cropped-images"));
            EnhancedImageCache = new FileSystemRepository(Path.Combine(appPaths.ImageCachePath, "enhanced-images"));
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="BaseStreamingService" /> class.
 /// </summary>
 /// <param name="appPaths">The app paths.</param>
 /// <param name="userManager">The user manager.</param>
 /// <param name="libraryManager">The library manager.</param>
 /// <param name="isoManager">The iso manager.</param>
 /// <param name="mediaEncoder">The media encoder.</param>
 protected BaseStreamingService(IServerApplicationPaths appPaths, IUserManager userManager, ILibraryManager libraryManager, IIsoManager isoManager, IMediaEncoder mediaEncoder, IDtoService dtoService, IFileSystem fileSystem)
 {
     FileSystem = fileSystem;
     DtoService = dtoService;
     ApplicationPaths = appPaths;
     UserManager = userManager;
     LibraryManager = libraryManager;
     IsoManager = isoManager;
     MediaEncoder = mediaEncoder;
 }
Esempio n. 18
0
        /// <summary>
        /// Initializes a new instance of the <see cref="FFMpegManager" /> class.
        /// </summary>
        /// <param name="appPaths">The app paths.</param>
        /// <param name="encoder">The encoder.</param>
        /// <param name="logger">The logger.</param>
        /// <param name="itemRepo">The item repo.</param>
        /// <exception cref="System.ArgumentNullException">zipClient</exception>
        public FFMpegManager(IServerApplicationPaths appPaths, IMediaEncoder encoder, ILogger logger, IItemRepository itemRepo)
        {
            _appPaths = appPaths;
            _encoder = encoder;
            _logger = logger;
            _itemRepo = itemRepo;

            VideoImageCache = new FileSystemRepository(VideoImagesDataPath);
            SubtitleCache = new FileSystemRepository(SubtitleCachePath);
        }
Esempio n. 19
0
 public UserViewManager(ILibraryManager libraryManager, ILocalizationManager localizationManager, IFileSystem fileSystem, IUserManager userManager, IChannelManager channelManager, ILiveTvManager liveTvManager, IServerApplicationPaths appPaths, IPlaylistManager playlists)
 {
     _libraryManager = libraryManager;
     _localizationManager = localizationManager;
     _fileSystem = fileSystem;
     _userManager = userManager;
     _channelManager = channelManager;
     _liveTvManager = liveTvManager;
     _appPaths = appPaths;
     _playlists = playlists;
 }
Esempio n. 20
0
        public LiveTvManager(IServerApplicationPaths appPaths, IFileSystem fileSystem, ILogger logger, IItemRepository itemRepo, IImageProcessor imageProcessor, ILocalizationManager localization, IUserDataManager userDataManager, IDtoService dtoService, IUserManager userManager)
        {
            _appPaths = appPaths;
            _fileSystem = fileSystem;
            _logger = logger;
            _itemRepo = itemRepo;
            _localization = localization;
            _userManager = userManager;

            _tvDtoService = new LiveTvDtoService(dtoService, userDataManager, imageProcessor, logger);
        }
Esempio n. 21
0
 public HdHomerunLiveStream(MediaSourceInfo mediaSource, string originalStreamId, IFileSystem fileSystem, IHttpClient httpClient, ILogger logger, IServerApplicationPaths appPaths, IServerApplicationHost appHost)
     : base(mediaSource)
 {
     _fileSystem = fileSystem;
     _httpClient = httpClient;
     _logger = logger;
     _appPaths = appPaths;
     _appHost = appHost;
     OriginalStreamId = originalStreamId;
     _multicastStream = new MulticastStream(_logger);
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="SqliteUserRepository" /> class.
        /// </summary>
        /// <param name="jsonSerializer">The json serializer.</param>
        /// <param name="logManager">The log manager.</param>
        /// <param name="appPaths">The app paths.</param>
        /// <exception cref="System.ArgumentNullException">appPaths</exception>
        public SqliteUserRepository(IJsonSerializer jsonSerializer, ILogManager logManager, IServerApplicationPaths appPaths)
        {
            if (jsonSerializer == null)
            {
                throw new ArgumentNullException("jsonSerializer");
            }

            _jsonSerializer = jsonSerializer;
            _appPaths = appPaths;

            _logger = logManager.GetLogger(GetType().Name);
        }
Esempio n. 23
0
        /// <summary>
        /// Removes the virtual folder.
        /// </summary>
        /// <param name="name">The name.</param>
        /// <param name="user">The user.</param>
        /// <param name="appPaths">The app paths.</param>
        /// <exception cref="System.IO.DirectoryNotFoundException">The media folder does not exist</exception>
        public static void RemoveVirtualFolder(string name, User user, IServerApplicationPaths appPaths)
        {
            var rootFolderPath = user != null ? user.RootFolderPath : appPaths.DefaultUserViewsPath;
            var path = Path.Combine(rootFolderPath, name);

            if (!Directory.Exists(path))
            {
                throw new DirectoryNotFoundException("The media folder does not exist");
            }

            Directory.Delete(path, true);
        }
Esempio n. 24
0
        /// <summary>
        /// Adds the virtual folder.
        /// </summary>
        /// <param name="name">The name.</param>
        /// <param name="user">The user.</param>
        /// <param name="appPaths">The app paths.</param>
        /// <exception cref="System.ArgumentException">There is already a media collection with the name  + name + .</exception>
        public static void AddVirtualFolder(string name, User user, IServerApplicationPaths appPaths)
        {
            name = FileSystem.GetValidFilename(name);

            var rootFolderPath = user != null ? user.RootFolderPath : appPaths.DefaultUserViewsPath;
            var virtualFolderPath = Path.Combine(rootFolderPath, name);

            if (Directory.Exists(virtualFolderPath))
            {
                throw new ArgumentException("There is already a media collection with the name " + name + ".");
            }

            Directory.CreateDirectory(virtualFolderPath);
        }
Esempio n. 25
0
        public LuceneSearchEngine(IServerApplicationPaths serverPaths, ILogManager logManager, ILibraryManager libraryManager)
        {
            _libraryManager = libraryManager;

            _logger = logManager.GetLogger("Lucene");

            //string luceneDbPath = serverPaths.DataPath + "\\SearchIndexDB";
            //if (!System.IO.Directory.Exists(luceneDbPath))
            //    System.IO.Directory.CreateDirectory(luceneDbPath);
            //else if(File.Exists(luceneDbPath + "\\write.lock"))
            //        File.Delete(luceneDbPath + "\\write.lock");

            //LuceneSearch.Init(luceneDbPath, _logger);

            //BaseItem.LibraryManager.LibraryChanged += LibraryChanged;
        }
Esempio n. 26
0
        /// <summary>
        /// Deletes a shortcut from within a virtual folder, within either the default view or a user view
        /// </summary>
        /// <param name="fileSystem">The file system.</param>
        /// <param name="virtualFolderName">Name of the virtual folder.</param>
        /// <param name="mediaPath">The media path.</param>
        /// <param name="user">The user.</param>
        /// <param name="appPaths">The app paths.</param>
        /// <exception cref="System.IO.DirectoryNotFoundException">The media folder does not exist</exception>
        public static void RemoveMediaPath(IFileSystem fileSystem, string virtualFolderName, string mediaPath, User user, IServerApplicationPaths appPaths)
        {
            var rootFolderPath = user != null ? user.RootFolderPath : appPaths.DefaultUserViewsPath;
            var path = Path.Combine(rootFolderPath, virtualFolderName);

            if (!Directory.Exists(path))
            {
                throw new DirectoryNotFoundException(string.Format("The media collection {0} does not exist", virtualFolderName));
            }

            var shortcut = Directory.EnumerateFiles(path, ShortcutFileSearch, SearchOption.AllDirectories).FirstOrDefault(f => fileSystem.ResolveShortcut(f).Equals(mediaPath, StringComparison.OrdinalIgnoreCase));

            if (!string.IsNullOrEmpty(shortcut))
            {
                File.Delete(shortcut);
            }
        }
Esempio n. 27
0
        public ImageProcessor(ILogger logger,
            IServerApplicationPaths appPaths,
            IFileSystem fileSystem,
            IJsonSerializer jsonSerializer,
            IImageEncoder imageEncoder,
            int maxConcurrentImageProcesses, Func<ILibraryManager> libraryManager)
        {
            _logger = logger;
            _fileSystem = fileSystem;
            _jsonSerializer = jsonSerializer;
            _imageEncoder = imageEncoder;
            _libraryManager = libraryManager;
            _appPaths = appPaths;

            ImageEnhancers = new List<IImageEnhancer>();
            _saveImageSizeTimer = new Timer(SaveImageSizeCallback, null, Timeout.Infinite, Timeout.Infinite);

            Dictionary<Guid, ImageSize> sizeDictionary;

            try
            {
                sizeDictionary = jsonSerializer.DeserializeFromFile<Dictionary<Guid, ImageSize>>(ImageSizeFile) ??
                    new Dictionary<Guid, ImageSize>();
            }
            catch (FileNotFoundException)
            {
                // No biggie
                sizeDictionary = new Dictionary<Guid, ImageSize>();
            }
            catch (DirectoryNotFoundException)
            {
                // No biggie
                sizeDictionary = new Dictionary<Guid, ImageSize>();
            }
            catch (Exception ex)
            {
                logger.ErrorException("Error parsing image size cache file", ex);

                sizeDictionary = new Dictionary<Guid, ImageSize>();
            }

            _cachedImagedSizes = new ConcurrentDictionary<Guid, ImageSize>(sizeDictionary);
            _logger.Info("ImageProcessor started with {0} max concurrent image processes", maxConcurrentImageProcesses);
            _imageProcessingSemaphore = new SemaphoreSlim(maxConcurrentImageProcesses, maxConcurrentImageProcesses);
        }
Esempio n. 28
0
        /// <summary>
        /// Adds an additional mediaPath to an existing virtual folder, within either the default view or a user view
        /// </summary>
        /// <param name="fileSystem">The file system.</param>
        /// <param name="virtualFolderName">Name of the virtual folder.</param>
        /// <param name="path">The path.</param>
        /// <param name="user">The user.</param>
        /// <param name="appPaths">The app paths.</param>
        /// <exception cref="System.ArgumentException">The path is not valid.</exception>
        /// <exception cref="System.IO.DirectoryNotFoundException">The path does not exist.</exception>
        public static void AddMediaPath(IFileSystem fileSystem, string virtualFolderName, string path, User user, IServerApplicationPaths appPaths)
        {
            if (!Directory.Exists(path))
            {
                throw new DirectoryNotFoundException("The path does not exist.");
            }

            var rootFolderPath = user != null ? user.RootFolderPath : appPaths.DefaultUserViewsPath;
            var virtualFolderPath = Path.Combine(rootFolderPath, virtualFolderName);

            var shortcutFilename = Path.GetFileNameWithoutExtension(path);

            var lnk = Path.Combine(virtualFolderPath, shortcutFilename + ShortcutFileExtension);

            while (File.Exists(lnk))
            {
                shortcutFilename += "1";
                lnk = Path.Combine(virtualFolderPath, shortcutFilename + ShortcutFileExtension);
            }

            fileSystem.CreateShortcut(lnk, path);
        }
        public static void Main()
        {
            var options = new StartupOptions(Environment.GetCommandLineArgs());

            IsRunningAsService = options.ContainsOption("-service");

            var currentProcess = Process.GetCurrentProcess();

            ApplicationPath = currentProcess.MainModule.FileName;
            var architecturePath = Path.Combine(Path.GetDirectoryName(ApplicationPath), Environment.Is64BitProcess ? "x64" : "x86");

            var success = SetDllDirectory(architecturePath);

            SQLitePCL.raw.SetProvider(new SQLitePCL.SQLite3Provider_sqlite3());

            var appPaths = CreateApplicationPaths(ApplicationPath, IsRunningAsService);

            _appPaths = appPaths;

            using (var logManager = new SimpleLogManager(appPaths.LogDirectoryPath, "server"))
            {
                _logManager = logManager;

                var task = logManager.ReloadLogger(LogSeverity.Debug, CancellationToken.None);
                Task.WaitAll(task);

                logManager.AddConsoleOutput();

                var logger = _logger = logManager.GetLogger("Main");

                ApplicationHost.LogEnvironmentInfo(logger, appPaths, true);

                // Uninstall directly
                if (options.ContainsOption("-uninstallservice"))
                {
                    logger.Info("Performing service uninstallation");
                    UninstallService(ApplicationPath, logger);
                    return;
                }

                // Restart with admin rights, then uninstall
                if (options.ContainsOption("-uninstallserviceasadmin"))
                {
                    logger.Info("Performing service uninstallation");
                    RunServiceUninstallation(ApplicationPath);
                    return;
                }

                AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;

                if (IsAlreadyRunning(ApplicationPath, currentProcess))
                {
                    logger.Info("Shutting down because another instance of Emby Server is already running.");
                    return;
                }

                if (PerformUpdateIfNeeded(appPaths, logger))
                {
                    logger.Info("Exiting to perform application update.");
                    return;
                }

                RunApplication(appPaths, logManager, IsRunningAsService, options);

                logger.Info("Shutdown complete");

                if (_restartOnShutdown)
                {
                    logger.Info("Starting new server process");
                    var restartCommandLine = GetRestartCommandLine();

                    Process.Start(restartCommandLine.Item1, restartCommandLine.Item2);
                }
            }
        }
Esempio n. 30
0
 public SyncRepository(ILogManager logManager, IJsonSerializer json, IServerApplicationPaths appPaths, IDbConnector connector)
     : base(logManager, connector)
 {
     _json      = json;
     DbFilePath = Path.Combine(appPaths.DataPath, "sync14.db");
 }
 public HlsSegmentService(IServerApplicationPaths appPaths)
 {
     _appPaths = appPaths;
 }
Esempio n. 32
0
 public HdHomerunHttpStream(MediaSourceInfo mediaSource, string originalStreamId, IFileSystem fileSystem, IHttpClient httpClient, ILogger logger, IServerApplicationPaths appPaths, IServerApplicationHost appHost, IEnvironmentInfo environment)
     : base(mediaSource, environment, fileSystem, logger, appPaths)
 {
     _httpClient      = httpClient;
     _appHost         = appHost;
     OriginalStreamId = originalStreamId;
 }
Esempio n. 33
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MigrateDisplayPreferencesDb"/> class.
 /// </summary>
 /// <param name="logger">The logger.</param>
 /// <param name="paths">The server application paths.</param>
 /// <param name="provider">The database provider.</param>
 public MigrateDisplayPreferencesDb(ILogger <MigrateDisplayPreferencesDb> logger, IServerApplicationPaths paths, JellyfinDbProvider provider)
 {
     _logger      = logger;
     _paths       = paths;
     _provider    = provider;
     _jsonOptions = new JsonSerializerOptions();
     _jsonOptions.Converters.Add(new JsonStringEnumConverter());
 }
Esempio n. 34
0
 public ActivityRepository(ILogger <ActivityRepository> logger, IServerApplicationPaths appPaths, IFileSystem fileSystem)
     : base(logger)
 {
     DbFilePath  = Path.Combine(appPaths.DataPath, "activitylog.db");
     _fileSystem = fileSystem;
 }
Esempio n. 35
0
 public HdHomerunUdpStream(MediaSourceInfo mediaSource, TunerHostInfo tunerHostInfo, string originalStreamId, IHdHomerunChannelCommands channelCommands, int numTuners, IFileSystem fileSystem, IHttpClient httpClient, ILogger logger, IServerApplicationPaths appPaths, IServerApplicationHost appHost, MediaBrowser.Model.Net.ISocketFactory socketFactory, INetworkManager networkManager)
     : base(mediaSource, tunerHostInfo, fileSystem, logger, appPaths)
 {
     _appHost            = appHost;
     _socketFactory      = socketFactory;
     _networkManager     = networkManager;
     OriginalStreamId    = originalStreamId;
     _channelCommands    = channelCommands;
     _numTuners          = numTuners;
     EnableStreamSharing = true;
 }
Esempio n. 36
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ProviderManager" /> class.
 /// </summary>
 public ProviderManager(IHttpClient httpClient, ISubtitleManager subtitleManager, IServerConfigurationManager configurationManager, ILibraryMonitor libraryMonitor, ILoggerFactory loggerFactory, IFileSystem fileSystem, IServerApplicationPaths appPaths, Func <ILibraryManager> libraryManagerFactory, IJsonSerializer json)
 {
     _logger                = loggerFactory.CreateLogger("ProviderManager");
     _httpClient            = httpClient;
     ConfigurationManager   = configurationManager;
     _libraryMonitor        = libraryMonitor;
     _fileSystem            = fileSystem;
     _appPaths              = appPaths;
     _libraryManagerFactory = libraryManagerFactory;
     _json            = json;
     _subtitleManager = subtitleManager;
 }
Esempio n. 37
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MigrateAuthenticationDb"/> class.
 /// </summary>
 /// <param name="logger">The logger.</param>
 /// <param name="dbProvider">The database provider.</param>
 /// <param name="appPaths">The server application paths.</param>
 public MigrateAuthenticationDb(ILogger <MigrateAuthenticationDb> logger, JellyfinDbProvider dbProvider, IServerApplicationPaths appPaths)
 {
     _logger     = logger;
     _dbProvider = dbProvider;
     _appPaths   = appPaths;
 }
 public AuthenticationRepository(ILogManager logManager, IServerApplicationPaths appPaths, IDbConnector connector)
     : base(logManager, connector)
 {
     _appPaths  = appPaths;
     DbFilePath = Path.Combine(appPaths.DataPath, "authentication.db");
 }
Esempio n. 39
0
 public DeprecatePlugins(IServerApplicationPaths appPaths)
 {
     _appPaths = appPaths;
 }
Esempio n. 40
0
 public SpecialFolderResolver(IFileSystem fileSystem, IServerApplicationPaths appPaths)
 {
     _fileSystem = fileSystem;
     _appPaths   = appPaths;
 }
Esempio n. 41
0
 public SharedHttpStream(MediaSourceInfo mediaSource, TunerHostInfo tunerHostInfo, string originalStreamId, IFileSystem fileSystem, IHttpClient httpClient, ILogger logger, IServerApplicationPaths appPaths, IServerApplicationHost appHost)
     : base(mediaSource, tunerHostInfo, fileSystem, logger, appPaths)
 {
     _httpClient         = httpClient;
     _appHost            = appHost;
     OriginalStreamId    = originalStreamId;
     EnableStreamSharing = true;
 }
Esempio n. 42
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AddPeopleQueryIndex"/> class.
 /// </summary>
 /// <param name="logger">Instance of the <see cref="ILogger{AddPeopleQueryIndex}"/> interface.</param>
 /// <param name="serverApplicationPaths">Instance of the <see cref="IServerApplicationPaths"/> interface.</param>
 public AddPeopleQueryIndex(ILogger <AddPeopleQueryIndex> logger, IServerApplicationPaths serverApplicationPaths)
 {
     _logger = logger;
     _serverApplicationPaths = serverApplicationPaths;
 }
Esempio n. 43
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ProviderManager" /> class.
 /// </summary>
 /// <param name="httpClient">The HTTP client.</param>
 /// <param name="configurationManager">The configuration manager.</param>
 /// <param name="libraryMonitor">The directory watchers.</param>
 /// <param name="logManager">The log manager.</param>
 /// <param name="fileSystem">The file system.</param>
 public ProviderManager(IHttpClient httpClient, IServerConfigurationManager configurationManager, ILibraryMonitor libraryMonitor, ILogManager logManager, IFileSystem fileSystem, IServerApplicationPaths appPaths, Func <ILibraryManager> libraryManagerFactory)
 {
     _logger                = logManager.GetLogger("ProviderManager");
     _httpClient            = httpClient;
     ConfigurationManager   = configurationManager;
     _libraryMonitor        = libraryMonitor;
     _fileSystem            = fileSystem;
     _appPaths              = appPaths;
     _libraryManagerFactory = libraryManagerFactory;
 }
Esempio n. 44
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ImageManager" /> class.
        /// </summary>
        /// <param name="kernel">The kernel.</param>
        /// <param name="protobufSerializer">The protobuf serializer.</param>
        /// <param name="logger">The logger.</param>
        public ImageManager(Kernel kernel, IProtobufSerializer protobufSerializer, ILogger logger, IServerApplicationPaths appPaths)
        {
            _protobufSerializer = protobufSerializer;
            _logger             = logger;
            _kernel             = kernel;

            ImageSizeCache     = new FileSystemRepository(Path.Combine(appPaths.ImageCachePath, "image-sizes"));
            ResizedImageCache  = new FileSystemRepository(Path.Combine(appPaths.ImageCachePath, "resized-images"));
            CroppedImageCache  = new FileSystemRepository(Path.Combine(appPaths.ImageCachePath, "cropped-images"));
            EnhancedImageCache = new FileSystemRepository(Path.Combine(appPaths.ImageCachePath, "enhanced-images"));
        }
Esempio n. 45
0
 public MovieResolver(ILibraryManager libraryManager, IServerApplicationPaths applicationPaths, ILogger logger, IFileSystem fileSystem) : base(libraryManager)
 {
     _applicationPaths = applicationPaths;
     _logger           = logger;
     _fileSystem       = fileSystem;
 }
Esempio n. 46
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ProviderManager" /> class.
 /// </summary>
 /// <param name="httpClient">The HTTP client.</param>
 /// <param name="configurationManager">The configuration manager.</param>
 /// <param name="libraryMonitor">The directory watchers.</param>
 /// <param name="logManager">The log manager.</param>
 /// <param name="fileSystem">The file system.</param>
 public ProviderManager(IHttpClient httpClient, IServerConfigurationManager configurationManager, ILibraryMonitor libraryMonitor, ILogManager logManager, IFileSystem fileSystem, IServerApplicationPaths appPaths, Func <ILibraryManager> libraryManagerFactory, IJsonSerializer json, IMemoryStreamProvider memoryStreamProvider)
 {
     _logger                = logManager.GetLogger("ProviderManager");
     _httpClient            = httpClient;
     ConfigurationManager   = configurationManager;
     _libraryMonitor        = libraryMonitor;
     _fileSystem            = fileSystem;
     _appPaths              = appPaths;
     _libraryManagerFactory = libraryManagerFactory;
     _json = json;
     _memoryStreamProvider = memoryStreamProvider;
 }
Esempio n. 47
0
        public LiveStream(MediaSourceInfo mediaSource, TunerHostInfo tuner, IFileSystem fileSystem, ILogger logger, IServerApplicationPaths appPaths)
        {
            OriginalMediaSource = mediaSource;
            FileSystem          = fileSystem;
            MediaSource         = mediaSource;
            Logger = logger;
            EnableStreamSharing = true;
            UniqueId            = Guid.NewGuid().ToString("N");

            if (tuner != null)
            {
                TunerHostId = tuner.Id;
            }

            AppPaths = appPaths;

            ConsumerCount = 1;
            SetTempFilePath("ts");
        }
 public SqliteNotificationsRepository(ILogger logger, IServerApplicationPaths appPaths, IFileSystem fileSystem) : base(logger)
 {
     FileSystem = fileSystem;
     DbFilePath = Path.Combine(appPaths.DataPath, "notifications.db");
 }
Esempio n. 49
0
 public RemoteImageService(IProviderManager providerManager, IDtoService dtoService, IServerApplicationPaths appPaths, IHttpClient httpClient, IFileSystem fileSystem, ILibraryManager libraryManager)
 {
     _providerManager = providerManager;
     _dtoService      = dtoService;
     _appPaths        = appPaths;
     _httpClient      = httpClient;
     _fileSystem      = fileSystem;
     _libraryManager  = libraryManager;
 }
Esempio n. 50
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AudioHlsService" /> class.
 /// </summary>
 /// <param name="appPaths">The app paths.</param>
 /// <param name="userManager">The user manager.</param>
 /// <param name="libraryManager">The library manager.</param>
 /// <param name="isoManager">The iso manager.</param>
 /// <param name="mediaEncoder">The media encoder.</param>
 public AudioHlsService(IServerApplicationPaths appPaths, IUserManager userManager, ILibraryManager libraryManager, IIsoManager isoManager, IMediaEncoder mediaEncoder, IDtoService dtoService, IFileSystem fileSystem)
     : base(appPaths, userManager, libraryManager, isoManager, mediaEncoder, dtoService, fileSystem)
 {
 }
Esempio n. 51
0
 public SmartPlaylistFileSystem(IServerApplicationPaths serverApplicationPaths)
 {
     BasePath = Path.Combine(serverApplicationPaths.DataPath, "smartplaylists");
 }
Esempio n. 52
0
 public DeleteDlnaProfiles(IServerApplicationPaths appPaths, IFileSystem fileSystem)
 {
     _appPaths   = appPaths;
     _fileSystem = fileSystem;
 }
Esempio n. 53
0
        public LiveStream(MediaSourceInfo mediaSource, TunerHostInfo tuner, IEnvironmentInfo environment, IFileSystem fileSystem, ILogger logger, IServerApplicationPaths appPaths)
        {
            OriginalMediaSource = mediaSource;
            Environment         = environment;
            FileSystem          = fileSystem;
            OpenedMediaSource   = mediaSource;
            Logger = logger;
            EnableStreamSharing = true;
            SharedStreamIds     = new List <string>();
            UniqueId            = Guid.NewGuid().ToString("N");
            TunerHostId         = tuner.Id;
            TunerHostDeviceId   = tuner.DeviceId;

            AppPaths = appPaths;

            SetTempFilePath("ts");
        }
Esempio n. 54
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AudioHlsService" /> class.
 /// </summary>
 /// <param name="appPaths">The app paths.</param>
 /// <param name="userManager">The user manager.</param>
 /// <param name="libraryManager">The library manager.</param>
 /// <param name="isoManager">The iso manager.</param>
 /// <param name="mediaEncoder">The media encoder.</param>
 public AudioHlsService(IServerApplicationPaths appPaths, IUserManager userManager, ILibraryManager libraryManager, IIsoManager isoManager, IMediaEncoder mediaEncoder)
     : base(appPaths, userManager, libraryManager, isoManager, mediaEncoder)
 {
 }
Esempio n. 55
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ItemResolveArgs" /> class.
 /// </summary>
 /// <param name="appPaths">The app paths.</param>
 /// <param name="libraryManager">The library manager.</param>
 public ItemResolveArgs(IServerApplicationPaths appPaths, ILibraryManager libraryManager)
 {
     _appPaths = appPaths;
     _libraryManager = libraryManager;
 }
Esempio n. 56
0
 public HlsSegmentService(IServerApplicationPaths appPaths, IServerConfigurationManager config, IFileSystem fileSystem)
 {
     _appPaths   = appPaths;
     _config     = config;
     _fileSystem = fileSystem;
 }
Esempio n. 57
0
 public EncodedRecorder(ILogger logger, IFileSystem fileSystem, IMediaEncoder mediaEncoder, IServerApplicationPaths appPaths, IJsonSerializer json, LiveTvOptions liveTvOptions, IHttpClient httpClient, IProcessFactory processFactory)
 {
     _logger         = logger;
     _fileSystem     = fileSystem;
     _mediaEncoder   = mediaEncoder;
     _appPaths       = appPaths;
     _json           = json;
     _liveTvOptions  = liveTvOptions;
     _httpClient     = httpClient;
     _processFactory = processFactory;
 }
Esempio n. 58
0
 public SqliteNotificationsRepository(ILogManager logManager, IServerApplicationPaths appPaths)
     : base(logManager)
 {
     _appPaths = appPaths;
 }
Esempio n. 59
0
 /// <summary>
 /// Initializes a new instance of the <see cref="BaseStreamingService" /> class.
 /// </summary>
 /// <param name="appPaths">The app paths.</param>
 /// <param name="userManager">The user manager.</param>
 /// <param name="libraryManager">The library manager.</param>
 /// <param name="isoManager">The iso manager.</param>
 /// <param name="mediaEncoder">The media encoder.</param>
 public VideoHlsService(IServerApplicationPaths appPaths, IUserManager userManager, ILibraryManager libraryManager, IIsoManager isoManager, IMediaEncoder mediaEncoder, IDtoService dtoService)
     : base(appPaths, userManager, libraryManager, isoManager, mediaEncoder, dtoService)
 {
 }
Esempio n. 60
0
 public AuthenticationRepository(ILogger logger, IServerApplicationPaths appPaths)
     : base(logger)
 {
     _appPaths  = appPaths;
     DbFilePath = Path.Combine(appPaths.DataPath, "authentication.db");
 }