private static void DetermineSeriesInfo(ref MxfProgram mxfProgram, sdProgram sdProgram) { // do not extend cast and crew for paid programming if (string.IsNullOrEmpty(mxfProgram.IsPaidProgramming)) { mxfProgram.HasExtendedCastAndCrew = "true"; } // for sports programs that start with "SP", create a series entry based on program title // this groups them all together as a series for recordings MxfSeriesInfo mxfSeriesInfo; if (mxfProgram.tmsId.StartsWith("SP")) { string name = mxfProgram.Title.Replace(' ', '_'); mxfSeriesInfo = sdMxf.With[0].getSeriesInfo(name); sportsSeries.Add(name, mxfProgram.tmsId.Substring(0, 10)); } else { // create a seriesInfo entry if needed mxfSeriesInfo = sdMxf.With[0].getSeriesInfo(mxfProgram.tmsId.Substring(2, 8)); } mxfSeriesInfo.Title = mxfSeriesInfo.Title ?? mxfProgram.Title; mxfProgram.Series = mxfSeriesInfo.Id; }
private static void determineCastAndCrew(ref MxfProgram prg, sdProgram sd) { prg.ActorRole = getPersons(sd.Cast, new string[] { "Actor", "Voice", "Judge" }); prg.DirectorRole = getPersons(sd.Crew, new string[] { "Director" }); prg.GuestActorRole = getPersons(sd.Cast, new string[] { "Guest" }); // "Guest Star", "Guest" prg.HostRole = getPersons(sd.Cast, new string[] { "Anchor", "Host", "Presenter", "Narrator", "Correspondent" }); prg.ProducerRole = getPersons(sd.Crew, new string[] { "Executive Producer" }); // "Producer", "Executive Producer", "Co-Executive Producer" prg.WriterRole = getPersons(sd.Crew, new string[] { "Writer", "Story" }); // "Screenwriter", "Writer", "Co-Writer" }
private static void determineEpisodeInfo(ref MxfProgram prg, sdProgram sd) { if (sd.EntityType == "Episode") { // use the last 4 numbers as a production number int episode = int.Parse(prg.tmsId.Substring(10)); if (episode > 0) { prg.EpisodeNumber = episode.ToString(); } if (sd.Metadata != null) { // grab season and episode numbers if available foreach (Dictionary <string, sdProgramMetadataProvider> providers in sd.Metadata) { sdProgramMetadataProvider provider; if (providers.TryGetValue("Gracenote", out provider)) { if ((provider == null) || (provider.EpisodeNumber == 0)) { continue; } prg.SeasonNumber = provider.SeasonNumber.ToString(); prg.EpisodeNumber = provider.EpisodeNumber.ToString(); if (!config.TheTVDBNumbers) { break; } } else if (providers.TryGetValue("TheTVDB", out provider)) { if ((provider == null) || (provider.EpisodeNumber == 0) || (provider.SeasonNumber > 255)) { continue; } prg.SeasonNumber = provider.SeasonNumber.ToString(); prg.EpisodeNumber = provider.EpisodeNumber.ToString(); if (config.TheTVDBNumbers) { break; } } } } // if there is a season number, create as seasonInfo entry if (!string.IsNullOrEmpty(prg.SeasonNumber)) { prg.Season = sdMxf.With[0].getSeasonId(prg.tmsId.Substring(2, 8), prg.SeasonNumber); } } }
private static bool buildAllProgramEntries() { // reset counters processedObjects = 0; Logger.WriteMessage(string.Format("Entering buildAllProgramEntries() for {0} programs.", totalObjects = sdMxf.With[0].Programs.Count)); ++processStage; reportProgress(); // fill mxf programs with cached values and queue the rest programQueue = new List <string>(); for (int i = 0; i < sdMxf.With[0].Programs.Count; ++i) { string filepath = string.Format("{0}\\{1}", Helper.Epg123CacheFolder, safeFilename(sdMxf.With[0].Programs[i].md5)); FileInfo file = new FileInfo(filepath); if (file.Exists && (file.Length > 0)) { ++processedObjects; reportProgress(); using (StreamReader reader = File.OpenText(filepath)) { JsonSerializer serializer = new JsonSerializer(); sdProgram program = (sdProgram)serializer.Deserialize(reader, typeof(sdProgram)); sdMxf.With[0].Programs[i] = buildMxfProgram(sdMxf.With[0].Programs[i], program); } File.SetLastAccessTimeUtc(filepath, DateTime.UtcNow); } else { programQueue.Add(sdMxf.With[0].Programs[i].tmsId); } } Logger.WriteVerbose(string.Format("Found {0} cached program descriptions.", processedObjects)); // maximum 5000 queries at a time if (programQueue.Count > 0) { Parallel.For(0, (programQueue.Count / MAXQUERIES + 1), new ParallelOptions { MaxDegreeOfParallelism = MAXPARALLELDOWNLOADS }, i => { downloadProgramResponses(i * MAXQUERIES); }); processProgramResponses(); if (processedObjects != totalObjects) { Logger.WriteWarning("Problem occurred during buildAllProgramEntries(). Did not process all program description responses."); } } Logger.WriteInformation(string.Format("Processed {0} program descriptions.", processedObjects)); Logger.WriteMessage("Exiting buildAllProgramEntries(). SUCCESS."); programQueue = null; programResponses = null; return(true); }
private static void determineContentAdvisory(ref MxfProgram prg, sdProgram sd) { // fill content ratings and advisories; set flags HashSet <string> advisories = new HashSet <string>(); if (sd.ContentRating != null) { string[] ratings = !string.IsNullOrEmpty(config.RatingsOrigin) ? config.RatingsOrigin.Split(',') : new string[] { RegionInfo.CurrentRegion.ThreeLetterISORegionName }; prg.contentRatings = new Dictionary <string, string>(); foreach (sdProgramContentRating rating in sd.ContentRating) { if (string.IsNullOrEmpty(rating.Country) || !string.IsNullOrEmpty(Helper.tableContains(ratings, "ALL")) || !string.IsNullOrEmpty(Helper.tableContains(ratings, rating.Country))) { prg.contentRatings.Add(rating.Body, rating.Code); } if (rating.ContentAdvisory != null) { foreach (string reason in rating.ContentAdvisory) { advisories.Add(reason); } } } } if (sd.ContentAdvisory != null) { foreach (string reason in sd.ContentAdvisory) { advisories.Add(reason); } } if (advisories.Count > 0) { string[] advisoryTable = advisories.ToArray(); // set flags prg.HasAdult = Helper.tableContains(advisoryTable, "Adult Situations"); prg.HasBriefNudity = Helper.tableContains(advisoryTable, "Brief Nudity"); prg.HasGraphicLanguage = Helper.tableContains(advisoryTable, "Graphic Language"); prg.HasGraphicViolence = Helper.tableContains(advisoryTable, "Graphic Violence"); prg.HasLanguage = Helper.tableContains(advisoryTable, "Adult Language"); prg.HasMildViolence = Helper.tableContains(advisoryTable, "Mild Violence"); prg.HasNudity = Helper.tableContains(advisoryTable, "Nudity"); prg.HasRape = Helper.tableContains(advisoryTable, "Rape"); prg.HasStrongSexualContent = Helper.tableContains(advisoryTable, "Strong Sexual Content"); prg.HasViolence = Helper.tableContains(advisoryTable, "Violence"); prg.contentAdvisories = advisoryTable; } }
private static void AddModernMediaUiPlusProgram(sdProgram sd) { // create entry in ModernMedia UI+ dictionary ModernMediaUiPlus.Programs.Add(sd.ProgramID, new ModernMediaUiPlusPrograms() { ContentRating = sd.ContentRating, EventDetails = sd.EventDetails, KeyWords = sd.KeyWords, Movie = sd.Movie, OriginalAirDate = (!string.IsNullOrEmpty(sd.ShowType) && sd.ShowType.ToLower().Contains("series") ? sd.OriginalAirDate : null), ShowType = sd.ShowType }); }
private static MxfProgram buildMxfProgram(MxfProgram prg, sdProgram sd) { prg.jsonProgramData = sd; // populate title, short title, description, and short description determineTitlesAndDescriptions(ref prg, sd); // set program flags setProgramFlags(ref prg, sd); // populate program keywords determineProgramKeywords(ref prg, sd); // determine movie or series information if (!string.IsNullOrEmpty(prg.IsMovie)) { // populate mpaa and star rating as well as enable extended information determineMovieInfo(ref prg, sd); } else { // take care of series and episode fields DetermineSeriesInfo(ref prg, sd); determineEpisodeInfo(ref prg, sd); completeEpisodeTitle(ref prg); } // set content reason flags determineContentAdvisory(ref prg, sd); // populate the cast and crew determineCastAndCrew(ref prg, sd); // add program to array for ModernMedia UI+ if (config.ModernMediaUiPlusSupport) { AddModernMediaUiPlusProgram(sd); } return(prg); }
private static void determineMovieInfo(ref MxfProgram prg, sdProgram sd) { // fill MPAA rating prg.MpaaRating = decodeMpaaRating(sd.ContentRating); // populate movie specific attributes if (sd.Movie != null) { prg.Year = sd.Movie.Year; prg.HalfStars = decodeStarRating(sd.Movie.QualityRating); } else if (!string.IsNullOrEmpty(prg.OriginalAirdate)) { prg.Year = prg.OriginalAirdate.Substring(0, 4); } prg.HasExtendedCastAndCrew = "true"; prg.HasExtendedSynopsis = "true"; prg.HasReview = "true"; prg.HasSimilarPrograms = "true"; }
private static void determineTitlesAndDescriptions(ref MxfProgram prg, sdProgram sd) { // populate titles if (sd.Titles != null) { prg.Title = sd.Titles[0].Title120; } else { Logger.WriteWarning(string.Format("Program {0} is missing required content.", sd.ProgramID)); } prg.EpisodeTitle = sd.EpisodeTitle150; // populate descriptions and language if (sd.Descriptions != null) { string lang = string.Empty; prg.ShortDescription = getDescriptions(sd.Descriptions.Description100, out lang); prg.Description = getDescriptions(sd.Descriptions.Description1000, out lang); // if short description is empty, not a movie, and append episode option is enabled // copy long description into short description if (string.IsNullOrEmpty(prg.ShortDescription) && !sd.EntityType.ToLower().Equals("movie") && config.AppendEpisodeDesc) { prg.ShortDescription = prg.Description; } // populate language if (!string.IsNullOrEmpty(lang)) { prg.Language = lang.ToLower(); } } prg.OriginalAirdate = sd.OriginalAirDate; }
private static void determineProgramKeywords(ref MxfProgram prg, sdProgram sd) { // determine primary group of program GROUPS group = GROUPS.UNKNOWN; if (!string.IsNullOrEmpty(prg.IsMovie)) { group = GROUPS.MOVIES; } else if (!string.IsNullOrEmpty(prg.IsPaidProgramming)) { group = GROUPS.PAIDPROGRAMMING; } else if (!string.IsNullOrEmpty(prg.IsSports)) { group = GROUPS.SPORTS; } else if (!string.IsNullOrEmpty(prg.IsKids)) { group = GROUPS.KIDS; } else if (!string.IsNullOrEmpty(prg.IsEducational)) { group = GROUPS.EDUCATIONAL; } else if (!string.IsNullOrEmpty(prg.IsNews)) { group = GROUPS.NEWS; } else if (!string.IsNullOrEmpty(prg.IsSpecial)) { group = GROUPS.SPECIAL; } else if (!string.IsNullOrEmpty(prg.IsReality)) { group = GROUPS.REALITY; } else if (!string.IsNullOrEmpty(prg.IsSeries)) { group = GROUPS.SERIES; } // build the keywords/categories if (group != GROUPS.UNKNOWN) { prg.Keywords = string.Format("k{0}", (int)group + 1); // add premiere categories as necessary if (!string.IsNullOrEmpty(prg.IsSeasonPremiere) || !string.IsNullOrEmpty(prg.IsSeriesPremiere)) { prg.Keywords += string.Format(",k{0}", (int)GROUPS.PREMIERES + 1); if (!string.IsNullOrEmpty(prg.IsSeasonPremiere)) { prg.Keywords += "," + sdMxf.With[0].KeywordGroups[(int)GROUPS.PREMIERES].getKeywordId("Season Premiere"); } if (!string.IsNullOrEmpty(prg.IsSeriesPremiere)) { prg.Keywords += "," + sdMxf.With[0].KeywordGroups[(int)GROUPS.PREMIERES].getKeywordId("Series Premiere"); } } else if (!string.IsNullOrEmpty(prg.IsPremiere)) { if (group == GROUPS.MOVIES) { prg.Keywords += "," + sdMxf.With[0].KeywordGroups[(int)group].getKeywordId("Premiere"); } else if (Helper.tableContains(sd.Genres, "miniseries") == "true") { prg.Keywords += string.Format(",k{0}", (int)GROUPS.PREMIERES + 1); prg.Keywords += "," + sdMxf.With[0].KeywordGroups[(int)GROUPS.PREMIERES].getKeywordId("Miniseries Premiere"); } } // now add the real categories if (sd.Genres != null) { foreach (string genre in sd.Genres) { string key = sdMxf.With[0].KeywordGroups[(int)group].getKeywordId(genre); List <string> keys = prg.Keywords.Split(',').ToList(); if (!keys.Contains(key)) { prg.Keywords += "," + key; } } } if (prg.Keywords.Length < 5) { string key = sdMxf.With[0].KeywordGroups[(int)group].getKeywordId("Uncategorized"); prg.Keywords += "," + key; } } }
private static void setProgramFlags(ref MxfProgram prg, sdProgram sd) { // transfer genres to mxf program prg.IsAction = Helper.tableContains(sd.Genres, "Action"); prg.IsComedy = Helper.tableContains(sd.Genres, "Comedy"); prg.IsDocumentary = Helper.tableContains(sd.Genres, "Documentary"); prg.IsDrama = Helper.tableContains(sd.Genres, "Drama"); prg.IsEducational = Helper.tableContains(sd.Genres, "Educational"); prg.IsHorror = Helper.tableContains(sd.Genres, "Horror"); //prg.IsIndy = null; prg.IsKids = Helper.tableContains(sd.Genres, "Children"); prg.IsMusic = Helper.tableContains(sd.Genres, "Music"); prg.IsNews = Helper.tableContains(sd.Genres, "News"); prg.IsReality = Helper.tableContains(sd.Genres, "Reality"); prg.IsRomance = Helper.tableContains(sd.Genres, "Romance"); prg.IsScienceFiction = Helper.tableContains(sd.Genres, "Science Fiction"); prg.IsSoap = Helper.tableContains(sd.Genres, "Soap"); prg.IsThriller = Helper.tableContains(sd.Genres, "Suspense"); // below flags are populated when creating the program in processMd5ScheduleEntry(string md5) // prg.IsPremiere // prg.IsSeasonFinale // prg.IsSeasonPremiere // prg.IsSeriesFinale // prg.IsSeriesPremiere // transfer show types to mxf program //prg.IsLimitedSeries = null; prg.IsMiniseries = Helper.stringContains(sd.ShowType, "Miniseries"); prg.IsMovie = Helper.stringContains(sd.EntityType, "Movie"); prg.IsPaidProgramming = Helper.stringContains(sd.ShowType, "Paid Programming"); //prg.IsProgramEpisodic = null; //prg.IsSerial = null; prg.IsSeries = Helper.stringContains(sd.ShowType, "Series") ?? Helper.stringContains(sd.ShowType, "Sports non-event"); prg.IsShortFilm = Helper.stringContains(sd.ShowType, "Short Film"); prg.IsSpecial = Helper.stringContains(sd.ShowType, "Special"); prg.IsSports = Helper.stringContains(sd.ShowType, "Sports event"); // set isGeneric flag if programID starts with "SH", is a series, is not a miniseries, and is not paid programming if (prg.tmsId.StartsWith("SH") && ((!string.IsNullOrEmpty(prg.IsSports) && string.IsNullOrEmpty(Helper.stringContains(sd.EntityType, "Sports"))) || (!string.IsNullOrEmpty(prg.IsSeries) && string.IsNullOrEmpty(prg.IsMiniseries) && string.IsNullOrEmpty(prg.IsPaidProgramming)))) { prg.IsGeneric = "true"; } // special case to flag sports events ** I CURRENTLY SEE NO ADVANTAGE TO DOING THIS ** //if (!string.IsNullOrEmpty(Helper.stringContains(sd.ShowType, "Sports Event"))) //{ // // find all schedule entries that link to this program // foreach (MxfScheduleEntries mxfScheduleEntries in sdMxf.With[0].ScheduleEntries) // { // foreach (MxfScheduleEntry mxfScheduleEntry in mxfScheduleEntries.ScheduleEntry) // { // if (mxfScheduleEntry.Program.Equals(prg.Id) && !string.IsNullOrEmpty(mxfScheduleEntry.IsLive)) // { // mxfScheduleEntry.IsLiveSports = "true"; // } // } // } //} }