Пример #1
0
        public async Task <ActionResult <Series> > GetById(int seriesId)
        {
            var client = new SonarrClient("localhost", 8989, "2e8fcac32bf147608239cab343617485");
            var series = await client.Series.GetSeries(seriesId, true);

            return(Ok(series));
        }
Пример #2
0
        public SonarrScanner(
            IOptions <SonarrConfig> config)
        {
            var clientConfig = config.Value;

            _client = new SonarrClient(clientConfig.Host, clientConfig.Port, clientConfig.ApiKey);
        }
Пример #3
0
        public void Setup()
        {
            var fixture = new ConfigurationFixture();

            _servicePath  = fixture.ServicePath;
            _apiKeys      = fixture.ApiKeys;
            _sonarrClient = fixture.sonarrClient;
        }
Пример #4
0
 public ChatBot(IServiceProvider serviceProvider, ILogger <ChatBot> logger, DiscordSettingsProvider discordSettingsProvider)
 {
     _logger                  = logger;
     _serviceProvider         = serviceProvider;
     _discordSettingsProvider = discordSettingsProvider;
     _ombiDownloadClient      = new OmbiClient(serviceProvider.Get <IHttpClientFactory>(), serviceProvider.Get <ILogger <OmbiClient> >(), serviceProvider.Get <OmbiSettingsProvider>());
     _radarrDownloadClient    = new RadarrClient(serviceProvider.Get <IHttpClientFactory>(), serviceProvider.Get <ILogger <RadarrClient> >(), serviceProvider.Get <RadarrSettingsProvider>());
     _sonarrDownloadClient    = new SonarrClient(serviceProvider.Get <IHttpClientFactory>(), serviceProvider.Get <ILogger <SonarrClient> >(), serviceProvider.Get <SonarrSettingsProvider>());
 }
Пример #5
0
        public void ShouldCreateClientWithCorrectUrl()
        {
            // Arrange
            // Act
            var sut = new SonarrClient(null, new Uri(ServerAddress));

            // Assert
            Assert.Equal("http://sonarr.in.nativecode.com/api/", sut.BaseAddress.ToString());
        }
Пример #6
0
 public ChatBot(IServiceProvider serviceProvider, ILogger <ChatBot> logger, DiscordSettingsProvider discordSettingsProvider)
 {
     _logger                  = logger;
     _serviceProvider         = serviceProvider;
     _discordSettingsProvider = discordSettingsProvider;
     _overseerrClient         = new OverseerrClient(serviceProvider.Get <IHttpClientFactory>(), serviceProvider.Get <ILogger <OverseerrClient> >(), serviceProvider.Get <OverseerrSettingsProvider>());
     _ombiDownloadClient      = new OmbiClient(serviceProvider.Get <IHttpClientFactory>(), serviceProvider.Get <ILogger <OmbiClient> >(), serviceProvider.Get <OmbiSettingsProvider>());
     _radarrDownloadClient    = new RadarrClient(serviceProvider.Get <IHttpClientFactory>(), serviceProvider.Get <ILogger <RadarrClient> >(), serviceProvider.Get <RadarrSettingsProvider>());
     _sonarrDownloadClient    = new SonarrClient(serviceProvider.Get <IHttpClientFactory>(), serviceProvider.Get <ILogger <SonarrClient> >(), serviceProvider.Get <SonarrSettingsProvider>());
     _movieWorkflowFactory    = new MovieWorkflowFactory(_discordSettingsProvider, _movieNotificationRepository, _overseerrClient, _ombiDownloadClient, _radarrDownloadClient);
     _tvShowWorkflowFactory   = new TvShowWorkflowFactory(serviceProvider.Get <TvShowsSettingsProvider>(), _discordSettingsProvider, _tvShowNotificationRepository, _overseerrClient, _ombiDownloadClient, _sonarrDownloadClient);
 }
