public MXFProgram(DBProgram dbProgram) { dbProgram_ = dbProgram; if (dbProgram.keyWords != null) { List <string> keywordIds = new List <string>(); var keywordsCache = KeywordCache.instance.keywords; foreach (var keywordGroup in dbProgram.keyWords) { keywordsCache.AddKeywords(keywordGroup.Key, keywordGroup.Value); keywordIds.Add(keywordsCache.GetTopLevelKeywordId(keywordGroup.Key)); foreach (string secondLevelKeyword in keywordGroup.Value) { keywordIds.Add(keywordsCache.GetSecondLevelKeywordId(keywordGroup.Key, secondLevelKeyword)); } } keywords = string.Join(",", keywordIds); } if (isSeries) { series = SeriesInfoCache.instance.GetMxfSeriesIdBySdId(key_); } if (dbProgram.hasImages) { string imageId = ImageCache.GetSDImageIDByProgramID(key_); if (ImageCache.instance.isImageLoaded(imageId)) { guideImage = ImageCache.instance.FindOrCreateMXFImageId(imageId); } } }
private List <DBProgram> DownloadPrograms(IEnumerable <string> programIDs) { const int kBatchSize = 5000; List <string> currentBatch = new List <string>(); List <DBProgram> fetchedPrograms = new List <DBProgram>(); Func <int> FetchCurrentBatch = new Func <int>(() => { Console.WriteLine("Downloading program info from SchedulesDirect"); List <object> response = JSONClient.GetJSONResponse <List <object> >( UrlBuilder.BuildWithAPIPrefix("/programs"), currentBatch, SDTokenManager.token_manager.token); List <DBProgram> programsThisBatch = new List <DBProgram>(); // Only include programs fetched successfully, so any errors do not replace good data. List <SDProgram> successfulResponses = new List <SDProgram>(); foreach (object genericJson in response) { SDProgram sdProgram = null; try { sdProgram = JSONClient.Deserialize <SDProgram>(genericJson.ToString()); } catch (Exception exc) { Console.WriteLine("Failed to deserialize program JSON: {0}", genericJson); Misc.OutputException(exc); continue; } if (sdProgram.code > 0) { Console.WriteLine("Failed to download updated program info for programID {0}, response {1}, message: {2}", sdProgram.programID, sdProgram.response, sdProgram.message); continue; } successfulResponses.Add(sdProgram); var dbProgram = new DBProgram(sdProgram); fetchedPrograms.Add(dbProgram); programsThisBatch.Add(dbProgram); } DBManager.instance.SaveRawSDProgramResponses(successfulResponses); DBManager.instance.SaveProgramData(programsThisBatch); currentBatch.Clear(); return(0); }); foreach (string id in programIDs) { currentBatch.Add(id); if (currentBatch.Count >= kBatchSize) { FetchCurrentBatch(); } } if (currentBatch.Count > 0) { FetchCurrentBatch(); } return(fetchedPrograms); }
public DBSeriesInfo(DBProgram program) { id = SeriesIDByProgramID(program.programID); title = program.longTitle ?? program.title; shortTitle = program.shortTitle; hasGuideImage = program.hasImages; description = program.description; shortDescription = program.shortDescription; }
private string GetElementNameForRole(DBProgram.DBCastMember.RoleType role) { return role.ToString() + "Role"; }
public MXFProgram(DBProgram dbProgram) { dbProgram_ = dbProgram; if (dbProgram.keyWords != null) { List<string> keywordIds = new List<string>(); var keywordsCache = KeywordCache.instance.keywords; foreach (var keywordGroup in dbProgram.keyWords) { keywordsCache.AddKeywords(keywordGroup.Key, keywordGroup.Value); keywordIds.Add(keywordsCache.GetTopLevelKeywordId(keywordGroup.Key)); foreach(string secondLevelKeyword in keywordGroup.Value) { keywordIds.Add(keywordsCache.GetSecondLevelKeywordId(keywordGroup.Key, secondLevelKeyword)); } } keywords = string.Join(",", keywordIds); } if (isSeries) { series = SeriesInfoCache.instance.GetMxfSeriesIdBySdId(key_); } if (dbProgram.hasImages) { string imageId = ImageCache.GetSDImageIDByProgramID(key_); if (ImageCache.instance.isImageLoaded(imageId)) guideImage = ImageCache.instance.FindOrCreateMXFImageId(imageId); } }
private List<DBProgram> DownloadPrograms(IEnumerable<string> programIDs) { const int kBatchSize = 5000; List<string> currentBatch = new List<string>(); List<DBProgram> fetchedPrograms = new List<DBProgram>(); Func<int> FetchCurrentBatch = new Func<int>(() => { Console.WriteLine("Downloading program info from SchedulesDirect"); List<object> response = JSONClient.GetJSONResponse<List<object>>( UrlBuilder.BuildWithAPIPrefix("/programs"), currentBatch, SDTokenManager.token_manager.token); List<DBProgram> programsThisBatch = new List<DBProgram>(); // Only include programs fetched successfully, so any errors do not replace good data. List<SDProgram> successfulResponses = new List<SDProgram>(); foreach(object genericJson in response) { SDProgram sdProgram = null; try { sdProgram = JSONClient.Deserialize<SDProgram>(genericJson.ToString()); } catch (Exception exc) { Console.WriteLine("Failed to deserialize program JSON: {0}", genericJson); Misc.OutputException(exc); continue; } if (sdProgram.code > 0) { Console.WriteLine("Failed to download updated program info for programID {0}, response {1}, message: {2}", sdProgram.programID, sdProgram.response, sdProgram.message); continue; } successfulResponses.Add(sdProgram); var dbProgram = new DBProgram(sdProgram); fetchedPrograms.Add(dbProgram); programsThisBatch.Add(dbProgram); } DBManager.instance.SaveRawSDProgramResponses(successfulResponses); DBManager.instance.SaveProgramData(programsThisBatch); currentBatch.Clear(); return 0; }); foreach(string id in programIDs) { currentBatch.Add(id); if (currentBatch.Count >= kBatchSize) FetchCurrentBatch(); } if (currentBatch.Count > 0) FetchCurrentBatch(); return fetchedPrograms; }
public override void Initialize() { base.Initialize(); dbEntity = new DBProgram(connManager); }