Example #1
0
        public async Task <IActionResult> Create(long id, string type, string screenshot)
        {
            var userId      = this.User.FindFirst(ClaimTypes.NameIdentifier)?.Value;
            var currentUser = await _userManager.FindByIdAsync(userId);

            Item newItem = new Item();

            if (type == "game")
            {
                RawgIdRoot itemDetails = Rawg.GetGameById(id);
                newItem.GetRawgValues(itemDetails);
                newItem.Poster   = screenshot;
                newItem.Priority = currentUser.PriorityValue;
                _db.Items.Add(newItem);
                ItemUser newItemUser = new ItemUser {
                    Item = newItem, User = currentUser, ItemId = newItem.ItemId, UserId = userId
                };
                _db.ItemUser.Add(newItemUser);
                currentUser.PriorityValue++;
                var result = await _userManager.UpdateAsync(currentUser);

                _db.SaveChanges();
            }
            else if (type == "movie")
            {
                TmdbMovieRoot itemDetails = Tmdb.GetMovieById(id);
                newItem.GetTmdbMovieValues(itemDetails);
                newItem.Priority = currentUser.PriorityValue;
                _db.Items.Add(newItem);
                ItemUser newItemUser = new ItemUser {
                    Item = newItem, User = currentUser, ItemId = newItem.ItemId, UserId = userId
                };
                _db.ItemUser.Add(newItemUser);
                currentUser.PriorityValue++;
                var result = await _userManager.UpdateAsync(currentUser);

                _db.SaveChanges();
            }
            else if (type == "tv")
            {
                TmdbTvRoot itemDetails = Tmdb.GetTvById(id);
                newItem.GetTmdbTvValues(itemDetails);
                newItem.Priority = currentUser.PriorityValue;
                _db.Items.Add(newItem);
                ItemUser newItemUser = new ItemUser {
                    Item = newItem, User = currentUser, ItemId = newItem.ItemId, UserId = userId
                };
                _db.ItemUser.Add(newItemUser);
                currentUser.PriorityValue++;
                var result = await _userManager.UpdateAsync(currentUser);

                _db.SaveChanges();
            }
            return(RedirectToAction("Index", new { typeFilter = type }));
        }
Example #2
0
 protected void Page_Load(object sender, EventArgs e)
 {
     search = Request.Params["q"];
     if (!string.IsNullOrEmpty(search))
     {
         results = Tmdb.SearchShows(search, 0, 4);
     }
     else
     {
         results = Tmdb.DiscoverShows(new TmdbDiscoverShowsInfo(), 0, 0);
     }
 }
Example #3
0
    public static void ShowSearchResult(this IDialogService dialogService, string searchMode, string query,
                                        string folderPath, ResultResponse result, Tmdb tmdbObject, IgdbClass igdbObject, bool isPickedById,
                                        Action <IDialogResult> callBack)
    {
        var p = new DialogParameters
        {
            { "query", query }, { "result", result }, { "searchmode", searchMode }, { "tmdbObject", tmdbObject },
            { "igdbObject", igdbObject },
            { "folderpath", folderPath },
            { "isPickedById", isPickedById }
        };

        dialogService.ShowDialog("SearchResult", p, callBack);
    }
Example #4
0
        public TmdbNowPlaying GetNowPlayingMovies(int page)
        {
            var            api    = new Tmdb(App.ApiKey, null);
            TmdbNowPlaying result = null;

            api.GetNowPlayingMovies(page, null, tmdbResult =>
            {
                result = tmdbResult.Data;
                _autoResetEvent.Set();
            });

            _autoResetEvent.WaitOne();

            return(result);
        }
Example #5
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);
        }
Example #6
0
 public override MovieInfo QueryMovieInfo(string imdbId)
 {
     if (!string.IsNullOrEmpty(imdbId))
     {
         if (api == null)
         {
             api = new Tmdb(AccessKey, FileManager.Configuration.Options.MovieSheetsOptions.TVShowsLanguage);
         }
         var movie = api.GetMovieByIMDB(imdbId, FileManager.Configuration.Options.MovieSheetsOptions.TVShowsLanguage);
         if (movie != null)
         {
             return(GetMovieInfo(movie));
         }
     }
     return(null);
 }
