//******************* Methods *******************// // Gets data from url public Movie GetMovie(string MediaID) { // Get Raw Movie Data string FullPath = library + "movie/" + MediaID + "?" + apiKey + default_filters; dynamic RawResults = parseJson(FullPath); // Construct movie Movie movie = new Movie(RawResults); return movie; }
// Searches TMDB, both movies and tv. Returns a concatenanted list of media items public List<Media> Search(string query) { string FullPathMovie = library + "search/movie" + "?" + apiKey + "&query=" + query + default_filters; string FullPathTV = library + "search/tv" + "?" + apiKey + "&query=" + query + default_filters; dynamic RawResultsMovie = parseJson(FullPathMovie); dynamic RawResultsTV = parseJson(FullPathTV); List<Media> SearchResults = new List<Media>(); foreach (var m in RawResultsMovie["results"]) { try { if (m["popularity"] > 1) { Movie movie = new Movie(m); SearchResults.Add((Media)movie); } } catch (KeyNotFoundException e) {} catch (Microsoft.CSharp.RuntimeBinder.RuntimeBinderException e) {} } foreach (var m in RawResultsTV["results"]) { try { if (m["popularity"] > 1) { Show show = new Show(m); SearchResults.Add((Media)show); } } catch (KeyNotFoundException e) { } catch (Microsoft.CSharp.RuntimeBinder.RuntimeBinderException e) {} } List<Media> SortedSearchResults = SearchResults.OrderByDescending(o=>o.release_date).ToList(); return SortedSearchResults; }