public Mock <IKodiService> GetKodiServiceMock(GetFileDetailsParams parameters) { var mock = new Mock <IKodiService>(); mock.Setup(s => s.GetFileDetails(parameters, "UnitTests")) .Returns(() => MakeFauxRequest <GetFileDetailsResponse>($"files.{parameters.File}.json")); return(mock); }
public void GivenAString_WhenGettingFileDetails_ItShouldReturnFileDetails() { var parameters = new GetFileDetailsParams { File = "1", Properties = FileProperties.All() }; var mock = GetKodiServiceMock(parameters); var service = mock.Object; var actual = service.GetFileDetails(parameters, "UnitTests"); var expected = Files.GetFileDetails(); Assert.IsInstanceOf <JsonRpcResponse <GetFileDetailsResponse> >(actual); AssertThatPropertyValuesAreEquals(actual.Result, expected); }
public void WhenGettingFileDetails_WithValidFile_ItShouldReturnAFileResult() { var service = new KodiService(); var parameters = 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() }; var fileDetails = service.GetFileDetails(parameters); Assert.IsNotNull(fileDetails); Assert.IsInstanceOf <JsonRpcResponse <GetFileDetailsResponse> >(fileDetails); StringAssert.IsMatch(fileDetails.Result.FileDetails.FilePath, "/media/gotham/series/Dark Matter/Season 02/Dark Matter - S02E03 - I’ve Seen the Other Side of You.mkv"); Assert.AreEqual(fileDetails.Result.FileDetails.MimeType, "video/x-matroska"); Assert.AreEqual(fileDetails.Result.FileDetails.Size, 857542653); }
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(); } }
public JsonRpcResponse <GetFileDetailsResponse> GetFileDetails(GetFileDetailsParams parameters, string requestId = "GetFileDetails") { return(_rpcConnector.MakeRequest <GetFileDetailsResponse>(KodiMethods.GetFileDetails, parameters, requestId)); }