Exemplo n.º 1
0
        public async Task <IList <KodiTvEpisode> > GetRecentlyAddedEpisodes()
        {
            var cmd = new KodiCommand <KodiStandardRequestArgs, KodiGetRecentlyAddedEpisodesResponse>(
                "VideoLibrary.GetRecentlyAddedEpisodes", new KodiStandardRequestArgs(KodiTvEpisode.AllProperties));

            var response = await _client.ExecuteCommandAsync(cmd);

            return(response.Episodes);
        }
Exemplo n.º 2
0
        public async Task <IList <KodiTvShow> > GetShows()
        {
            var cmd = new KodiCommand <KodiStandardRequestArgs, KodiGetTvShowsResponse>(
                "VideoLibrary.GetTVShows", new KodiStandardRequestArgs(KodiTvShow.AllProperties));

            var response = await _client.ExecuteCommandAsync(cmd);

            return(response.Shows);
        }
Exemplo n.º 3
0
        public async Task RemoveShow(int tvShowId)
        {
            var cmd = new KodiCommand <KodiRemoveTvShowRequestArgs, string>(
                "VideoLibrary.RemoveTVShow", new KodiRemoveTvShowRequestArgs(tvShowId));

            var response = await _client.ExecuteCommandAsync(cmd);

            if (response != "OK")
            {
                throw new Exception("Failed to remove TV show.");
            }
        }
Exemplo n.º 4
0
        // ===========================================================================
        // = Internal Methods
        // ===========================================================================

        internal async Task <TResponse> ExecuteCommandAsync <TRequestArgs, TResponse>(KodiCommand <TRequestArgs, TResponse> command)
            where TRequestArgs : class
            where TResponse : class
        {
            var body = new KodiRequestBody(command.MethodName, command.RequestArguments);

            var request = new RestRequest("jsonrpc");

            request.Method = Method.POST;
            request.AddJsonBody(body);

            var response = await _restClient.Execute <KodiResponseWrapper <TResponse> >(request);

            if (!response.IsSuccess)
            {
                throw new Exception(String.Format("Request failed. Response: {0}: {1}", response.StatusCode, response.StatusDescription));
            }

            return(response.Data.Result);
        }