Пример #7
0
        public async Task <IActionResult> TestSonarrSettings([FromBody] TestSonarrSettingsModel model)
        {
            try
            {
                await SonarrClient.TestConnectionAsync(_httpClientFactory.CreateClient(), _logger, ConvertToSonarrSettings(model));

                return(Ok(new { ok = true }));
            }
            catch (System.Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
Пример #8
0
 public TvShowWorkflowFactory(
     TvShowsSettingsProvider tvShowsSettingsProvider,
     DiscordSettingsProvider settingsProvider,
     TvShowNotificationsRepository notificationsRepository,
     OverseerrClient overseerrClient,
     OmbiClient ombiDownloadClient,
     SonarrClient radarrDownloadClient)
 {
     _tvShowsSettingsProvider = tvShowsSettingsProvider;
     _settingsProvider        = settingsProvider;
     _notificationsRepository = notificationsRepository;
     _overseerrClient         = overseerrClient;
     _ombiDownloadClient      = ombiDownloadClient;
     _sonarrDownloadClient    = radarrDownloadClient;
 }
Пример #9
0
        public async Task <bool> Start()
        {
            if (!string.IsNullOrEmpty(_sonarrConfig.ApiKey) && !string.IsNullOrEmpty(_sonarrConfig.Host))
            {
                _sonarrClient = new SonarrClient(_sonarrConfig.Host, _sonarrConfig.Port, _sonarrConfig.ApiKey);

                var calendar = await _sonarrClient.Calendar.GetCalendar(DateTime.Now, DateTime.Now.AddDays(30));

                foreach (var item in calendar)
                {
                    _logger.LogInformation($"{item.AirDate}: {item.Series.Title} - s{item.SeasonNumber}e{item.EpisodeNumber} - {item.Title}");
                }
            }

            return(true);
        }
Пример #10
0
        public async Task <IActionResult> GetSonarrRootPaths([FromBody] TestSonarrSettingsModel model)
        {
            try
            {
                var paths = await SonarrClient.GetRootPaths(_httpClientFactory.CreateClient(), _logger, ConvertToSonarrSettings(model));

                return(Ok(paths.Select(x => new SonarrPath
                {
                    Id = x.id,
                    Path = x.path
                })));
            }
            catch (System.Exception)
            {
                return(BadRequest($"Could not load the paths from Sonarr, check your settings."));
            }
        }
Пример #11
0
        public async Task <IActionResult> GetSonarrLanguages([FromBody] TestSonarrSettingsModel model)
        {
            try
            {
                var profiles = await SonarrClient.GetLanguages(_httpClientFactory.CreateClient(), _logger, ConvertToSonarrSettings(model));

                return(Ok(profiles.Select(x => new SonarrLanguage
                {
                    Id = x.id,
                    Name = x.name
                })));
            }
            catch (System.Exception)
            {
                return(BadRequest($"Could not load the profiles from Sonarr, check your settings."));
            }
        }
Пример #12
0
        public async Task <ActionResult> Get(int episodeFileId, [FromQuery] int fromSeconds, [FromQuery] bool startInFullscreen)
        {
            var client      = new SonarrClient("localhost", 8989, "2e8fcac32bf147608239cab343617485");
            var episodeFile = await client.EpisodeFile.GetEpisodeFile(episodeFileId);

            var mpcHcClient = new MediaPlayerClient("localhost", 50051);

            var startPosition = TimeSpan.FromSeconds(fromSeconds);

            var initRepsonse = await mpcHcClient.Init(@"C:\Program Files (x86)\MPC-HC\mpc-hc.exe");

            if (initRepsonse.IsError)
            {
                return(StatusCode(502));
            }

            var isRunningResponse = await mpcHcClient.CheckIfMediaPlayerIsRunning();

            if (isRunningResponse.IsError)
            {
                return(StatusCode(502));
            }

            if (isRunningResponse.Response.Value)
            {
                var stopResponse = await mpcHcClient.CloseMediaPlayer();

                if (stopResponse.IsError)
                {
                    return(StatusCode(502));
                }
            }

            var startResponse = await mpcHcClient.OpenMediaPlayer();

            if (startResponse.IsError)
            {
                return(StatusCode(502));
            }

            await mpcHcClient.OpenFile(episodeFile.Path, startPosition, startInFullscreen);

            CurrentlyPlayingManager.EpisodeFile = episodeFile;

            return(Ok());
        }
Пример #13
0
        public override Task <bool> Start()
        {
            if (Config.Api.ApiKey == "change_me")
            {
                ThrowComponentNeedConfiguration("ApiKey");
            }

            if (Config.Server.Hostname == "change_me")
            {
                ThrowComponentNeedConfiguration("Hostname", "Port");
            }

            _isConfigured = true;

            _sonarrClient = new SonarrClient(Config.Server.Hostname, Config.Server.Port, Config.Api.ApiKey);


            return(base.Start());
        }
Пример #14
0
        public MainWindow()
        {
            InitializeComponent();
            DataContext = this;

            _sClient = new SonarrClient("http://192.168.1.50:8989/api/", "9f7f7589ac1942cea5ec5cecdc431945");
            _kClient = new KodiClient("192.168.1.180", userName: "******", password: "******");

            _tvSort = x => x.OrderBy(y => y.Sonarr.Title);

            TvSortByNameCommand = new DelegateCommand(TvSortByName);
            TvSortBySizeCommand = new DelegateCommand(TvSortBySize);
            TvDeleteCommand     = new DelegateCommand(async _ => await DeleteAsync());

            Series         = new ObservableCollection <Series>();
            FilteredSeries = new ObservableCollection <Series>();

            Movies = new ObservableCollection <Movie>();
        }
Пример #15
0
        public ConfigurationFixture()
        {
            #region Configuration classes
            var basePath = Path.GetFullPath("../../../../MediaRequest/");

            configurationBuilder = new ConfigurationBuilder()
                                   .SetBasePath(basePath)
                                   .AddYamlFile("settings.yaml", false, true)
                                   .Build();

            ServicePath = Options.Create(GetServicePathConfiguration());
            ApiKeys     = Options.Create(GetApiKeysConfiguration());

            #region Sonarr
            var sonarrHttpClient = new HttpClient()
            {
                BaseAddress = new Uri(ServicePath.Value.Sonarr),
            };
            sonarrHttpClient.DefaultRequestHeaders.Add("X-Api-Key", ApiKeys.Value.Sonarr);
            sonarrClient = new SonarrClient(sonarrHttpClient);
            #endregion

            #region Radarr
            var radarrHttpClient = new HttpClient()
            {
                BaseAddress = new Uri(ServicePath.Value.Radarr),
            };
            radarrHttpClient.DefaultRequestHeaders.Add("X-Api-Key", ApiKeys.Value.Radarr);
            radarrClient = new RadarrClient(radarrHttpClient);
            #endregion

            tmdbClient = new TMDBClient(new System.Net.Http.HttpClient()
            {
                BaseAddress = new System.Uri(ServicePath.Value.TMDB)
            });

            #endregion
        }
Пример #16
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Parse"/> class.
 /// </summary>
 /// <param name="sonarrClient">The sonarr client.</param>
 public Parse(SonarrClient sonarrClient)
 {
     _sonarrClient = sonarrClient;
 }
Пример #17
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Series"/> class.
 /// </summary>
 /// <param name="sonarrClient">The sonarr client.</param>
 public Series(SonarrClient sonarrClient)
 {
     _sonarrClient = sonarrClient;
 }
Пример #18
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ReleasePush"/> class.
 /// </summary>
 /// <param name="sonarrClient">The sonarr client.</param>
 public ReleasePush(SonarrClient sonarrClient)
 {
     _sonarrClient = sonarrClient;
 }
Пример #19
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SystemStatus"/> class.
 /// </summary>
 /// <param name="sonarrClient">The sonarr client.</param>
 public SystemStatus(SonarrClient sonarrClient)
 {
     _sonarrClient = sonarrClient;
 }
Пример #20
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Profile"/> class.
 /// </summary>
 /// <param name="sonarrClient">The sonarr client.</param>
 public Profile(SonarrClient sonarrClient)
 {
     _sonarrClient = sonarrClient;
 }
Пример #21
0
 public SeriesProvider(SonarrFactory sonarrFactory)
 {
     _client        = sonarrFactory.GetClient();
     _seriesBuilder = new SeriesBuilder();
 }
Пример #22
0
        public Task <bool> Stop()
        {
            _sonarrClient = null;

            return(Task.FromResult(true));
        }
Пример #23
0
 public EpisodeProvider(SonarrFactory sonarrFactory, EpisodeBuilder episodeBuilder)
 {
     _client        = sonarrFactory.GetClient();
     _seriesBuilder = episodeBuilder;
 }
Пример #24
0
 /// <summary>
 /// Initializes a new instance of the <see cref="EpisodeFile"/> class.
 /// </summary>
 /// <param name="sonarrClient">The sonarr client.</param>
 public EpisodeFile(SonarrClient sonarrClient)
 {
     _sonarrClient = sonarrClient;
 }
Пример #25
0
 public GetSingleSeriesHandler(SonarrClient sonarrClient)
 {
     _sonarrClient = sonarrClient;
 }
Пример #26
0
 public GetSingleEpisodeHandler(IOptions <ApiKeys> apiKeys, IOptions <ServicePath> servicePath, SonarrClient sonarrClient)
 {
     _apiKeys      = apiKeys.Value;
     _servicePath  = servicePath.Value;
     _sonarrClient = sonarrClient;
 }
Пример #27
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SeriesLookup"/> class.
 /// </summary>
 /// <param name="sonarrClient">The sonarr client.</param>
 public SeriesLookup(SonarrClient sonarrClient)
 {
     _sonarrClient = sonarrClient;
 }
Пример #28
0
 /// <summary>
 /// Initializes a new instance of the <see cref="History"/> class.
 /// </summary>
 /// <param name="sonarrClient">The sonarr client.</param>
 public History(SonarrClient sonarrClient)
 {
     _sonarrClient = sonarrClient;
 }
Пример #29
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Queue"/> class.
 /// </summary>
 /// <param name="sonarrClient">The sonarr client.</param>
 public Queue(SonarrClient sonarrClient)
 {
     _sonarrClient = sonarrClient;
 }
Пример #30
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Command" /> class.
 /// </summary>
 /// <param name="sonarrClient">The sonarr client.</param>
 public Command(SonarrClient sonarrClient)
 {
     _sonarrClient = sonarrClient;
 }