/// <summary> /// Common method to get a list of titles from an IMDb mobile JSON feed /// </summary> /// <param name="session"></param> /// <param name="path">path to JSON feed</param> /// <returns>a collection of titles</returns> internal static List <TitleReference> GetList(Session session, string path) { List <TitleReference> titles = new List <TitleReference>(); string data = GetResponseFromEndpoint(session, path); IMDbMobileResponse <List <IMDbTitleMobile> > response = JsonConvert.DeserializeObject <IMDbMobileResponse <List <IMDbTitleMobile> > >(data); DateTime releaseDateHeader = DateTime.MinValue; foreach (IMDbTitleMobile item in response.Data) { if (item.URL == null) { if (item.ReleaseDate > DateTime.MinValue) { releaseDateHeader = item.ReleaseDate; } continue; } TitleReference title = new TitleReference(); title.session = session; title.FillFrom(item); title.ReleaseDate = releaseDateHeader; titles.Add(title); } return(titles); }
/// <summary> /// Common method to get a list of titles from an IMDb trailer JSON feed /// </summary> /// <param name="session"></param> /// <param name="path">path to JSON feed</param> /// <returns>a collection of titles</returns> internal static List <TitleReference> GetTrailers(Session session, string uri, int token) { string url = (token > 0) ? uri + "&token=" + token : uri; List <TitleReference> titles = new List <TitleReference>(); string response = session.MakeRequest(url); //JObject parsedResults = JObject.Parse(response); var imdbResponse = JsonConvert.DeserializeObject <OnlineVideos.Sites.apondman.IMDb.DTO.IMDbResponse>(response); HashSet <string> duplicateFilter = new HashSet <string>(); foreach (var item in imdbResponse.model.items) { var titleId = item.display.titleId; if (duplicateFilter.Contains(titleId)) { continue; } duplicateFilter.Add(titleId); TitleReference title = new TitleReference(); title.session = session; title.FillFrom(item); titles.Add(title); } return(titles); }
/// <summary> /// Common method to get a list of titles from the IMDb app interface (JSON) /// </summary> /// <param name="session"></param> /// <param name="chart">name of the chart</param> /// <returns>a collection of titles</returns> internal static List <TitleReference> GetChart(Session session, string chart) { List <TitleReference> titles = new List <TitleReference>(); string data = GetResponseFromEndpoint(session, chart); IMDbResponse <IMDbSingleList <IMDbList <IMDbTitle> > > response = JsonConvert.DeserializeObject <IMDbResponse <IMDbSingleList <IMDbList <IMDbTitle> > > >(data); foreach (IMDbTitle item in response.Data.List.Items) { TitleReference title = new TitleReference(); title.session = session; title.FillFrom(item); titles.Add(title); } return(titles); }