Example #7
0
        public IActionResult Index(string searchOption = null, string searchString = null, int page = 1)
        {
            if (String.IsNullOrEmpty(searchString))
            {
                return(RedirectToAction("Index", "Home"));
            }
            var             userId     = this.User.FindFirst(ClaimTypes.NameIdentifier)?.Value;
            List <ItemUser> joinList   = _db.ItemUser.Where(join => join.UserId == userId).Include(join => join.Item).ToList();
            List <long>     userApiIds = new List <long>();

            foreach (ItemUser join in joinList)
            {
                userApiIds.Add(join.Item.ApiId);
            }
            ItemIndexViewModel model = new ItemIndexViewModel();

            model.ApiIds       = userApiIds;
            model.CurrentPage  = page;
            model.SearchOption = searchOption;
            model.SearchString = searchString;
            if (searchOption == "games")
            {
                RawgSearchRoot results = Rawg.GetGamesSearch(searchString, page);
                model.GamesSearch = results;
                model.Results     = results.Count;
                model.Pages       = (results.Count + 19) / 20;
            }
            else if (searchOption == "movies")
            {
                TmdbMovieSearchRoot results = Tmdb.GetMoviesSearch(searchString, page);
                model.MovieSearch = results;
                model.Results     = results.TotalResults;
                model.Pages       = results.TotalPages;
            }
            else if (searchOption == "tv")
            {
                TmdbTvSearchRoot results = Tmdb.GetTvSearch(searchString, page);
                model.TvSearch = results;
                model.Results  = results.TotalResults;
                model.Pages    = results.TotalPages;
            }
            return(View(model));
        }
Example #8
0
        public void GetMetadata(CancellationToken cancellationToken, Job job)
        {
            if (cancellationToken.IsCancellationRequested)
            {
                return;
            }

            StartProgress("Loading plugin preferences...");

            var prefs = LoadPreferences();

            if (cancellationToken.IsCancellationRequested)
            {
                return;
            }

            if (_apiKey == null)
            {
                const string message = "No API key found";
                Logger.Error(message);
                throw new TmdbException(message);
            }

            _tmdbApi = new Tmdb(_apiKey, _searchISO_639_1);

            if (Configuration == null)
            {
                return;
            }

            Search(job);

            if (cancellationToken.IsCancellationRequested)
            {
                return;
            }

            GetPosters(job);

            FinishProgress("Finished querying TMDb");
        }
Example #9
0
        static void _RunCacheDemo2()
        {
            // demos the secondary (url based) caching
            // make it hit the server less (about every
            // 5 minutes usually (depending on machine
            // policy)
            Tmdb.CacheLevel = JsonRpcCacheLevel.Aggressive;

            // grab the show changes just so we have something to work with.
            // this is a non-caching function which means it doesn't use
            // the primary (memory) cache, but it will use this one.
            try
            {
                foreach (var show in Tmdb.GetShowChanges(DateTime.UtcNow, maxPage: 2))
                {
                    Console.WriteLine(show.Name);
                }
            }
            catch (JsonRpcException rex)
            {
                Console.Error.WriteLine("Error: " + rex.Json.ToString());
            }
            Console.WriteLine("Press any key...");
            Console.Read();
            Console.Clear();
            Console.WriteLine("Hopefully cached and faster (also no request limit delay if cache mode is aggressive)");
            // do it again, this time with some cache hits.
            try
            {
                foreach (var show in Tmdb.GetShowChanges(DateTime.UtcNow, maxPage: 2))
                {
                    Console.WriteLine(show.Name);
                }
            }
            catch (JsonRpcException rex)
            {
                Console.Error.WriteLine("Error: " + rex.Json.ToString());
            }
        }
Example #10
0
        public override IEnumerable <IContent> Search()
        {
            ISearchSource TMDB = new Tmdb()
            {
                Filter = this.Filter, Actor = this.Actor, From = this.From, To = this.To
            };
            ISearchSource youtube = new Youtube()
            {
                Filter = this.Filter
            };
            Cache cache = new Cache()
            {
                Filter = this.Filter, Actor = this.Actor, From = this.From, To = this.To
            };

            IContentFinder finder = new ContentFinder();

            var cachefound = finder.Search(cache);

            if (cachefound?.Count() > 0)
            {
                return(cachefound);
            }
            else
            {
                var tmdbfound    = finder.Search(TMDB);
                var youtubefound = finder.Search(youtube);

                cache.Set(tmdbfound);
                cache.Set(youtubefound);

                var merged = tmdbfound.Concat(youtubefound);

                return(merged);
            }
        }
