private ApiResponse <ApiValue> RetrieveRadarr(string path) { string directory = System.IO.Path.GetDirectoryName(path); string filename = System.IO.Path.GetFileName(path); var api = new RadarrQuery(url, apiKey, username, password); var filtered = api.Where((x) => x.FolderName == directory && x.MovieFile.RelativePath == filename); if (filtered.StatusCode != System.Net.HttpStatusCode.OK) { return(new ApiResponse <ApiValue>(null, filtered.StatusCode, filtered.ErrorDetails)); } var mediaInfo = filtered.Value.FirstOrDefault(); if (mediaInfo == null || mediaInfo.Title == null) { return(new ApiResponse <ApiValue>(null, System.Net.HttpStatusCode.BadRequest, "Could not find the media item.")); } return(new ApiResponse <ApiValue>(new ApiValue() { SeriesTitle = mediaInfo.Title, Title = mediaInfo.Title, ImdbId = mediaInfo.ImdbId, TmdbId = mediaInfo.TmdbId, Genres = mediaInfo.Genres }, System.Net.HttpStatusCode.OK)); }
private ApiValue RetrieveRadarr(string path) { string directory = System.IO.Path.GetDirectoryName(path); string filename = System.IO.Path.GetFileName(path); var api = new RadarrQuery(url, apiKey, username, password); var mediaInfo = api.Where((x) => x.FolderName == directory && x.MovieFile.RelativePath == filename).FirstOrDefault(); if (mediaInfo == null || mediaInfo.Title == null) { return(null); } return(new ApiValue() { SeriesTitle = mediaInfo.Title, Title = mediaInfo.Title, ImdbId = mediaInfo.ImdbId, TmdbId = mediaInfo.TmdbId, Genres = mediaInfo.Genres }); }