Esempio n. 1
0
        public IEnumerable <Library> GetMediaServerLibraries()
        {
            var rootItems = _httpClient.GetMediaFolders();

            var libraries = rootItems.Items
                            .Select(LibraryConverter.ConvertToLibrary)
                            .Where(x => x.Type != LibraryType.BoxSets)
                            .ToList();

            _libraryRepository.AddOrUpdateRange(libraries);
            return(libraries);
        }
Esempio n. 2
0
        public override async Task RunJobAsync()
        {
            var cancellationToken = new CancellationToken(false);


            if (!Settings.WizardFinished)
            {
                await LogWarning("Media sync task not running because wizard is not yet finished!");

                return;
            }

            if (!IsMediaServerOnline())
            {
                await LogWarning($"Halting task because we can't contact the server on {Settings.MediaServer.FullMediaServerAddress}, please check the connection and try again.");

                return;
            }

            await LogInformation("First delete all existing media and root media libraries from database so we have a clean start.");
            await LogProgress(3);

            var libraries = await GetLibrariesAsync();

            _libraryRepository.AddOrUpdateRange(libraries);
            await LogInformation($"Found {libraries.Count} root items, getting ready for processing");
            await LogProgress(15);

            await ProcessMoviesAsync(libraries, cancellationToken);
            await LogProgress(55);


            await ProcessShowsAsync(libraries, cancellationToken);
            await LogProgress(85);

            await CalculateStatistics();
            await LogProgress(100);
        }