public ActionResult SaveChannelRequest([FromBody] SaveChannel channel)
        {
            List <M3UItem> m3UPlaylist = new List <M3UItem>();

            if (Plugin.Instance.M3UChannels.ContainsKey(channel.PlaylistUrl))
            {
                m3UPlaylist = Plugin.Instance.M3UChannels[channel.PlaylistUrl];
            }
            else
            {
                return(NotFound());
            }

            for (int i = 0; i < m3UPlaylist.Count; i++)
            {
                if (m3UPlaylist[i].Url.Equals(channel.channel.Url))
                {
                    m3UPlaylist[i] = channel.channel;
                }
            }

            Plugin.Instance.M3UChannels[channel.PlaylistUrl] = m3UPlaylist;

            Plugin.Instance.TaskManager.CancelIfRunningAndQueue <SaveTask>();

            return(NoContent());
        }
예제 #2
0
        public async Task <bool> ShouldSendInChannel(int movieId, SaveChannel channel)
        {
            var tags = await GetMovieTags(movieId);

            if (tags.Contains("private") && channel.ShowsPrivate == false)
            {
                return(false);
            }
            foreach (var required in channel.TagRequired)
            {
                if (tags.Contains(required))
                {
                    return(true);
                }
            }
            return(channel.TagRequired.Count == 0);
        }
        public async Task ToggleSonarr()
        {
            var id = Context.Channel.Id;

            if (SonarrService.Channels.RemoveAll(x => x.Channel.Id == id) > 0)
            {
                await ReplyAsync("Removed.");
            }
            else
            {
                var sv = new SaveChannel()
                {
                    Channel      = Context.Channel as ITextChannel,
                    ShowsPrivate = false
                };
                SonarrService.Channels.Add(sv);
                await ReplyAsync("Added.");
            }
            SonarrService.OnSave();
        }