private static List <XmltvEpisodeNum> BuildEpisodeNumbers(MxfScheduleEntry mxfScheduleEntry) { var list = new List <XmltvEpisodeNum>(); var mxfProgram = mxfScheduleEntry.mxfProgram; if (!mxfProgram.ProgramId.StartsWith("EPG123")) { list.Add(new XmltvEpisodeNum() { System = "dd_progid", Text = mxfProgram.Uid.Substring(9).Replace("_", ".") }); } if (mxfProgram.EpisodeNumber != 0 || mxfScheduleEntry.Part != 0) { var text = $"{(mxfProgram.SeasonNumber != 0 ? (mxfProgram.SeasonNumber - 1).ToString() : string.Empty)}.{(mxfProgram.EpisodeNumber != 0 ? (mxfProgram.EpisodeNumber - 1).ToString() : string.Empty)}.{(mxfScheduleEntry.Part != 0 ? $"{mxfScheduleEntry.Part - 1}/" : "0/")}{(mxfScheduleEntry.Parts != 0 ? $"{mxfScheduleEntry.Parts}" : "1")}"; list.Add(new XmltvEpisodeNum() { System = "xmltv_ns", Text = text }); } else if (mxfProgram.ProgramId.StartsWith("EPG123")) { // filler data - create oad of scheduled start time list.Add(new XmltvEpisodeNum() { System = "original-air-date", Text = $"{mxfScheduleEntry.StartTime.ToLocalTime():yyyy-MM-dd HH:mm:ss}" });
private static void UpdateScheduleEntryTags(ScheduleEntry wmc, MxfScheduleEntry mxf) { wmc.AudioFormat = (AudioFormat)mxf.AudioFormat; wmc.Is3D = mxf.Is3D; wmc.IsBlackout = mxf.IsBlackout; wmc.IsCC = mxf.IsCc; wmc.IsClassroom = mxf.IsClassroom; wmc.IsDelay = mxf.IsDelay; wmc.IsDvs = mxf.IsDvs; wmc.IsEnhanced = mxf.IsEnhanced; wmc.IsFinale = mxf.IsFinale; wmc.IsHdtv = mxf.IsHdtv; wmc.IsHdtvSimulCast = mxf.IsHdtvSimulCast; wmc.IsInProgress = mxf.IsInProgress; wmc.IsLetterbox = mxf.IsLetterbox; wmc.IsLive = mxf.IsLive; wmc.IsLiveSports = mxf.IsLiveSports; wmc.IsPremiere = mxf.IsPremiere; //wmc.IsRepeatFlag = mxf.IsRepeat; wmc.IsSap = mxf.IsSap; wmc.IsSubtitled = mxf.IsSubtitled; wmc.IsTape = mxf.IsTape; wmc.Part = mxf.Part; wmc.Parts = mxf.Parts; wmc.TVRating = (TVRating)mxf.TvRating; wmc.IsOnlyWmis = true; }
// Subtitles private static List <XmltvSubtitles> buildProgramSubtitles(MxfScheduleEntry mxfScheduleEntry) { if (!string.IsNullOrEmpty(mxfScheduleEntry.IsCC) || !string.IsNullOrEmpty(mxfScheduleEntry.IsSubtitled) || !string.IsNullOrEmpty(mxfScheduleEntry.IsSigned)) { List <XmltvSubtitles> list = new List <XmltvSubtitles>(); if (!string.IsNullOrEmpty(mxfScheduleEntry.IsCC)) { list.Add(new XmltvSubtitles() { Type = "teletext" }); } if (!string.IsNullOrEmpty(mxfScheduleEntry.IsSubtitled)) { list.Add(new XmltvSubtitles() { Type = "onscreen" }); } if (!string.IsNullOrEmpty(mxfScheduleEntry.IsSigned)) { list.Add(new XmltvSubtitles() { Type = "deaf-signed" }); } return(list); } return(null); }
// Audio private static XmltvAudio buildProgramAudio(MxfScheduleEntry mxfScheduleEntry) { if (!string.IsNullOrEmpty(mxfScheduleEntry.AudioFormat)) { string format = string.Empty; switch (mxfScheduleEntry.AudioFormat) { case "1": format = "mono"; break; case "2": format = "stereo"; break; case "3": format = "dolby"; break; case "4": format = "dolby digital"; break; case "5": format = "surround"; break; default: break; } if (!string.IsNullOrEmpty(format)) { return(new XmltvAudio() { Stereo = format }); } } return(null); }
// Premiere private static XmltvText buildProgramPremiere(MxfProgram mxfProgram, MxfScheduleEntry mxfScheduleEntry) { if (!string.IsNullOrEmpty(mxfScheduleEntry.IsPremiere)) { string text = string.Empty; if (!string.IsNullOrEmpty(mxfProgram.IsMovie)) { text = "Movie Premiere"; } else if (!string.IsNullOrEmpty(mxfProgram.IsSeriesPremiere)) { text = "Series Premiere"; } else if (!string.IsNullOrEmpty(mxfProgram.IsSeasonPremiere)) { text = "Season Premiere"; } else { text = "Miniseries Premiere"; } return(new XmltvText() { Text = text }); } return(null); }
private static string buildLiveFlag(MxfScheduleEntry mxfScheduleEntry) { if (string.IsNullOrEmpty(mxfScheduleEntry.IsLive)) { return(null); } return(string.Empty); }
// New private static string buildNewFlag(MxfProgram mxfProgram, MxfScheduleEntry mxfScheduleEntry) { if (!string.IsNullOrEmpty(mxfProgram.IsMovie) || !string.IsNullOrEmpty(mxfScheduleEntry.IsRepeat)) { return(null); } return(string.Empty); }
// Video private static XmltvVideo buildProgramVideo(MxfScheduleEntry mxfScheduleEntry) { if (!string.IsNullOrEmpty(mxfScheduleEntry.IsHdtv)) { return(new XmltvVideo() { Quality = "HDTV" }); } return(null); }
private static void addProgramRating(MxfScheduleEntry mxfScheduleEntry, List <XmltvRating> list) { if (mxfScheduleEntry.Ratings != null) { foreach (KeyValuePair <string, string> rating in mxfScheduleEntry.Ratings) { list.Add(new XmltvRating() { System = rating.Key, Value = rating.Value }); } } if (!string.IsNullOrEmpty(mxfScheduleEntry.TvRating)) { string rating = string.Empty; switch (mxfScheduleEntry.TvRating) { // v-chip is only for US, Canada, and Brazil case "1": rating = "TV-Y"; break; case "2": rating = "TV-Y7"; break; case "3": rating = "TV-G"; break; case "4": rating = "TV-PG"; break; case "5": rating = "TV-14"; break; case "6": rating = "TV-MA"; break; default: break; } if (!string.IsNullOrEmpty(rating)) { list.Add(new XmltvRating() { System = "VCHIP", Value = rating }); } } }
// Rating private static List <XmltvRating> buildProgramRatings(MxfProgram mxfProgram, MxfScheduleEntry mxfScheduleEntry) { if (!string.IsNullOrEmpty(mxfProgram.MpaaRating) || !string.IsNullOrEmpty(mxfScheduleEntry.TvRating) || (mxfProgram.contentRatings != null)) { List <XmltvRating> ret = new List <XmltvRating>(); addProgramRatingAdvisory(mxfProgram.HasAdult, ret, "Adult Situations"); addProgramRatingAdvisory(mxfProgram.HasBriefNudity, ret, "Brief Nudity"); addProgramRatingAdvisory(mxfProgram.HasGraphicLanguage, ret, "Graphic Language"); addProgramRatingAdvisory(mxfProgram.HasGraphicViolence, ret, "Graphic Violence"); addProgramRatingAdvisory(mxfProgram.HasLanguage, ret, "Language"); addProgramRatingAdvisory(mxfProgram.HasMildViolence, ret, "Mild Violence"); addProgramRatingAdvisory(mxfProgram.HasNudity, ret, "Nudity"); addProgramRatingAdvisory(mxfProgram.HasRape, ret, "Rape"); addProgramRatingAdvisory(mxfProgram.HasStrongSexualContent, ret, "Strong Sexual Content"); addProgramRatingAdvisory(mxfProgram.HasViolence, ret, "Violence"); addProgramRating(mxfScheduleEntry, ret); return(ret); } return(null); }
private static XmltvProgramme buildXmltvProgram(MxfScheduleEntry scheduleEntry, DateTime startTime, string channelId, out DateTime endTime) { MxfProgram mxfProgram = sdMxf.With[0].Programs[int.Parse(scheduleEntry.Program) - 1]; if (!mxfProgram.Id.Equals(scheduleEntry.Program)) { mxfProgram = sdMxf.With[0].Programs.Where(arg => arg.Id.Equals(scheduleEntry.Program)).SingleOrDefault(); } endTime = startTime + TimeSpan.FromSeconds((scheduleEntry.Duration)); return(new XmltvProgramme() { // added +0000 for NPVR; otherwise it would assume local time instead of UTC Start = startTime.ToString("yyyyMMddHHmmss") + " +0000", Stop = endTime.ToString("yyyyMMddHHmmss") + " +0000", Channel = channelId, Titles = mxfStringToXmlTextArray(mxfProgram.Title), SubTitles = mxfStringToXmlTextArray(mxfProgram.EpisodeTitle), Descriptions = mxfStringToXmlTextArray(mxfProgram.Description), Credits = buildProgramCredits(mxfProgram), Date = buildProgramDate(mxfProgram), Categories = buildProgramCategories(mxfProgram, scheduleEntry), Language = mxfStringToXmlText(!string.IsNullOrEmpty(mxfProgram.Language) ? mxfProgram.Language.Substring(0, 2) : null), Icons = buildProgramIcons(mxfProgram), Sport = grabSportEvent(mxfProgram), Teams = buildSportTeams(mxfProgram), EpisodeNums = buildEpisodeNumbers(mxfProgram, scheduleEntry, startTime, channelId), Video = buildProgramVideo(scheduleEntry), Audio = buildProgramAudio(scheduleEntry), PreviouslyShown = buildProgramPreviouslyShown(mxfProgram, scheduleEntry), Premiere = buildProgramPremiere(mxfProgram, scheduleEntry), Live = buildLiveFlag(scheduleEntry), New = string.IsNullOrEmpty(scheduleEntry.IsRepeat) ? string.Empty : null, Subtitles = buildProgramSubtitles(scheduleEntry), Rating = buildProgramRatings(mxfProgram, scheduleEntry), StarRating = buildProgramStarRatings(mxfProgram) }); }
private static XmltvProgramme BuildXmltvProgram(MxfScheduleEntry scheduleEntry, string channelId) { var mxfProgram = scheduleEntry.mxfProgram; var descriptionExtended = string.Empty; if (!config.XmltvExtendedInfoInTitleDescriptions || mxfProgram.IsPaidProgramming) { return new XmltvProgramme() { // added +0000 for NPVR; otherwise it would assume local time instead of UTC Start = $"{scheduleEntry.StartTime:yyyyMMddHHmmss} +0000", Stop = $"{scheduleEntry.StartTime + TimeSpan.FromSeconds(scheduleEntry.Duration):yyyyMMddHHmmss} +0000", Channel = channelId, Titles = MxfStringToXmlTextArray(mxfProgram.Title), SubTitles = MxfStringToXmlTextArray(mxfProgram.EpisodeTitle), Descriptions = MxfStringToXmlTextArray((descriptionExtended + mxfProgram.Description).Trim()), Credits = BuildProgramCredits(mxfProgram), Date = BuildProgramDate(mxfProgram), Categories = BuildProgramCategories(mxfProgram), Language = MxfStringToXmlText(!string.IsNullOrEmpty(mxfProgram.Language) ? mxfProgram.Language.Substring(0, 2) : null), Icons = BuildProgramIcons(mxfProgram), Sport = GrabSportEvent(mxfProgram), Teams = BuildSportTeams(mxfProgram), EpisodeNums = BuildEpisodeNumbers(scheduleEntry), Video = BuildProgramVideo(scheduleEntry), Audio = BuildProgramAudio(scheduleEntry), PreviouslyShown = BuildProgramPreviouslyShown(scheduleEntry), Premiere = BuildProgramPremiere(scheduleEntry), Live = BuildLiveFlag(scheduleEntry), New = !scheduleEntry.IsRepeat ? string.Empty : null, Subtitles = BuildProgramSubtitles(scheduleEntry), Rating = BuildProgramRatings(scheduleEntry), StarRating = BuildProgramStarRatings(mxfProgram) } } ; if (mxfProgram.IsMovie && mxfProgram.Year > 0) { descriptionExtended = $"{mxfProgram.Year}"; } else if (!mxfProgram.IsMovie) { if (scheduleEntry.IsLive) { descriptionExtended = "[LIVE]"; } else if (scheduleEntry.IsPremiere) { descriptionExtended = "[PREMIERE]"; } else if (scheduleEntry.IsFinale) { descriptionExtended = "[FINALE]"; } else if (!scheduleEntry.IsRepeat) { descriptionExtended = "[NEW]"; } else if (scheduleEntry.IsRepeat && !mxfProgram.IsGeneric) { descriptionExtended = "[REPEAT]"; } if (!config.PrefixEpisodeTitle && !config.PrefixEpisodeDescription && !config.AppendEpisodeDesc) { if (mxfProgram.SeasonNumber > 0 && mxfProgram.EpisodeNumber > 0) { descriptionExtended += $" S{mxfProgram.SeasonNumber}:E{mxfProgram.EpisodeNumber}"; } else if (mxfProgram.EpisodeNumber > 0) { descriptionExtended += $" #{mxfProgram.EpisodeNumber}"; } } } //if (scheduleEntry.IsHdtv) descriptionExtended += " HD"; //if (!string.IsNullOrEmpty(mxfProgram.Language)) descriptionExtended += $" {new CultureInfo(mxfProgram.Language).DisplayName}"; //if (scheduleEntry.IsCC) descriptionExtended += " CC"; //if (scheduleEntry.IsSigned) descriptionExtended += " Signed"; //if (scheduleEntry.IsSap) descriptionExtended += " SAP"; //if (scheduleEntry.IsSubtitled) descriptionExtended += " SUB"; string[] tvRatings = { "", "TV-Y", "TV-Y7", "TV-G", "TV-PG", "TV-14", "TV-MA", "", "Kinder bis 12 Jahren", "Freigabe ab 12 Jahren", "Freigabe ab 16 Jahren", "Keine Jugendfreigabe", "", "Déconseillé aux moins de 10 ans", "Déconseillé aux moins de 12 ans", "Déconseillé aux moins de 16 ans", "Déconseillé aux moins de 18 ans", "모든 연령 시청가", "7세 이상 시청가", "12세 이상 시청가", "15세 이상 시청가", "19세 이상 시청가", "SKY-UC", "SKY-U", "SKY-PG", "SKY-12", "SKY-15", "SKY-18", "SKY-R18" }; string[] mpaaRatings = { "", "G", "PG", "PG-13", "R", "NC-17", "X", "NR", "AO" }; if (!string.IsNullOrEmpty(tvRatings[scheduleEntry.TvRating])) { descriptionExtended += $" {tvRatings[scheduleEntry.TvRating]}"; if (mxfProgram.MpaaRating > 0) { descriptionExtended += ","; } } if (mxfProgram.MpaaRating > 0) { descriptionExtended += $" {mpaaRatings[mxfProgram.MpaaRating]}"; } { var advisories = string.Empty; if (mxfProgram.HasAdult) { advisories += "Adult Situations,"; } if (mxfProgram.HasGraphicLanguage) { advisories += "Graphic Language,"; } else if (mxfProgram.HasLanguage) { advisories += "Language,"; } if (mxfProgram.HasStrongSexualContent) { advisories += "Strong Sexual Content,"; } if (mxfProgram.HasGraphicViolence) { advisories += "Graphic Violence,"; } else if (mxfProgram.HasMildViolence) { advisories += "Mild Violence,"; } else if (mxfProgram.HasViolence) { advisories += "Violence,"; } if (mxfProgram.HasNudity) { advisories += "Nudity,"; } else if (mxfProgram.HasBriefNudity) { advisories += "Brief Nudity,"; } if (mxfProgram.HasRape) { advisories += "Rape,"; } if (!string.IsNullOrEmpty(advisories)) { descriptionExtended += $" ({advisories.Trim().TrimEnd(',').Replace(",", ", ")})"; } } if (mxfProgram.IsMovie && mxfProgram.HalfStars > 0) { descriptionExtended += $" {mxfProgram.HalfStars * 0.5:N1}/4.0"; } else if (!mxfProgram.IsMovie) { if (!mxfProgram.IsGeneric && !string.IsNullOrEmpty(mxfProgram.OriginalAirdate)) { descriptionExtended += $" Original air date: {DateTime.Parse(mxfProgram.OriginalAirdate):d}"; } } if (!string.IsNullOrEmpty(descriptionExtended)) { descriptionExtended = descriptionExtended.Trim() + "\u000D\u000A"; } return(new XmltvProgramme() { // added +0000 for NPVR; otherwise it would assume local time instead of UTC Start = $"{scheduleEntry.StartTime:yyyyMMddHHmmss} +0000", Stop = $"{scheduleEntry.StartTime + TimeSpan.FromSeconds(scheduleEntry.Duration):yyyyMMddHHmmss} +0000", Channel = channelId, Titles = MxfStringToXmlTextArray(mxfProgram.Title), SubTitles = MxfStringToXmlTextArray(mxfProgram.EpisodeTitle), Descriptions = MxfStringToXmlTextArray((descriptionExtended + mxfProgram.Description).Trim()), Credits = BuildProgramCredits(mxfProgram), Date = BuildProgramDate(mxfProgram), Categories = BuildProgramCategories(mxfProgram), Language = MxfStringToXmlText(!string.IsNullOrEmpty(mxfProgram.Language) ? mxfProgram.Language.Substring(0, 2) : null), Icons = BuildProgramIcons(mxfProgram), Sport = GrabSportEvent(mxfProgram), Teams = BuildSportTeams(mxfProgram), EpisodeNums = BuildEpisodeNumbers(scheduleEntry), Video = BuildProgramVideo(scheduleEntry), Audio = BuildProgramAudio(scheduleEntry), PreviouslyShown = BuildProgramPreviouslyShown(scheduleEntry), Premiere = BuildProgramPremiere(scheduleEntry), Live = BuildLiveFlag(scheduleEntry), New = (!scheduleEntry.IsRepeat) ? string.Empty : null, Subtitles = BuildProgramSubtitles(scheduleEntry), //Rating = BuildProgramRatings(mxfProgram, scheduleEntry), //StarRating = BuildProgramStarRatings(mxfProgram) }); }
// Previously Shown private static XmltvPreviouslyShown buildProgramPreviouslyShown(MxfProgram mxfProgram, MxfScheduleEntry mxfScheduleEntry) { if (!string.IsNullOrEmpty(mxfScheduleEntry.IsRepeat)) { //if (!string.IsNullOrEmpty(mxfProgram.OriginalAirdate)) //{ // return new XmltvPreviouslyShown() { Start = mxfProgram.OriginalAirdate.Replace("-", "") }; //} return(new XmltvPreviouslyShown() { Text = string.Empty }); } return(null); }
private static List <XmltvEpisodeNum> buildEpisodeNumbers(MxfProgram mxfProgram, MxfScheduleEntry mxfScheduleEntry, DateTime startTime, string channelId) { List <XmltvEpisodeNum> list = new List <XmltvEpisodeNum>(); if (!mxfProgram.tmsId.StartsWith("EPG123")) { list.Add(new XmltvEpisodeNum() { System = "dd_progid", Text = mxfProgram.Uid.Substring(9).Replace("_", ".") }); } if (!string.IsNullOrEmpty(mxfProgram.EpisodeNumber) || !string.IsNullOrEmpty(mxfScheduleEntry.Part)) { string text = string.Format("{0}.{1}.{2}{3}", (mxfProgram.SeasonNumber != null) ? (int.Parse(mxfProgram.SeasonNumber) - 1).ToString() : string.Empty, (mxfProgram.EpisodeNumber != null) ? (int.Parse(mxfProgram.EpisodeNumber) - 1).ToString() : string.Empty, (mxfScheduleEntry.Part != null) ? (int.Parse(mxfScheduleEntry.Part) - 1).ToString() + "/" : "0/", (mxfScheduleEntry.Parts != null) ? (int.Parse(mxfScheduleEntry.Parts)).ToString() : "1"); list.Add(new XmltvEpisodeNum() { System = "xmltv_ns", Text = text }); } else if (mxfProgram.tmsId.StartsWith("EPG123")) { // filler data - create oad of scheduled start time list.Add(new XmltvEpisodeNum() { System = "original-air-date", Text = startTime.ToLocalTime().ToString("yyyy-MM-dd HH:mm:ss") }); } else if (!mxfProgram.tmsId.StartsWith("MV")) { // add this entry due to Plex identifying anything without an episode number as being a movie string oad = mxfProgram.OriginalAirdate; if (string.IsNullOrEmpty(mxfScheduleEntry.IsRepeat)) { oad = startTime.ToLocalTime().ToString("yyyy-MM-dd HH:mm:") + randomNumber.Next(1, 60).ToString("00"); } else if (string.IsNullOrEmpty(oad)) { oad = "1900-01-01"; } list.Add(new XmltvEpisodeNum() { System = "original-air-date", Text = oad }); } if (mxfProgram.jsonProgramData.Metadata != null) { foreach (Dictionary <string, sdProgramMetadataProvider> providers in mxfProgram.jsonProgramData.Metadata) { foreach (KeyValuePair <string, sdProgramMetadataProvider> provider in providers) { if (provider.Key.ToLower().Equals("thetvdb")) { if (provider.Value.SeriesID > 0) { list.Add(new XmltvEpisodeNum() { System = "thetvdb.com", Text = "series/" + provider.Value.SeriesID.ToString() }); } if (provider.Value.EpisodeID > 0) { list.Add(new XmltvEpisodeNum() { System = "thetvdb.com", Text = "episode/" + provider.Value.EpisodeID.ToString() }); } } } } } return(list); }
// Categories private static List <XmltvText> buildProgramCategories(MxfProgram mxfProgram, MxfScheduleEntry mxfScheduleEntry) { if (!string.IsNullOrEmpty(mxfProgram.Keywords)) { HashSet <string> categories = new HashSet <string>(); foreach (string keywordId in mxfProgram.Keywords.Split(',')) { foreach (MxfKeyword keyword in sdMxf.With[0].Keywords) { if (keyword.Word.ToLower().Contains("premiere")) { continue; } if (keyword.Id == keywordId) { categories.Add(keyword.Word.Equals("Movies") ? "Movie" : keyword.Word); break; } } } if (!string.IsNullOrEmpty(mxfScheduleEntry.IsLive)) { //categories.Add("Live"); } if (categories.Contains("Kids") && categories.Contains("Children")) { categories.Remove("Kids"); } if (categories.Count > 0) { List <XmltvText> ret = new List <XmltvText>(); foreach (string category in categories) { ret.Add(new XmltvText() { Text = category }); } return(ret); } } return(null); }