Example #11
0
 public void Setup()
 {
     api = new Tmdb("e7ea08e0ed9aba51ea90d5ffe68fa672");
 }
Example #12
0
        static void Main(string[] args)
        {
            int[] moviesIds = { 389, 62, 20453, 453, 185, 702, 348, 705, 143, 279, 14, 73, 55, 93, 703, 28, 212, 105, 3175, 272, 10020, 76, 665, 44214, 78, 197, 642, 289, 524, 829, 598, 15, 901, 903, 562, 17654, 68718, 968, 141, 996, 935, 1417, 38, 5961, 275, 309, 550, 12, 13, 600, 783, 98, 770, 489, 769, 13223, 137, 12445, 11787, 949, 288, 205, 10191, 429, 7984, 46738, 27205, 89, 10775, 16869, 5915, 77338, 3078, 1585, 103663, 578, 329, 81, 24, 2118, 947, 87827, 100, 832, 24238, 77, 19, 70, 3082, 128, 585, 762, 583, 3083, 322, 10774, 6977, 213, 303, 11216, 654, 311, 510, 5924, 975, 391, 797, 22, 792, 539, 680, 1578, 85, 380, 11645, 2062, 567, 223, 641, 500, 1366, 804, 1580, 805, 857, 111, 424, 807, 11324, 187, 872, 993, 12405, 107, 239, 235, 13475, 1892, 845, 599, 7508, 103, 280, 284, 74643, 24428, 887, 115, 910, 2503, 826, 155, 11778, 1422, 1955, 9552, 961, 238, 962, 37247, 596, 914, 5925, 497, 49051, 990, 10098, 247, 45269, 8587, 121, 963, 11697, 982, 603, 3112, 423, 1124, 2493, 278, 694, 274, 745, 9277, 218, 1091, 1092, 3090, 37165, 117, 629, 576, 630, 7345, 595, 8392, 1480, 862, 627, 110 };

            Tmdb api = new Tmdb("APIKey"); //Enter your API key here

            string[] lines = new string[moviesIds.Length * 23];

            int recordId = 1;

            for (int i = 0; i < moviesIds.Length; i++)
            {
                TmdbMovie     movie = api.GetMovieInfo(moviesIds[i]);
                TmdbMovieCast cast  = api.GetMovieCast(moviesIds[i]);

                MovieUtilities movieUtilities = new MovieUtilities(movie, cast);

                string collectionId_1           = (movie.belongs_to_collection != null) ? movie.belongs_to_collection.id.ToString() : "null";
                string budget_2                 = movie.budget.ToString();
                string genresIds_3              = movieUtilities.GetGenresIds();
                string popularity_4             = movie.popularity.ToString();
                string productionCompaniesIds_5 = movieUtilities.GetProductionCompaniesIds();
                string productionCountriesIso_6 = movieUtilities.GetProductionCountriesIso();
                string releaseDate_7            = movie.release_date;
                string revenue_8                = movie.revenue.ToString();
                string runtime_9                = movie.runtime.ToString();
                string spokenLanguagesIso_10    = movieUtilities.GetSpokenLanguagesIso();
                string voteAverage_11           = movie.vote_average.ToString();
                string voteCount_12             = movie.vote_count.ToString();
                string castIds_13               = movieUtilities.GetCastIds(8);
                string costumeMakeUpIds_14      = movieUtilities.GetCostumeMakeUpIds();
                string directingIds_15          = movieUtilities.GetDirectingIds();
                string cameraIds_16             = movieUtilities.GetCameraIds();
                string editingIds_17            = movieUtilities.GetEditingIds();
                string productionIds_18         = movieUtilities.GetProductionIds();
                string soundIds_19              = movieUtilities.GetSoundIds();
                string writingIds_20            = movieUtilities.GetWritingIds();
                string artIds_21                = movieUtilities.GetArtIds();
                string crewIds_22               = movieUtilities.GetCrewIds();
                string visualEffectsIds_23      = movieUtilities.GetVisualEffectsIds();

                popularity_4   = popularity_4.Replace(',', '.');
                voteAverage_11 = voteAverage_11.Replace(',', '.');

                Record record1 = new Record(recordId, i + 1, 1, collectionId_1);
                lines[recordId - 1] = record1.PrintRecord();
                recordId++;
                Record record2 = new Record(recordId, i + 1, 2, budget_2);
                lines[recordId - 1] = record2.PrintRecord();
                recordId++;
                Record record3 = new Record(recordId, i + 1, 3, genresIds_3);
                lines[recordId - 1] = record3.PrintRecord();
                recordId++;
                Record record4 = new Record(recordId, i + 1, 4, popularity_4);
                lines[recordId - 1] = record4.PrintRecord();
                recordId++;
                Record record5 = new Record(recordId, i + 1, 5, productionCompaniesIds_5);
                lines[recordId - 1] = record5.PrintRecord();
                recordId++;
                Record record6 = new Record(recordId, i + 1, 6, productionCountriesIso_6);
                lines[recordId - 1] = record6.PrintRecord();
                recordId++;
                Record record7 = new Record(recordId, i + 1, 7, releaseDate_7);
                lines[recordId - 1] = record7.PrintRecord();
                recordId++;
                Record record8 = new Record(recordId, i + 1, 8, revenue_8);
                lines[recordId - 1] = record8.PrintRecord();
                recordId++;
                Record record9 = new Record(recordId, i + 1, 9, runtime_9);
                lines[recordId - 1] = record9.PrintRecord();
                recordId++;
                Record record10 = new Record(recordId, i + 1, 10, spokenLanguagesIso_10);
                lines[recordId - 1] = record10.PrintRecord();
                recordId++;
                Record record11 = new Record(recordId, i + 1, 11, voteAverage_11);
                lines[recordId - 1] = record11.PrintRecord();
                recordId++;
                Record record12 = new Record(recordId, i + 1, 12, voteCount_12);
                lines[recordId - 1] = record12.PrintRecord();
                recordId++;
                Record record13 = new Record(recordId, i + 1, 13, castIds_13);
                lines[recordId - 1] = record13.PrintRecord();
                recordId++;
                Record record14 = new Record(recordId, i + 1, 14, costumeMakeUpIds_14);
                lines[recordId - 1] = record14.PrintRecord();
                recordId++;
                Record record15 = new Record(recordId, i + 1, 15, directingIds_15);
                lines[recordId - 1] = record15.PrintRecord();
                recordId++;
                Record record16 = new Record(recordId, i + 1, 16, cameraIds_16);
                lines[recordId - 1] = record16.PrintRecord();
                recordId++;
                Record record17 = new Record(recordId, i + 1, 17, editingIds_17);
                lines[recordId - 1] = record17.PrintRecord();
                recordId++;
                Record record18 = new Record(recordId, i + 1, 18, productionIds_18);
                lines[recordId - 1] = record18.PrintRecord();
                recordId++;
                Record record19 = new Record(recordId, i + 1, 19, soundIds_19);
                lines[recordId - 1] = record19.PrintRecord();
                recordId++;
                Record record20 = new Record(recordId, i + 1, 20, writingIds_20);
                lines[recordId - 1] = record20.PrintRecord();
                recordId++;
                Record record21 = new Record(recordId, i + 1, 21, artIds_21);
                lines[recordId - 1] = record21.PrintRecord();
                recordId++;
                Record record22 = new Record(recordId, i + 1, 22, crewIds_22);
                lines[recordId - 1] = record22.PrintRecord();
                recordId++;
                Record record23 = new Record(recordId, i + 1, 23, visualEffectsIds_23);
                lines[recordId - 1] = record23.PrintRecord();
                recordId++;
            }
            File.WriteAllLines("records.txt", lines);
        }
