public static bool GetScheduleEventForTVProgramme(CommonEPG.TVProgramme tvp, ref ScheduleEvent matchingEvent, ref ScheduleRequest matchingRequest) { CommonEPG.TVService tvc = EPGManager.TVServiceWithIDOrNull(tvp.ServiceID); if (tvc == null) { return(false); } return(GetScheduleEventAtExactTimeOnChannel(tvp.StartTimeDT(), tvc.Callsign, false, "", ref matchingEvent, ref matchingRequest)); }
private bool StreamVideoUsingTVProgramme(TVProgramme tvp, int Quality, double StartAt, int iPlayerWidth, int iPlayerHeight) { // Get table for display string tblShow = FileCache.ReadSkinTextFile("stream_show.htm"); txtPageTitle = tvp.Title; tblShow = tblShow.Replace("**EPISODETITLE**", tvp.EpisodeTitle); tblShow = tblShow.Replace("**DESCRIPTION**", tvp.Description); // Set up streaming parameters WTVProfileQuality qual = WTVProfileQuality.Normal; switch (Quality) { case 0: qual = WTVProfileQuality.Low; break; case 1: qual = WTVProfileQuality.Normal; break; case 2: qual = WTVProfileQuality.Med; break; case 3: qual = WTVProfileQuality.High; break; case 4: qual = WTVProfileQuality.UltraHigh; break; default: qual = WTVProfileQuality.Low; break; } WTVStreamingVideoRequest svrq = new WTVStreamingVideoRequest(); svrq.FileName = tvp.Filename; svrq.Quality = qual; svrq.StartAt = TimeSpan.FromSeconds(StartAt); svrq.DeInterlaceMode = 1; WTVStreamingVideoResult rs = DSStreamingManager.Default.StartStreamer(svrq); if (rs.ResultCode == DSStreamResultCodes.OK) { // Wait for streaming to start Thread.Sleep(3500); // Compose stream URL StringBuilder sbStreamURL = new StringBuilder(30); sbStreamURL.Append(@"mms://"); sbStreamURL.Append(Request.Url.Host); sbStreamURL.Append(":" + rs.Port.ToString() ); sbStreamURL.Append(@"/tvshow.wmv"); tblShow = tblShow.Replace("**STREAMURL**", sbStreamURL.ToString()); tblShow = tblShow.Replace("**STREAMWIDTH**", iPlayerWidth.ToString()); tblShow = tblShow.Replace("**STREAMHEIGHT**", iPlayerHeight.ToString()); //tblShow = tblShow.Replace("**STOPSTREAMLINK**", "<a href=\"stopstreamprogramme?programmeid=" + tvp.Id.ToString() + "\">Stop streaming</a>"); tblShow = tblShow.Replace("**STOPSTREAMLINK**", ""); } else // NOT OK { string reasonCannotStream = "Cannot stream show - "; if (rs.ResultCode == DSStreamResultCodes.ErrorAlreadyStreaming) reasonCannotStream += "the streamer is already running; please wait a small while and then try again."; else if (rs.ResultCode == DSStreamResultCodes.ErrorAC3CodecNotFound) reasonCannotStream += "the required codecs are not installed; please download the Remote Potato streaming pack from www.fatattitude.com"; else if (rs.ResultCode == DSStreamResultCodes.ErrorFileNotFound) reasonCannotStream += "the file was not found"; else if (rs.ResultCode == DSStreamResultCodes.ErrorExceptionOccurred) reasonCannotStream += "an exception occurred: " + rs.ResultString; else reasonCannotStream += "an error occurred. " + rs.ResultString; tblShow = tblShow.Replace("**STREAMOBJECT**", reasonCannotStream); tblShow = tblShow.Replace("**STOPSTREAMLINK**", ""); } // Commit to displaying show info txtResponse += tblShow; return true; }
public TVMovie(int newId, TVProgramme tvp) : this(newId) { Showings.Add(tvp); Title = tvp.Title; }
public static bool CachedRedDotRecordingMatchesAndIsRecording(CommonEPG.TVProgramme tvp, ref bool isSeriesRecording) { return(CachedRedDotRecordingMatchesAndIsRecording(tvp.StartTime, tvp.Title, ref isSeriesRecording)); }
public static TVProgramme TVProgrammeFromScheduleEntry(ScheduleEntry se, bool omitDescription) { TVProgramme tvp = new TVProgramme(); Program p = se.Program; if (p == null) { return(null); } tvp.MCProgramID = string.Copy(p.Id.ToString("G17")); Service tvs = se.Service; if (tvs == null) { return(null); } if (!string.IsNullOrEmpty(p.Title)) { tvp.Title = string.Copy(p.Title); } if (!string.IsNullOrEmpty(p.EpisodeTitle)) { if (p.EpisodeNumber > 0) { tvp.EpisodeTitle = string.Copy(p.EpisodeNumber.ToString()) + ". " + string.Copy(p.EpisodeTitle); } else { tvp.EpisodeTitle = string.Copy(p.EpisodeTitle); } } if (!omitDescription) { if (!string.IsNullOrEmpty(p.Description)) { tvp.Description = string.Copy(p.Description); } if (p.GuideImage != null) { if (!string.IsNullOrEmpty(p.GuideImage.AbsoluteUri)) { tvp.GuideImageUri = string.Copy(p.GuideImage.AbsoluteUri); } } } else { tvp.Description = ""; // OMIT description to keep transfer to client lean tvp.GuideImageUri = ""; } //if (!string.IsNullOrEmpty(p.StarRating)) if (p.HalfStars > 0) { tvp.StarRating = p.HalfStars; } if (!string.IsNullOrEmpty(p.MpaaRatingString)) { tvp.MPAARating = string.Copy(p.MpaaRatingString); } if (!string.IsNullOrEmpty(se.TVRatingString)) { tvp.TVRating = string.Copy(se.TVRatingString); } if (p.OriginalAirdate != null) { tvp.OriginalAirDate = p.OriginalAirdate.Ticks; } // Flags tvp.HasSubtitles = se.IsSubtitled; tvp.IsFirstShowing = (!se.IsRepeat); tvp.IsHD = (se.IsHdtv); tvp.ProgramType = ProgrammeTypeForProgram(p); // Series? SeriesInfo si = p.Series; if (si != null) { tvp.IsSeries = true; tvp.SeriesID = si.Id; } else { tvp.IsSeries = false; } tvp.StartTime = se.StartTime.Ticks; tvp.StopTime = se.EndTime.Ticks; tvp.Id = string.Copy(se.Id.ToString("G17")); // CHANNEL tvp.ServiceID = string.Copy(tvs.Id.ToString("G17")); return(tvp); }
// Helper TVProgramme TVProgrammeFromWtvFile(string filename) { TVProgramme tvp = new TVProgramme(); tvp.isGeneratedFromFile = true; DvrmsMetadataEditor MetaEd = new DvrmsMetadataEditor(filename); try { tvp.Filename = filename; Dictionary<string, MetadataItem> attributes = new Dictionary<string, MetadataItem>(); if (!MetaEd.GetMetaData(ref attributes)) return null; // Title if (attributes.ContainsKey("Title")) { MetadataItem Mtitle = attributes["Title"]; tvp.Title = (string)Mtitle.Value; } else tvp.Title = "Untitled Show"; /* if (attributes.ContainsKey("WM/WMRVProgramID")) { // Use the file ID as it will persist MetadataItem Mid = attributes["WM/WMRVProgramID"]; string strID = (string)Mid.Value; // Strip any !! bit int locExcl = strID.LastIndexOf("!"); if (locExcl > 0) tvp.Id = strID.Substring(locExcl + 1); else tvp.Id = strID; } else */ // THIS WAS CAUSING SD AND HD SHOWS TO MERGE { // Make up an ID Random r = new Random(); int iRan = r.Next(100000000, 900000000); string addendum = ""; if ((tvp.Title != null) && (tvp.Title.Length > 4)) addendum += tvp.Title.Substring(0, 3); tvp.Id = iRan.ToString() + addendum; } // Episode Title if (attributes.ContainsKey("WM/SubTitle")) { MetadataItem Msubtitle = attributes["WM/SubTitle"]; if (Msubtitle.Value != null) tvp.EpisodeTitle = (string)Msubtitle.Value; } else tvp.EpisodeTitle = ""; // Description if (attributes.ContainsKey("WM/SubTitleDescription")) { MetadataItem Mdesc = attributes["WM/SubTitleDescription"]; if (Mdesc.Value != null) tvp.Description = (string)Mdesc.Value; } if (attributes.ContainsKey("WM/MediaIsSport")) { MetadataItem Msport = attributes["WM/MediaIsSport"]; if (Msport.Value != null) { bool isSport = (bool)Msport.Value; if (isSport) tvp.ProgramType = TVProgrammeType.Sport; } } if (attributes.ContainsKey("WM/MediaIsMovie")) { MetadataItem MisMovie = attributes["WM/MediaIsMovie"]; if (MisMovie.Value != null) { bool isMovie = (bool)MisMovie.Value; if (isMovie) tvp.ProgramType = TVProgrammeType.Movie; } } if (attributes.ContainsKey("WM/WMRVEncodeTime")) { MetadataItem Mdate = attributes["WM/WMRVEncodeTime"]; if (Mdate.Value != null) { try { long tickTime = (long)Mdate.Value; DateTime TheStartTime = new DateTime(tickTime, DateTimeKind.Utc); tvp.StartTime = TheStartTime.Ticks; } catch (Exception ex) { Functions.WriteLineToLogFile("Error setting start time from WTV metadata for file " + filename); Functions.WriteExceptionToLogFile(ex); } } } else { Functions.WriteLineToLogFile("No start time in WTV metadata for file " + filename + " - using current time."); tvp.StartTime = DateTime.Now.ToUniversalTime().Ticks; } if (attributes.ContainsKey("WM/WMRVEndTime")) { MetadataItem Menddate = attributes["WM/WMRVEndTime"]; if (Menddate.Value != null) { long tickTime = (long)Menddate.Value; DateTime TheEndTime = new DateTime(tickTime, DateTimeKind.Utc); tvp.StopTime = TheEndTime.Ticks; } } else { Functions.WriteLineToLogFile("No end time in WTV metadata for file " + filename + " - using current time plus 5 seconds."); tvp.StopTime = DateTime.Now.AddMinutes(5).ToUniversalTime().Ticks; } if (attributes.ContainsKey("WM/WMRVContentProtectedPercent")) { MetadataItem Mprotected = attributes["WM/WMRVContentProtectedPercent"]; if (Mprotected.Value != null) { int percentProtected = (int)Mprotected.Value; if (percentProtected > 0) tvp.IsDRMProtected = true; } } if (attributes.ContainsKey("WM/MediaStationCallSign")) { MetadataItem Mchannel = attributes["WM/MediaStationCallSign"]; if (Mchannel.Value != null) { tvp.WTVCallsign = (string)Mchannel.Value; } } // Only populate if we don't already have a callsign if (string.IsNullOrEmpty(tvp.WTVCallsign)) { if (attributes.ContainsKey("WM/MediaStationName")) // Added by request: also use station name { MetadataItem Mchanname = attributes["WM/MediaStationName"]; if (Mchanname.Value != null) tvp.WTVCallsign = (string)Mchanname.Value; } else { tvp.WTVCallsign = "Unknown channel."; } } if (attributes.ContainsKey("WM/WMRVSeriesUID")) { MetadataItem MSeriesUID = attributes["WM/WMRVSeriesUID"]; if (MSeriesUID.Value != null) tvp.IsSeries = !String.IsNullOrEmpty((string)MSeriesUID.Value); } if (attributes.ContainsKey("WM/WMRVHDContent")) { MetadataItem MisHD = attributes["WM/WMRVHDContent"]; if (MisHD.Value != null) tvp.IsHD = (bool)MisHD.Value; } if (attributes.ContainsKey("WM/MediaIsSubtitled")) { MetadataItem MisSubT = attributes["WM/MediaIsSubtitled"]; if (MisSubT.Value != null) tvp.HasSubtitles = (bool)MisSubT.Value; } // Original date if (attributes.ContainsKey("WM/MediaOriginalBroadcastDateTime")) { MetadataItem Morigdate = attributes["WM/MediaOriginalBroadcastDateTime"]; if (Morigdate.Value != null) { string strOrigDate = (string)Morigdate.Value; if (!string.IsNullOrWhiteSpace(strOrigDate)) { DateTime dtOrigDate; if (DateTime.TryParse(strOrigDate, out dtOrigDate)) { tvp.OriginalAirDate = dtOrigDate.ToUniversalTime().Ticks; } else { if (Settings.Default.DebugAdvanced) Functions.WriteLineToLogFile("Couldn't parse WTV original broadcast date for " + filename + ": [" + strOrigDate + "]"); } } } } if (attributes.ContainsKey("WM/MediaIsRepeat")) { MetadataItem MisRepeat = attributes["WM/MediaIsRepeat"]; if (MisRepeat.Value != null) { bool isRepeat = (bool)MisRepeat.Value; tvp.IsFirstShowing = !isRepeat; } } } catch (Exception ex) { if (Settings.Default.DebugAdvanced) { Functions.WriteLineToLogFile("Couldn't get WTV metadata for " + filename + ":"); Functions.WriteExceptionToLogFile(ex); } return null; } finally { MetaEd.ReleaseResources(); MetaEd = null; } return tvp; }
public static TVProgramme TVProgrammeFromScheduleEntry(ScheduleEntry se, bool omitDescription) { TVProgramme tvp = new TVProgramme(); Program p = se.Program; if (p == null) return null; tvp.MCProgramID = string.Copy( p.Id.ToString("G17") ); Service tvs = se.Service; if (tvs == null) return null; if (! string.IsNullOrEmpty(p.Title)) tvp.Title = string.Copy( p.Title ); if (!string.IsNullOrEmpty(p.EpisodeTitle)) { if (p.EpisodeNumber > 0) tvp.EpisodeTitle = string.Copy( p.EpisodeNumber.ToString() ) + ". " + string.Copy( p.EpisodeTitle ); else tvp.EpisodeTitle = string.Copy( p.EpisodeTitle ); } if (!omitDescription) { if (!string.IsNullOrEmpty(p.Description)) tvp.Description = string.Copy( p.Description ); if (p.GuideImage != null) if (!string.IsNullOrEmpty(p.GuideImage.AbsoluteUri)) tvp.GuideImageUri = string.Copy(p.GuideImage.AbsoluteUri); } else { tvp.Description = ""; // OMIT description to keep transfer to client lean tvp.GuideImageUri = ""; } //if (!string.IsNullOrEmpty(p.StarRating)) if (p.HalfStars > 0) tvp.StarRating = p.HalfStars; if (!string.IsNullOrEmpty(p.MpaaRatingString)) tvp.MPAARating = string.Copy( p.MpaaRatingString ); if (!string.IsNullOrEmpty(se.TVRatingString)) tvp.TVRating = string.Copy ( se.TVRatingString ); if (p.OriginalAirdate != null) tvp.OriginalAirDate = p.OriginalAirdate.Ticks; // Flags tvp.HasSubtitles = se.IsSubtitled; tvp.IsFirstShowing = (!se.IsRepeat); tvp.IsHD = (se.IsHdtv); tvp.ProgramType = ProgrammeTypeForProgram(p); // Series? SeriesInfo si = p.Series; if (si != null) { tvp.IsSeries = true; tvp.SeriesID = si.Id; } else tvp.IsSeries = false; tvp.StartTime = se.StartTime.Ticks; tvp.StopTime = se.EndTime.Ticks; tvp.Id = string.Copy ( se.Id.ToString("G17") ); // CHANNEL tvp.ServiceID = string.Copy ( tvs.Id.ToString("G17") ); return tvp; }
public static string imgTagRecordedTVProgramme(TVProgramme tvp) { return "<img src=\"/rectvthumbnail?filename=" + HttpUtility.UrlEncode(tvp.Filename) + "\" class=\"showthumbnail\"/>"; }