예제 #1
0
        public override bool GetResults(string keywords, string imdbID, bool skipImages)
        {
            bool result = false;

            api           = new Tmdb(AccessKey, FileManager.Configuration.Options.MovieSheetsOptions.TVShowsLanguage);
            configuration = api.GetConfiguration();

            TmdbMovie movie = null;

            if (!string.IsNullOrEmpty(imdbID))
            {
                movie = api.GetMovieByIMDB(imdbID, FileManager.Configuration.Options.MovieSheetsOptions.TVShowsLanguage);
                if (movie != null)
                {
                    result = GetResults(new[] { movie });
                }
            }
            if (movie == null)// no imdb identification,use list
            {
                var searchResults = api.SearchMovie(Escape(keywords), 1);
                if (searchResults.results.Any())
                {
                    var list = searchResults.results.Select(item => api.GetMovieInfo(item.id)).ToList();
                    result = GetResults(list);
                }
            }

            return(result);
        }
예제 #2
0
        void MainPage_Loaded(object sender, RoutedEventArgs e)
        {
            // load the config for the image paths
            var api = new Tmdb(App.ApiKey, null);

            api.GetConfiguration(null, result => tmdbConfig = result.Data);
        }
예제 #3
0
 private TmdbConfiguration GetConfiguration()
 {
     if (_configuration == null)
     {
         Logger.Debug("Getting TMDb configuration");
         _configuration = _tmdbApi.GetConfiguration();
     }
     return(_configuration);
 }
예제 #4
0
        /// <summary>
        /// Get the Configuration, method will block the current thread
        /// </summary>
        public TmdbConfiguration GetConfiguration()
        {
            var api = new Tmdb(App.ApiKey, null);
            TmdbConfiguration result = null;

            api.GetConfiguration(null, tmdbResult =>
            {
                result = tmdbResult.Data;
                _autoResetEvent.Set();     // signal event to continue
            });

            _autoResetEvent.WaitOne(); // block the current thread here until response has been received

            return(result);
        }
예제 #5
0
        /// <summary>
        /// NOTE: method contains calls that will block the current thread, use within a worker thread, not the UI thread.
        /// </summary>
        /// <param name="page"></param>
        public void LoadNowPlaying(int page)
        {
            var facade = new TmdbFacade();

            if (tmdbConfig == null)
            {
                tmdbConfig = facade.GetConfiguration();
            }

            var result  = facade.GetNowPlayingMovies(page);
            var baseUrl = string.Format("{0}{1}", tmdbConfig.images.base_url, tmdbConfig.images.poster_sizes[0]);

            foreach (var item in result.results)
            {
                AddNowPlayingItem(new NowPlayingViewModel(item, baseUrl));
            }
        }