Example #1
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);
        }
Example #2
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();
            }
        }