Example #13
0
        static void Main(string[] args)
        {
            Tmdb api = new Tmdb("apikey", null);

            Console.Write("Enter Movie Title: ");
            var search = Console.ReadLine();

            if (string.IsNullOrEmpty(search))
            {
                return;
            }

            Console.WriteLine("Synchronous call...");
            {
                int page = 1;
                while (true)
                {
                    var result = api.SearchMovie(search, page++);
                    if (result != null)
                    {
                        if (page == 1)
                        {
                            Console.WriteLine(string.Format("{0} matches found", result.total_results));
                        }

                        if (result.results.Count == 0)
                        {
                            break;
                        }

                        foreach (var movie in result.results)
                        {
                            Console.WriteLine(string.Format("{0} {1} {2}", movie.id, movie.title, movie.release_date));
                        }
                    }
                    else if (api.Error != null)
                    {
                        Console.WriteLine(string.Format("{0} {1}", api.Error.status_code, api.Error.status_message));
                    }
                }
            }

            Console.WriteLine("Asynchronous call...");
            {
                api.SearchMovie(search, 1, null, result =>
                {
                    if (result.Data != null)
                    {
                        foreach (var movie in result.Data.results)
                        {
                            Console.WriteLine(string.Format("{0} {1} {2}", movie.id, movie.title, movie.release_date));
                        }
                    }
                    else
                    {
                        Console.WriteLine(string.Format("{0} {1}", result.Error.status_code, result.Error.status_message));
                    }
                });
            }

            Console.WriteLine("Press any key...");
            Console.Read();
        }
