public static void NetflixGenres(string term = "Jim Carrey") { var data = OAuth1a.GetNextflixCatalogDataString( "categories/genres", term, max_results: "900", outputPath: System.Web.HttpContext.Current.Server.MapPath("~/dbfiles/genres.NFPOX")); }
//retrieve api data private static string GetOmbdbTitleInfoFromApi(string title, string year = null, string response_type = "xml", string tomatoes = "true") { //build url string base_url = @"http://www.omdbapi.com/"; string url_params = String.Format( "?t={0}&y={1}&tomatoes={2}&r={3}", OAuth1a.UpperCaseUrlEncode(title), year, tomatoes, response_type); string full_url = String.Format("{0}{1}", base_url, url_params); //Trace.WriteLine(full_url); Thread.Sleep(1000); Trace.WriteLine(" GetResponse'ing"); HttpWebRequest web = (HttpWebRequest)WebRequest.Create(full_url); web.KeepAlive = true; web.UserAgent = "Quickflicks API by Tankor Smash"; //set timeout to half a second //web.Timeout = 3000; var response = web.GetResponse(); Stream objStream; objStream = response.GetResponseStream(); Trace.WriteLine(" GetResponseStream'ing"); StreamReader objReader; objReader = new StreamReader(objStream); Trace.WriteLine(" ReadToEnd'ing"); string string_response = objReader.ReadToEnd(); //Trace.WriteLine(string_response); return(string_response); }
public static void Api(string term = "Jim Carrey") { MovieDbContext db = new MovieDbContext(); //grab new movies, turn one into a Movie and view it var data = OAuth1a.GetNextflixCatalogDataString( "catalog/titles/streaming", term, max_results: "100", outputPath: System.Web.HttpContext.Current.Server.MapPath("~/dbfiles/fixedAPI.NFPOX")); /*var titles = * NetFlixAPI.Create.ParseXmlForCatalogTitles(data); * * List<Movie> movies = new List<Movie>(); * * foreach (Title title in titles) * { * //create a movie from the title, and add it to a list of movies and * // the database * Movie movie = NetFlixAPI.Create.CreateMovie(title); * movies.Add(movie); * db.Movies.Add(movie); * * //create a boxart object from the movie and title object * BoxArt boxArt = * NetFlixAPI.Create.CreateMovieBoxartFromTitle(movie, title); * db.BoxArts.Add(boxArt); * * //for all the genres in a title, create the linking MtG * // and then add that object to the db * foreach (Genre genre in title.ListGenres) * { * MovieToGenre movieToGenre = * NetFlixAPI.Create.CreateMovieMovieToGenre(movie, * genre); * db.MovieToGenres.Add(movieToGenre); * * } * } * * db.SaveChanges(); */ }
public static void FullDbBuild() { MovieDbContext db = new MovieDbContext(); string netflixPosFilepath = System.Web.HttpContext.Current.Server.MapPath("~/dbfiles/fixedAPI.NFPOX"); //retrieve API .POX var netflixCatalogOutputPath = OAuth1a.GetNextflixCatalogDataString("catalog/titles/streaming", "", outputPath: netflixPosFilepath); var genresNFPOX = System.Web.HttpContext.Current.Server.MapPath("~/dbfiles/genres.NFPOX"); var omdbZIP = System.Web.HttpContext.Current.Server.MapPath("~/dbfiles/omdb.zip"); var omdbDUMP = System.Web.HttpContext.Current.Server.MapPath("~/dbfiles/omdb.DUMP"); var omdbTXT = System.Web.HttpContext.Current.Server.MapPath("~/dbfiles/omdb.txt"); var tomatoesTXT = System.Web.HttpContext.Current.Server.MapPath("~/dbfiles/tomatoes.txt"); //join the lines that don't match <catalog to the ones above it Tools.JoinLines(netflixPosFilepath); //Parse the netflix NFPOX and make sure the genres.nfpox exists and is up to date Tools.UpdateGenreList(netflixPosFilepath); //build a genres txt file for all the genres in the NFPOX //ASSUMES GENRES.NFPOX IS THERE PopulateGenres.PopulateGenresTable(); //parse the lines into a Title then Movie object, along with boxart data and genre Tools.BuildMoviesBoxartGenresTables(netflixPosFilepath); //download the omdbapi Omdb.DownloadOmdbZipAndExtract(omdbZIP); ////parse it for omdbentrys, serialize it to file //Tools.SerializeOmdbTsv(omdbDUMP, omdbTXT, tomatoesTXT); ////deserialize the file, turn it into omdb //// can't remember if it does it here or not, but marry the omdbs and movie //Tools.RebuildOmdbsFromProtobufDump(omdbDUMP); //new way to turn the TSV into Omdb db TSVParse.OptimizedPopulateOmdbTableFromTsv(omdbTXT, tomatoesTXT); Tools.MarryMovieToOmdb(db); }