예제 #1
0
파일: MediaAPI.cs 프로젝트: bdennisco/Shelf
 //******************* 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;
 }
예제 #2
0
파일: MediaAPI.cs 프로젝트: bdennisco/Shelf
        // 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;
        }