Example #14
0
        static void _RunShowDemo(int id = 2919 /*Burn Notice*/)
        {
            // fetch a show - you can use SearchShows() or if you already know the id
            // of the object you want, just create it with the given id.
            var show = new TmdbShow(id);

            //Console.WriteLine(show.Json); // write the json - for now just an id


            Console.WriteLine();

            var name     = show.Name;
            var overview = show.Overview;

            // watch how it grew after getting some properties
            Console.WriteLine(show.Json);
            Console.WriteLine();

            Console.WriteLine(name);
            Console.WriteLine(overview);
            Console.WriteLine();
            //
            // write out the genres
            Console.Write("Genres:");
            var gbid = show.GenresById;

            if (null != gbid)
            {
                foreach (var g in gbid)
                {
                    Console.Write(string.Concat(" ", g.Value));
                }
            }
            Console.WriteLine();

            Console.WriteLine();

            // write out the cast
            Console.Write("Cast:");
            foreach (var c in show.Cast)
            {
                Console.WriteLine("\t{0} as {1}", c.Name, c.Character);
            }

            Console.WriteLine();

            // write out the crew.
            Console.Write("Crew:");
            foreach (var c in from cs in show.Crew select cs)
            {
                Console.WriteLine("\t{1} - {0}", c.Name, c.Job);
            }
            Console.WriteLine();
            // Seasons zero is Specials when the series has them
            // To account for that, we look to TotalSeasons instead
            // of Seasons.Length
            Console.WriteLine(
                "{0} Seasons and {1} Episodes in {2} years",
                show.TotalSeasons,
                show.TotalEpisodes,
                Math.Round((show.LastAirDate - show.FirstAirDate).TotalDays / 365)
                );

            // write out the reviews we found, if their are any.
            // this is not cached, which is why it's a paged method
            // the individual reviews are still cached
            var reviews = show.GetReviews();

            if (0 < reviews.Length)
            {
                Console.WriteLine();
                Console.WriteLine("Reviews:");
                foreach (var r in reviews)
                {
                    Console.WriteLine("\t\"{1}\" - {0}", r.Author, r.Content);
                }
            }
            var images = show.Images;

            if (0 < images.Length)
            {
                Console.WriteLine();
                Console.WriteLine("Images:");
                foreach (var i in images)
                {
                    Console.WriteLine("{0}: {1}", i.ImageType, Tmdb.GetImageUrl(i.Path));
                }
            }
            // note how the Json data associated with the object grew even more
            // in response to use using the object.
            // Console.WriteLine(show.Json); // write the json again
        }
