예제 #1
0
        public void Notify(MediaBrowserSettings settings, string title, string message)
        {
            var path    = "/Notifications/Admin";
            var request = BuildRequest(path, settings);

            request.Headers.ContentType = "application/json";
            request.Method = HttpMethod.POST;

            request.SetContent(new
            {
                Name        = title,
                Description = message,
                ImageUrl    = "https://raw.github.com/lidarr/Lidarr/develop/Logo/64.png"
            }.ToJson());

            ProcessRequest(request, settings);
        }
예제 #2
0
        public void Update(MediaBrowserSettings settings, string seriesPath, string updateType)
        {
            var path    = "/Library/Media/Updated";
            var request = BuildRequest(path, settings);

            request.Headers.ContentType = "application/json";

            request.SetContent(new
            {
                Updates = new[]
                {
                    new
                    {
                        Path       = seriesPath,
                        UpdateType = updateType
                    }
                }
            }.ToJson());

            ProcessRequest(request, settings);
        }
        public ValidationFailure Test(MediaBrowserSettings settings)
        {
            try
            {
                _logger.Debug("Testing connection to MediaBrowser: {0}", settings.Address);

                Notify(settings, "Test from Sonarr", "Success! MediaBrowser has been successfully configured!");
            }
            catch (RestException ex)
            {
                if (ex.Response.StatusCode == HttpStatusCode.Unauthorized)
                {
                    return(new ValidationFailure("ApiKey", "API Key is incorrect"));
                }
            }
            catch (Exception ex)
            {
                _logger.Error(ex, "Unable to send test message: " + ex.Message);
                return(new ValidationFailure("Host", "Unable to send test message: " + ex.Message));
            }

            return(null);
        }
예제 #4
0
        public void Update(MediaBrowserSettings settings, List <string> musicCollectionPaths)
        {
            string      path;
            HttpRequest request;

            if (musicCollectionPaths.Any())
            {
                path    = "/Library/Media/Updated";
                request = BuildRequest(path, settings);
                request.Headers.ContentType = "application/json";

                var updateInfo = new List <EmbyMediaUpdateInfo>();

                foreach (var colPath in musicCollectionPaths)
                {
                    updateInfo.Add(new EmbyMediaUpdateInfo
                    {
                        Path       = colPath,
                        UpdateType = "Created"
                    });
                }

                request.SetContent(new
                {
                    Updates = updateInfo
                }.ToJson());
            }
            else
            {
                path    = "/Library/Refresh";
                request = BuildRequest(path, settings);
            }

            request.Method = HttpMethod.POST;

            ProcessRequest(request, settings);
        }
 public void Update(MediaBrowserSettings settings, Series series)
 {
     _proxy.Update(settings, series.TvdbId);
 }
 public void Notify(MediaBrowserSettings settings, string title, string message)
 {
     _proxy.Notify(settings, title, message);
 }
예제 #7
0
 public void UpdateMovies(MediaBrowserSettings settings, Movie movie, string updateType)
 {
     _proxy.UpdateMovies(settings, movie.Path, updateType);
 }
예제 #8
0
 public void Update(MediaBrowserSettings settings, Series series, string updateType)
 {
     _proxy.Update(settings, series.Path, updateType);
 }
예제 #9
0
        private HttpRequest BuildRequest(string path, MediaBrowserSettings settings)
        {
            var url = string.Format(@"http://{0}/mediabrowser", settings.Address);

            return(new HttpRequestBuilder(url).Resource(path).Build());
        }