public Mock <IKodiService> GetKodiServiceMock(GetTvShowDetailsParams parameters)
        {
            var mock = new Mock <IKodiService>();

            mock.Setup(s => s.GetTvShowDetails(parameters, "UnitTests"))
            .Returns(() => MakeFauxRequest <GetTvShowDetailsResponse>($"tvshow.{parameters.TvShowId}.json"));

            return(mock);
        }
Ejemplo n.º 2
0
        public void WhenGettingTvShowDetails_WithAnInvalidTvShowId_ItShouldThrowException()
        {
            var service = new KodiService();

            var parameters = new GetTvShowDetailsParams
            {
                TvShowId = (int)TvShows.TestSet.InvalidId
            };

            Assert.That(() => service.GetTvShowDetails(parameters, "UnitTests"), Throws.Exception.TypeOf <Exception>());
        }
Ejemplo n.º 3
0
        public void GivenAJsonString_WhenGettingATvShowByTvShowId_WithAnInvalidTvShowId_ItShouldThrowRpcInternalServerErrorException()
        {
            const TvShows.TestSet id = TvShows.TestSet.InvalidId;

            var parameters = new GetTvShowDetailsParams
            {
                TvShowId = (int)id
            };

            var mock    = GetKodiServiceMock(parameters);
            var service = mock.Object;

            Assert.That(() => service.GetTvShowDetails(parameters, "UnitTests"), Throws.Exception.TypeOf <RpcInternalServerErrorException>());
        }
Ejemplo n.º 4
0
        public void WhenGettingTvShowDetails_WithATvShowIdOfOne_ItShouldReturnATvShow()
        {
            var service = new KodiService();

            var parameters = new GetTvShowDetailsParams
            {
                TvShowId   = 1,
                Properties = new[] { TvShowProperties.Title, TvShowProperties.Year }
            };

            var details = service.GetTvShowDetails(parameters);

            Assert.IsNotNull(details);
            Assert.IsNotNull(details.Result);
            Assert.AreEqual(1, details.Result.TvShowDetails.TvShowId);
        }
Ejemplo n.º 5
0
        public void GivenAJsonString_WhenGettingATvShowByTvShowId_WithAValidTvShowId_ItShouldReturnATvShow()
        {
            const TvShows.TestSet id = TvShows.TestSet.TheAmericans;

            var parameters = new GetTvShowDetailsParams
            {
                TvShowId   = (int)id,
                Properties = TvShowProperties.All()
            };

            var mock    = GetKodiServiceMock(parameters);
            var service = mock.Object;

            var actual   = service.GetTvShowDetails(parameters, "UnitTests");
            var expected = TvShows.GetTvShow(id);

            Assert.IsInstanceOf <JsonRpcResponse <GetTvShowDetailsResponse> >(actual);
            Assert.That(actual.Result.TvShowDetails.TvShowId, Is.EqualTo(expected.TvShowDetails.TvShowId));
            AssertThatPropertyValuesAreEquals(actual.Result.TvShowDetails, expected.TvShowDetails);
        }
