Пример #1
0
        /// <summary>
        /// Refresh series information from trakt and rescan disk. If seriesId not set, all series will be refreshed and scanned
        /// </summary>
        /// <param name="seriesId">Series ID</param>
        /// <returns></returns>
        public async Task <Models.Command> RefreshSeries([Optional] int seriesId)
        {
            string parameter = JsonConvert.SerializeObject(new Dictionary <string, object>
            {
                ["name"]     = "refreshSeries",
                ["seriesId"] = seriesId
            });

            var json = await _sonarrClient.PostJson("/command", parameter, "POST");

            return(await Task.Run(() => JsonConvert.DeserializeObject <Models.Command>(json, Converter.Settings)));
        }
Пример #2
0
        /// <summary>
        /// Adds a previously searched release to the download client, if the release is still in Sonarr's search cache (30 minute cache)
        /// </summary>
        /// <param name="guid">Release GUID</param>
        /// <returns></returns>
        public async Task <List <Models.Release> > AddRelease(string guid)
        {
            string parameter = JsonSerializer.Serialize(new Dictionary <string, object>
            {
                ["guid"] = guid
            });

            var json = await _sonarrClient.PostJson($"/release", parameter, "POST");

            return(await Task.Run(() => JsonSerializer.Deserialize <List <Models.Release> >(json, Converter.Settings)));
        }
Пример #3
0
        /// <summary>
        /// Adds a new series to your collection (Refer to https://github.com/Sonarr/Sonarr/wiki/Series for more information on usage)
        /// </summary>
        /// <param name="tvdbId">TV Database ID</param>
        /// <param name="title">Title</param>
        /// <param name="qualityProfileId">Quality profile ID</param>
        /// <param name="titleSlug">Title slug</param>
        /// <param name="images">Images array</param>
        /// <param name="seasons">Seasons array</param>
        /// <param name="rootFolderPath">Full path will be created by combining the rootFolderPath with the series title</param>
        /// <param name="tvRageId">TV Rage ID</param>
        /// <param name="seasonFolder">Use season folders</param>
        /// <param name="monitored">Is monitored</param>
        /// <param name="addOptions">Object that contains three boolean properties - If supplied, all properties are required</param>
        /// <returns></returns>
        public async Task <Models.Series> AddSeries(int tvdbId, string title, int qualityProfileId, string titleSlug, Models.Image[] images, Models.Season[] seasons, string rootFolderPath, [Optional] int tvRageId, [Optional] bool seasonFolder, [Optional] bool monitored, [Optional] AddOptions addOptions)
        {
            var dictionary = new Dictionary <string, object>
            {
                ["tvdbId"]           = tvdbId,
                ["title"]            = title,
                ["qualityProfileId"] = qualityProfileId,
                ["titleSlug"]        = titleSlug,
                ["images"]           = images,
                ["seasons"]          = seasons,
                ["rootFolderPath"]   = rootFolderPath
            };

            if (monitored)
            {
                dictionary.Add("monitored", monitored);
            }

            if (seasonFolder)
            {
                dictionary.Add("seasonFolder", seasonFolder);
            }

            if (tvRageId != 0)
            {
                dictionary.Add("tvRageId", tvRageId);
            }

            if (addOptions != null)
            {
                dictionary.Add("addOptions", addOptions);
            }

            string parameter = JsonSerializer.Serialize(new Dictionary <string, object>(dictionary));

            var json = await _sonarrClient.PostJson("/series", parameter, "POST");

            return(await Task.Run(() => JsonSerializer.Deserialize <Models.Series>(json, Converter.Settings)));
        }
Пример #4
0
        /// <summary>
        /// No description
        /// </summary>
        /// <param name="title">The title.</param>
        /// <param name="downloadUrl">The download URL.</param>
        /// <param name="protocol">Download protocol</param>
        /// <param name="date">The date.</param>
        /// <returns></returns>
        public async Task <List <Models.ReleasePush> > PushRelease(string title, string downloadUrl, Protocol protocol, DateTime date)
        {
            string parameter = JsonSerializer.Serialize(new Dictionary <string, object>
            {
                ["title"]       = title,
                ["downloadUrl"] = downloadUrl,
                ["protocol"]    = protocol.ToString(),
                ["date"]        = date.ToString("yyyy-MM-ddTHH:mm:ssZ")
            });

            var json = await _sonarrClient.PostJson($"/releasePush", parameter, "POST");

            return(await Task.Run(() => JsonSerializer.Deserialize <List <Models.ReleasePush> >(json, Converter.Settings)));
        }
Пример #5
0
        /// <summary>
        /// Update the given episodes, currently only monitored is changed, all other modifications are ignored.
        /// </summary>
        /// <param name="episode">Episode to update - Requires all properties of Models.Episode object</param>
        /// <returns></returns>
        public async Task <Models.Episode> UpdateEpisode(Models.Episode episode)
        {
            var json = await _sonarrClient.PostJson("/episode", JsonConvert.SerializeObject(episode, Converter.Settings), "PUT");

            return(await Task.Run(() => JsonConvert.DeserializeObject <Models.Episode>(json, Converter.Settings)));
        }
Пример #6
0
        /// <summary>
        /// Update an existing quality definition
        /// </summary>
        /// <param name="qualityDefinition">QualityDefinition to update - Requires all properties of Models.QualityDefinition object</param>
        /// <returns></returns>
        public async Task <Models.QualityDefinition> UpdateQualityDefinition(Models.QualityDefinition qualityDefinition)
        {
            var json = await _sonarrClient.PostJson("/qualityDefinition", JsonSerializer.Serialize(qualityDefinition, Converter.Settings), "PUT");

            return(await Task.Run(() => JsonSerializer.Deserialize <Models.QualityDefinition>(json, Converter.Settings)));
        }