Example #15
0
        static void _RunMovieDemo(int movieId = -1)
        {
            // fetch a movie - this just grabs the top result. By default most
            // results from the API are sorted by popularity, most popular first.
            var movie = (0 > movieId) ? Tmdb.SearchMovies("Star Wars", minPage: 0, maxPage: 0)[0] : new TmdbMovie(movieId);

            //Console.WriteLine(movie.Json); // write the json (may not be complete)

            // A note about paged functions, like the SearchMovies() function above:
            // Be careful not specifying pages. Some searches can return a lot of results.
            // if you want to limit the pages, specify BOTH parameters. Each one is 0 based.
            // The first page is 0. If they are unspecified, all pages are returned. This
            // will take several HTTP requests in most cases. Some of the paged functions
            // *require* the minPage and maxPage parameters. They'll still accept zero and
            // behave the same way, but typically, some of these functions may return
            // hundreds of pages which is why the parameters are required in those cases.

            // The search itself is not cached, but the individual results will be.

            Console.WriteLine();
            Console.WriteLine(movie.Name);
            Console.WriteLine();
            Console.Write("Overview: ");
            Console.WriteLine(movie.Overview);
            Console.WriteLine();

            // write out the genres
            Console.Write("Genres:");
            foreach (var g in movie.GenresById)
            {
                Console.Write(string.Concat(" ", g.Value));
            }

            Console.WriteLine();

            Console.WriteLine();

            // write out the cast
            Console.Write("Cast:");
            foreach (var c in movie.Cast)
            {
                Console.WriteLine("\t{0} as {1}", c.Name, c.Character);
            }

            Console.WriteLine();

            // write out the crew
            Console.Write("Crew:");
            foreach (var c in from cs in movie.Crew select cs)
            {
                Console.WriteLine("\t{1} - {0}", c.Name, c.Job);
            }

            Console.WriteLine();

            // write out the reviews we found, if their are any.
            // this is not cached, which is why it's a paged method
            // the individual reviews are still cached
            var reviews = movie.GetReviews();

            if (0 < reviews.Length)
            {
                Console.WriteLine();
                Console.WriteLine("Reviews:");
                foreach (var r in reviews)
                {
                    Console.WriteLine("\t\"{1}\" - {0}", r.Author, r.Content);
                }
            }

            var images = movie.Images;

            if (0 < images.Length)
            {
                Console.WriteLine();
                Console.WriteLine("Images:");
                foreach (var i in images)
                {
                    Console.WriteLine("{0}: {1}", i.ImageType, Tmdb.GetImageUrl(i.Path));
                }
            }

            // Use the DiscoverXXXX() methods to find movies and TV shows based on many
            // possible parameters.

            try
            {
                // create a request token
                var requestToken = Tmdb.CreateRequestToken();

                // now authenticate the token using the supplied credentials
                Tmdb.AuthenticateRequestToken(requestToken.Key, Username, Password);

                // The other option is to send a user to a website so that *they* can log
                // in and therefore validate this token. Use
                // Tmdb.GetAuthenticateRequestTokenUserUrl() to retrieve the url to send
                // the user to. That url is not an rpc sink - it requires a browser.

                // now our token is "special" in that until it expires it can be used to
                // create sessions. You don't *have* to dispose the session - the remote
                // end will eventually close it, but implementing dispose makes it easer
                // to do what i'm about to do, and also it's good practice (causes a
                // little network traffic)
                using (var session = Tmdb.CreateSession(requestToken.Key))
                {
                    // You can also perform tasks under a guest session simply by
                    // ommitting the sessionId from the calls that accept one. The system
                    // keeps a guest session open but only if it is used. If you really
                    // want to, you can use a guest session without authenticating simply by
                    // not passing around a sessionId to methods that take one. Be careful
                    // using guest actions. The service tracks IP and tracks usage. Don't
                    // use them for automated tasks.

                    // you can use a session to rate a movie under a particular account.
                    // if you don't pass a session, the current guest session is used.
                    movie.Rate(5, session);

                    // you can also delete your rating
                    movie.ClearRating(session);

                    // ending the using block or calling Close() deletes the session,
                    // basically logging the session off
                    // and expiring the session id. This doesn't apply to guest sessions.
                }
            }
            catch
            {
                Console.WriteLine();
                Console.WriteLine("Couldn't log in.");
            }
            // note how the Json data associated with the object grew in response
            // to use using the object. This is to minimize network traffic.
            // Anything fetched before will be retrieved from the cache.
            //Console.WriteLine(movie.Json); // write the json again
        }
