public static string MatchedChannelCallsign(this CommonEPG.TVProgramme tvp) { CommonEPG.TVService tvc = EPGManager.TVServiceWithIDOrNull(tvp.ServiceID); if (tvc == null) { return("Unknown"); } return(tvc.Callsign); }
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)); }
public static string TVProgrammesMatchingSearch(EPGSearch theSearch) { List <TVProgramme> matchedProgs = null; bool wereTruncated = false; //if (theSearch.LimitToDateRange) TODO // matchedProgs = EPGManager.mcData.SearchTVProgrammesByDateRange(theSearch.DateRange, theSearch.TextToSearch, theSearch.TextType, theSearch.MatchType, out wereTruncated); //else matchedProgs = EPGManager.SearchTVProgrammes(theSearch.TextToSearch, theSearch.TextType, theSearch.MatchType, out wereTruncated); return(XMLHelper.Serialize <List <TVProgramme> >(matchedProgs)); }
public bool SendLogoToBrowser(string logoSvcID) { if (String.IsNullOrEmpty(logoSvcID)) { return(false); } logoSvcID = logoSvcID.Trim(); byte[] bytes = new byte[] { }; if (!EPGManager.GetLogoDataForCallsign(logoSvcID, 50, 50, out bytes)) { return(Send404Page()); } return(SendDataToBrowser("image/png", bytes)); }
public static void setStreamID(long RPRecId, long streamID) { // FOR NOW.. ..refresh each time, although strictly may not be necessary if (Settings.Default.RecordingsRetrieveAsParanoid) { EPGManager.ReloadAllRecordings(); } List <RPRecording> allRecordings = EPGManager.AllRecordings.Values.ToList(); foreach (var rpr in allRecordings) { if (rpr.Id == RPRecId) { rpr.StreamId = streamID; } } }
public static bool GetScheduleEventAtExactTimeOnChannel(DateTime exactTime, string callsign, bool matchTitleStart, string txtTitleStartsWith, ref ScheduleEvent matchingEvent, ref ScheduleRequest matchingRequest) { // We have a channel to search for, what's the service ID string svcID = EPGManager.ServiceIDFromCallsign(callsign); // So now bother to get the events List <ScheduleEvent> theList = GetScheduleEventsAroundExactTime(exactTime, 3); foreach (ScheduleEvent se in theList) { if (matchTitleStart) { string seTitle = (string)se.GetExtendedProperty("Title"); if (!seTitle.ToLowerInvariant().StartsWith(txtTitleStartsWith.ToLowerInvariant())) { continue; // ie Do not match } } if ((string)se.GetExtendedProperty("ServiceID") == svcID) { matchingEvent = se; // Match schedule request, if there is one try { matchingRequest = se.GetScheduleRequest(); } catch { matchingRequest = null; } return(true); } } return(false); // no match }
// Schedule Recordings /// <summary> /// Schedule a recording - this examines the request and populates Service ID, etc. /// The MCDATA.Schedule... method should never be called directly outside this method /// </summary> public static RecordingResult ScheduleRecording(RecordingRequest rr) { // Populate defaults, e.g. quality, if not set PopulateDefaultsIfUnset(ref rr); RecordingResult failedResult = new RecordingResult(); failedResult.Completed = false; if (rr.RequestType != RecordingRequestType.Manual) // manual recordings already have a service ID specified { if (rr.TVProgrammeID < 1) { failedResult.ErrorMessage = "No TV Programme ID was specified."; return(failedResult); } // Populate the Service ID if not already populated TVProgramme tvp = mcData.GetTVProgramme(rr.TVProgrammeID.ToString()); if (tvp == null) { failedResult.ErrorMessage = "No TV Programme with the specified ID could be found."; return(failedResult); } rr.ServiceID = long.Parse(tvp.ServiceID); // could fail } // Get the channel ID from the service ID TVService tvs = TVServiceWithIDOrNull(rr.ServiceID.ToString()); if (tvs == null) { failedResult.ErrorMessage = "No TV Channel with the retrieved ID could be found."; return(failedResult); } rr.MCChannelID = tvs.MCChannelID; // ************** SCHEDULE THE RECORDING ************************ RPRequest generatedRequest; RecordingResult earlyRecResult; if (!mcData.ScheduleRecording(rr, out generatedRequest, out earlyRecResult)) { bool debug2 = (Settings.Default.DebugAdvanced); Functions.WriteLineToLogFileIfSetting(debug2, "Failed already - return the early result"); return(earlyRecResult); } RecordingResult recResult = mcData.DetermineRecordingResultForRequest(generatedRequest); bool debug = (Settings.Default.DebugAdvanced); Functions.WriteLineToLogFileIfSetting(debug, "recResult.Success=" + recResult.Success); // Success? if (recResult.Success) { // Wait a moment so Scheduler can catch up and associate our request with our recordings... System.Threading.Thread.Sleep(600); Functions.WriteLineToLogFileIfSetting(debug, "// Now refresh and get the generated recordings..."); EPGManager.ReloadAllRecordings(); try { RPRequest req = recResult.GeneratedRecordingsBlob.RPRequests[0]; Functions.WriteLineToLogFileIfSetting(debug, "req.Title=" + req.Title); // Add recordings recResult.GeneratedRecordingsBlob.RPRecordings = req.Recordings(); Functions.WriteLineToLogFileIfSetting(debug, "recordings added"); // Add programs linked to these recordings foreach (RPRecording rec in recResult.GeneratedRecordingsBlob.RPRecordings) { TVProgramme tvp = rec.TVProgramme(); if (tvp != null) { recResult.GeneratedRecordingsBlob.TVProgrammes.Add(tvp); Functions.WriteLineToLogFileIfSetting(debug, tvp.Filename + " added"); } } } catch (Exception ex) { Functions.WriteLineToLogFile("ScheduleRecording(): Error retrieving recordings:"); Functions.WriteExceptionToLogFile(ex); recResult.Success = false; recResult.ErrorMessage = "Exception occured while retrieving recordings - the recording may have been scheduled."; } } return(recResult); }
internal bool Initialize(bool initErrorHandler, bool initRecTV, bool initEPG) { Monitor.Enter(initLock); if (IsInitialized) { Functions.WriteLineToLogFile("Init: Server already initialized, bailing out of init."); Monitor.Exit(initLock); return(true); } Functions.WriteLineToLogFile("Init: Initialise() Beginning"); // LEgacy app running? if (Functions.isLegacyAppRunning()) { Functions.WriteLineToLogFile("Init: Error - conflict - RemotePotato.exe (legacy app) is running."); Monitor.Exit(initLock); return(false); } // Hook up events if (initErrorHandler) { Functions.WriteLineToLogFile("Init: Initializing Error Handler..."); ErrorHandler.Default.Initialize(); } // RecTV if (initRecTV) { Functions.WriteLineToLogFile("Init: Initializing RecTV..."); RecTV.Default.Initialize(); } // Force Setting//LEGACYREMOVE ? (leave for a few months) if ((initEPG) && Settings.Default.EnableMediaCenterSupport) { Functions.WriteLineToLogFile("Init: Initia1izing EPG..."); Settings.Default.EnableEPG = true; if (EPGManager.Initialise()) { Functions.WriteLineToLogFile("Init: Initialized EPG - loading EPG Data"); //EPGManager.PopulateTVChannels(false); EPGManager.UpdateTVChannels(); // load TV channels from disk cache then update by combining with channels from media center : Includes a call to EPGManager.PopulateTVChannels(false) EPGManager.ReloadAllRecordings(); Functions.WriteLineToLogFile("Init: Loaded EPG Data"); } else { Functions.WriteLineToLogFile("ERROR - could not initialise the EPG Manager ."); IsInitialized = false; Monitor.Exit(initLock); return(false); } } // DNS CLIENT if (Settings.Default.DynDNSClientEnabled) { Functions.WriteLineToLogFile("Init: Initializing Dynamic DNS Client..."); DNSHelper.Default.Start(); Functions.WriteLineToLogFile("Init: Initialized Dynamic DNS Client..."); } IsInitialized = true; Functions.WriteLineToLogFile("Init: Initialise() Ending"); Monitor.Exit(initLock); return(true); }