Ejemplo n.º 6
0
        private static void Main()
        {
            try
            {
                Console.WriteLine("Connecting to Kodi JSON-RPC API/{0}.", Service.ApiVersion);
                Console.WriteLine("\tHost...........{0}:{1}", Service.Host, Service.Port);
                Console.WriteLine("\tUsername.......{0}", Service.Username);
                Console.WriteLine("\tPassword.......{0}", Service.Password);
                Console.WriteLine();
                Console.Write("Pinging Kodi....");

                var ping = Service.Ping();
                Console.WriteLine(ping.Result);

                var parameters = new GetTvShowDetailsParams
                {
                    TvShowId = 1,
                    //Properties = new[] {TvShowProperties.Title, TvShowProperties.Premiered, TvShowProperties.Year}
                    Properties = TvShowProperties.All()
                };

                Console.WriteLine();
                Console.WriteLine("Running VideoLibrary.GetTvShowDetails");

                var details = Service.GetTvShowDetails(parameters);

                Console.WriteLine("ID.................{0}", details.Id);
                Console.WriteLine("JsonRPC............{0}", details.JsonRpc);
                Console.WriteLine("ShowTitle..........{0}", details.Result.TvShowDetails.Title);
                Console.WriteLine("Studio.............{0}", details.Result.TvShowDetails.Premiered);
                Console.WriteLine("Premiered..........{0}", details.Result.TvShowDetails.Year);
                Console.WriteLine("Fanart.............{0}", details.Result.TvShowDetails.Fanart);
                Console.WriteLine("File...............{0}", details.Result.TvShowDetails.File);
                Console.WriteLine();

                Console.WriteLine();
                Console.Write("Scanning for new content...");
                var scan = Service.Scan(new ScanParams());
                Console.WriteLine(scan.Result);

                Console.WriteLine();
                Console.Write("Cleaning...");
                var clean = Service.Clean(new CleanParams());
                Console.WriteLine(clean.Result);

                Console.WriteLine();
                Console.WriteLine("Getting File details");

                var fileDetailParams = new GetFileDetailsParams
                {
                    File       = "/media/gotham/series/Dark Matter/Season 02/Dark Matter - S02E03 - I’ve Seen the Other Side of You.mkv",
                    Properties = FileProperties.All()
                };

                Console.WriteLine();
                var fileDetails = Service.GetFileDetails(fileDetailParams);

                Console.WriteLine("File..............{0}", fileDetails.Result.FileDetails.FilePath);
                Console.WriteLine("FileName..........{0}", fileDetails.Result.FileDetails.Label);
                Console.WriteLine("MimeType..........{0}", fileDetails.Result.FileDetails.MimeType);
                Console.WriteLine("Size..............{0}", fileDetails.Result.FileDetails.Size);

                Console.WriteLine();
                Console.WriteLine("Preparing file for download");
                var prepareDownloadParam = new PrepareDownloadParams
                {
                    Path = details.Result.TvShowDetails.Fanart
                           //Path = fileDetails.Result.FileDetails.FilePath
                };
                var prepareDownload = Service.PrepareDownload(prepareDownloadParam);
                Console.WriteLine("Details...........{0}", prepareDownload.Result.Details.Path);
                Console.WriteLine("Protocol..........{0}", prepareDownload.Result.Protocol);
                Console.WriteLine("Mode..............{0}", prepareDownload.Result.Mode);

                Console.WriteLine();
                Console.WriteLine("Getting directory (directory)");
                var getDirectoryParams = new GetDirectoryParams
                {
                    Directory  = "/media/gotham/series/Dark Matter",
                    Properties = FileProperties.All()
                };
                var getDirectory = Service.GetDirectory(getDirectoryParams);
                foreach (var file in getDirectory.Result.Files)
                {
                    Console.WriteLine("....{0}", file.Label);
                    Console.WriteLine("........Path..............{0}", file.FilePath);
                    Console.WriteLine("........Type..............{0}", file.FileType);
                }

                Console.WriteLine();
                Console.WriteLine("Getting directory (files)");
                getDirectoryParams.Directory += "/Season 01/";
                getDirectoryParams.Properties = FileProperties.All();
                getDirectory = Service.GetDirectory(getDirectoryParams);

                var x = FileProperties.All().Aggregate("", (current, y) => current + (@",""" + y + @""""));

                foreach (var file in getDirectory.Result.Files)
                {
                    Console.WriteLine("....{0}", file.Label);
                    Console.WriteLine("........Path..............{0}", file.FilePath);
                    Console.WriteLine("........Type..............{0}", file.FileType);
                }

                PressAnyKey();
            }
            catch (Exception e)
            {
                Console.WriteLine("An exception has occured: {0}", e.Message);
                PressAnyKey();
            }
        }
Ejemplo n.º 7
0
 public JsonRpcResponse <GetTvShowDetailsResponse> GetTvShowDetails(GetTvShowDetailsParams parameters, string requestId = "GetTvShowDetailsResponse")
 {
     return(_rpcConnector.MakeRequest <GetTvShowDetailsResponse>(KodiMethods.GetTvShowDetails, parameters, requestId));
 }