Example #16
0
        static void _RunCacheDemo()
        {
            // Normally, you don't really have to mess with the cache in a desktop app
            // or a console app. Long running apps and services will require some
            // maintenance. Otherwise caching is automatic.

            // Fetch a show.
            var show  = new TmdbShow(2919);            // get "Burn Notice"
            var movie = new TmdbMovie(219);            // fetch "Volver"

            // right now our entries only have an id. use some properties
            // so we can get the show into the cache.
            Console.WriteLine("Fetched {0} from tmdb", show.Name);
            Console.WriteLine("Fetched {0} from tmdb", movie.Name);

            // write the cache to a file in the project directory
            //Tmdb.SaveCacheTo(@"..\..\cache.json");
            // we won't use the above helper method since we want our cache to
            // be pretty printed
            JsonObject.SaveTo(Tmdb.Json, @"..\..\cache.json", "    ");


            // Note that the cache is thread static. It's per thread instance.
            // Do not pass objects between threads. Serialize if you must like above
            // or in memory.

            // clear our cache.
            Tmdb.Json.Clear();

            // any existing instances will be orphaned. this impacts equality as well.

            // if you MUST re-cache an orphaned object, what you can do is this:
            movie = new TmdbMovie(movie.Json);
            // this will copy the old json data into a new movie instance which will then root
            // that in the current cache.

            // should only have the movie we just re-rooted above in it.
            Console.WriteLine(Tmdb.Json);

            // that's cool but how about we load our cache that we saved?

            Tmdb.LoadCacheFrom(@"..\..\cache.json");
            // Note that this MERGES the loaded data with the existing data.
            // You can call it multiple times in a row with different files
            // if you ever wanted to. This might be useful down the road
            // for cache differentials in a distributed system. There's also
            // LoadCacheFromUrl() with an eye toward distribution down the
            // road

            // remember if we create new TmdbEntry instances like movie or
            // TV objects, they will use the existing cache rather than
            // fetching from TMDB.

            // So, since we loaded the cache we should now be able to do
            show = new TmdbShow(3050);
            Console.WriteLine("This is cached: {0}", show.Name);
            // without making any remote requests.

            // use value equality semantics.
            // get the show again, this time through a search.
            // searches themselves are not cached, but each individual result
            // is. That means The Practice will get filled in with any additional
            // data returned from the search query.
            var showComparand = Tmdb.SearchShows("The Practice", minPage: 0, maxPage: 0)[0];

            // check to make sure showComparand and show are actually two different TmdbShow wrapper instances
            // should report that they are different
            Console.WriteLine("Instances are {0} actual objects", ReferenceEquals(show, showComparand) ? "the same" : "different");

            // check to make sure showComparand and show are actually logically equal.
            // should report that they are the equal
            Console.WriteLine("Instances are logically {0}", show == showComparand ? "equal" : "not equal");


            // NOTES:
            // Clearing the cache "unroots" all existing instances of TmdbEntry
            // derived classes. They will no longer operate on anything you have a
            // root for. In fact, they are still writing to parts of the old cache.
            // The moral is don't hang on to object instances for longer than you need
            // them. Don't store them as class members or in collections just because.
            // Instead, use them and throw them away. Get a new object when you need
            // it. This will ensure that the most current cache is the one being used.

            // our show and movie instances are still valid, but are not writing or
            // reading from the current cache.

            // This also impacts equality. Objects from the old cache cannot be compared
            // to objects from the new cache. They will always return false.

            // Because of the above, it's best to release all instances of the old objects
            // when you clear the cache. The system does not track which object instances
            // are expired objects. You can check if an object is expired manually, but it's
            // expensive.

            // ideally, a batch of operations is performed, then the cache can be cleared, then
            // the next batch (with all new objects) is performed, if you clear the cache at all.
            // a server app or a long running desktop app should clear it periodically, but doing
            // so will make a bunch of HTTP requests happen again, even if they already happened
            // since they weren't cached anymore.
            // The HTTP requests might be cached through the second level caching mechanism.
            //
            // if you like, you can save and load the cache from disk, that way you can keep the cache
            // across application runs. Eventually it will get big and stale though. In the future I
            // might monitor the Tmdb.Configuration.ChangeKeys to expire old objects, if i can figure
            // out how it works exactly.
        }