public void WhenPreparingDownload_WithInvalidPath_ItShouldReturnAnException() { var service = new KodiService(); Assert.That(() => service.PrepareDownload(new PrepareDownloadParams { Path = "Invalid path" }), Throws.Exception.TypeOf <Exception>()); }
public void WhenPreparingDownload_WithValidPath_ItShouldReturnAString() { var service = new KodiService(); var prepareDownload = service.PrepareDownload(new PrepareDownloadParams { Path = "image://http%3A%2F%2Fthetvdb.com%2Fbanners%2Ffanart%2Foriginal%2F295647-11.jpg/" }); Assert.IsNotNull(prepareDownload); Assert.IsInstanceOf <JsonRpcResponse <PrepareDownloadResponse> >(prepareDownload); Assert.AreEqual(prepareDownload.Result.Details.Path, "image/image%3A%2F%2Fhttp%253A%252F%252Fthetvdb.com%252Fbanners%252Ffanart%252Foriginal%252F295647-11.jpg%2F"); }
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(); } }