// Extension methods to link records: public static TVService TVService(this TVProgramme tvp) // TVProgramme => TVService { string svcID = null; // If it's a fake, generated TV Programme... if (tvp.isGeneratedFromFile) { // Attempt to match the callsign to one of our channels svcID = ServiceIDFromCallsign(tvp.WTVCallsign); // If there's no match, generate a dummy TV service with the correct callsign if (string.IsNullOrEmpty(svcID)) { TVService tvs = new TVService(); tvs.Callsign = tvp.WTVCallsign; tvs.UniqueId = "0"; return(tvs); } } else { svcID = tvp.ServiceID; // Normal service retrieval } if (string.IsNullOrEmpty(svcID)) { return(null); } try { return(AllTVChannels[tvp.ServiceID]); } catch { } return(null); }
public async Task SearchAsync_WhenRequestAmountIsEqualToTotal_ReturnsSearchPage() { var mockTVRepository = new Mock <ITVRepository>(); mockTVRepository.Setup(m => m.SearchAsync(It.IsAny <string>(), 1)) .ReturnsAsync(new SearchPage <TVShow>() { Page = 1, PageTotal = 2, Results = new List <TVShow>() { new TVShow() } }); mockTVRepository.Setup(m => m.SearchAsync(It.IsAny <string>(), 2)) .ReturnsAsync(new SearchPage <TVShow>() { Page = 2, PageTotal = 2, Results = new List <TVShow>() { new TVShow() } }); var TVService = new TVService(mockTVRepository.Object); var results = await TVService.SearchAsync("title", 2); Assert.Equal(2, results.Count()); }
public static void CacheMoviesNow(List <TVProgramme> progList, bool restrictToFavouriteChannels) { CachedMovies.Clear(); foreach (TVProgramme tvp in progList) { if ( (tvp.ProgramType == TVProgrammeType.Movie) ) { if (restrictToFavouriteChannels) { TVService tvs = tvp.TVService(); if (tvs != null) { if (!FavoriteTVChannels.Contains(tvs)) { continue; } } } AddOrMergeToMovieCache(tvp); } } if (CachedMovies.Count > 0) // Don't refresh cache time if there's nothing in it { MovieCacheLastUpdated = DateTime.Now; } }
protected async Task HandlePageChanged(int selectedPage) { Page = selectedPage; var data = await TVService.GetPopularTVAsync(Page); SetTVData(data); }
public ChannelDetailViewModel(ILoggingService loggingService, IOnlineTelevizorConfiguration config, IDialogService dialogService, TVService service) : base(loggingService, config, dialogService) { _loggingService = loggingService; _dialogService = dialogService; _service = service; Config = config; }
protected override async Task OnInitializedAsync() { if (int.TryParse(Id, out int tvShowId) && int.TryParse(Number, out int seasonNumber)) { SeasonDetails = await TVService.GetTVSeasonDetailsAsync(tvShowId, seasonNumber); TVShowDetails = await TVService.GetTVDetailsAsync(tvShowId); } }
public StreamQualityViewModel(ILoggingService loggingService, IOnlineTelevizorConfiguration config, IDialogService dialogService, TVService service) : base(loggingService, config, dialogService) { _service = service; _loggingService = loggingService; _dialogService = dialogService; Config = config; RefreshCommand = new Command(async() => await Refresh()); }
protected override async Task OnInitializedAsync() { if (int.TryParse(Id, out int tvShowId)) { TVShow = await TVService.GetTVDetailsAsync(tvShowId); Cast = await TVService.GetTVCastAsync(tvShowId); } await SetTVShowInLocalStorage(); }
public FilterPageViewModel(ILoggingService loggingService, IOnlineTelevizorConfiguration config, IDialogService dialogService, TVService service) : base(loggingService, config, dialogService) { _service = service; _loggingService = loggingService; _dialogService = dialogService; Config = config; ClearFilterCommand = new Command(async() => await ClearFilter()); RefreshCommand = new Command(async() => await Refresh()); }
public PlayerPageViewModel(ILoggingService loggingService, IOnlineTelevizorConfiguration config, IDialogService dialogService, TVService service) : base(loggingService, config, dialogService) { _service = service; _loggingService = loggingService; _dialogService = dialogService; Config = config; RefreshCommand = new Command(async() => await Refresh()); BackgroundCommandWorker.RunInBackground(RefreshCommand, 30, 15); }
protected override async Task OnInitializedAsync() { var movieResults = await MovieService.GetUpcomingMoviesAsync(); var tvResults = await TVService.GetPopularTVAsync(); if (movieResults is not null && tvResults is not null) { UpcomingMovies = movieResults.Results; PopularTVShows = tvResults.Results; } }
public void GetAsync_WithTitle_ReturnsTVShow() { var mockTvRepository = new Mock <ITVRepository>(); mockTvRepository.Setup(m => m.GetAsync(It.IsAny <string>())) .ReturnsAsync(new TVShow()); var TVService = new TVService(mockTvRepository.Object); var result = TVService.GetAsync("title"); Assert.NotNull(result); }
public static bool MakeChannelNotFavorite(string serviceID) { TVService tvs = TVServiceWithIDOrNull(serviceID); if (tvs == null) { return(false); } tvs.IsFavorite = false; SaveChannelsToLocal(); return(true); }
public SettingsViewModel(ILoggingService loggingService, IOnlineTelevizorConfiguration config, IDialogService dialogService, TVService service) : base(loggingService, config, dialogService) { _service = service; _loggingService = loggingService; _dialogService = dialogService; Config = config; IsPurchased = Config.Purchased; PayCommand = new Command(async() => await Pay()); StopStreamCommand = new Command(async() => await StopStream()); AboutCommand = new Command(async() => await About()); }
protected override async Task OnInitializedAsync() { var popularTvShows = await TVService.GetPopularTVAsync(); var topRatedTvShows = await TVService.GetTopRatedTVAsync(); var onTheAirTvShows = await TVService.GetOnTheAirTVAsync(); if (popularTvShows is not null && topRatedTvShows is not null && onTheAirTvShows is not null) { PopularTVShows = popularTvShows.Results; TopRatedTVShows = topRatedTvShows.Results; OnTheAirTVShows = onTheAirTvShows.Results; } }
public static string CallsignFromServiceID(string svcID) { TVService tvs = TVServiceWithIDOrNull(svcID); if (tvs == null) { return("Unknown"); } if (!string.IsNullOrEmpty(tvs.Callsign)) { return(tvs.Callsign); } else { return("None"); } }
public static string ServiceIDFromCallsign(string callsign) { TVService tvs = TVServiceWithCallsignOrNull(callsign); if (tvs == null) { return(""); } if (!string.IsNullOrEmpty(tvs.UniqueId)) { return(tvs.UniqueId); } else { return(""); } }
public static bool LogoForServiceExists(string svcID, out string logoFN) { logoFN = ""; TVService tvs = TVServiceWithIDOrNull(svcID); if (tvs == null) { return(false); } if (string.IsNullOrEmpty(tvs.LogoUri)) { return(false); } logoFN = FileFNFromUri(tvs.LogoUri); return(true); }
public void LoadData() { MovieService movieService = new MovieService(); TVService tVService = new TVService(); MovieListResult movieListResult = movieService.GetPopularMovies(1); TVShowListResult tVShowListResult = tVService.GetOnTheAirTVShows(1); List <Movie> movieList = movieListResult.results; List <TVShow> tVShowList = tVShowListResult.results; movies[0] = movieList.ElementAt <Movie>(0); movies[1] = movieList.ElementAt <Movie>(1); movies[2] = movieList.ElementAt <Movie>(2); tVShows[0] = tVShowList.ElementAt <TVShow>(0); tVShows[1] = tVShowList.ElementAt <TVShow>(1); tVShows[2] = tVShowList.ElementAt <TVShow>(2); test = "This is not for testing"; }
public Task Start() { return(Task.Run(async() => { while (true) { var command = $"cat {pipeFile}"; var result = BashHelper.ExecBashCommand(command); if (string.IsNullOrWhiteSpace(result.Error)) { var tvService = new TVService(); var tvCommand = (IRCommands)Enum.Parse(typeof(IRCommands), result.Message, true); await tvService.SendCommand(tvCommand); } } })); }
public static bool GetLogoDataForCallsign(string svcID, int width, int height, out byte[] logoData) { logoData = new byte[] { }; TVService tvs = TVServiceWithIDOrNull(svcID); if (tvs == null) { return(false); } if (tvs.LogoUri == null) { return(false); } string fileFN = FileFNFromUri(tvs.LogoUri); byte[] inLogoData = FileCache.ReadBinaryFile(fileFN); System.Drawing.Size sz = new System.Drawing.Size(width, height); return(ImageResizer.ResizePicture(inLogoData, sz, out logoData, true)); }
public static string HTMLForLogoImageOrCallsign(this TVService tvs, string cssClass, bool showTextIfNoLogo) { if (tvs == null) { return(""); } if (String.IsNullOrEmpty(tvs.Callsign)) { return(""); } string altText = showTextIfNoLogo ? tvs.Callsign : ""; if (!Settings.Default.ShowChannelLogos) { return(tvs.Callsign); } if (!String.IsNullOrEmpty(tvs.LogoUri)) { // There's a logo, return it string strHTML = "<img alt=\"" + altText + "\" title=\"" + altText + "\" src=\"/logo/" + HttpUtility.UrlEncode(tvs.UniqueId) + "\" "; if (!(string.IsNullOrEmpty(cssClass))) { strHTML += "class = \"" + cssClass + "\""; } strHTML += "/>"; return(strHTML); } else { // No logo - just text if allowed return(altText);; } }
public FilterPage(ILoggingService loggingService, IOnlineTelevizorConfiguration config, TVService service) { InitializeComponent(); var dialogService = new DialogService(this); GroupPicker.Unfocused += GroupPicker_Unfocused; TypePicker.Unfocused += TypePicker_Unfocused; BindingContext = _viewModel = new FilterPageViewModel(loggingService, config, dialogService, service); }
public SettingsPage(ILoggingService loggingService, IOnlineTelevizorConfiguration config, IDialogService dialogService, TVService service) { InitializeComponent(); _config = config; _loggingService = loggingService; _dialogService = dialogService; BindingContext = _viewModel = new SettingsViewModel(loggingService, config, dialogService, service); PlayOnBackgroundSwitch.Toggled += PlayOnBackgroundSwitch_Toggled; UseInternalPlayerSwitch.Toggled += PlayOnBackgroundSwitch_Toggled; if (Device.RuntimePlatform == Device.UWP) { UsernameEntry.TextColor = Color.Black; UsernameEntry.BackgroundColor = Color.Gray; PasswordEntry.TextColor = Color.Black; PasswordEntry.BackgroundColor = Color.Gray; PinEntry.TextColor = Color.Black; PinEntry.BackgroundColor = Color.Gray; FontSizeLabel.IsVisible = false; FontSizePicker.IsVisible = false; } MessagingCenter.Subscribe <string>(this, BaseViewModel.RequestBatterySettings, async(sender) => { if (await _dialogService.Confirm("Při běhu na pozadí je nutné zajistit, aby se aplikace kvůli optimalizaci baterie neukončovala. Přejít do nastavení?")) { MessagingCenter.Send <SettingsPage>(this, BaseViewModel.SetBatterySettings); } }); TVAPIPicker.Unfocused += TVAPIPicker_Unfocused; LastChannelAutoPlayPicker.Unfocused += LastChannelAutoPlayPicker_Unfocused; FontSizePicker.Unfocused += FontSizePicker_Unfocused; PasswordEntry.Unfocused += PasswordEntry_Unfocused; }
public HelpViewModel(ILoggingService loggingService, IOnlineTelevizorConfiguration config, IDialogService dialogService, TVService service) : base(loggingService, config, dialogService) { }
public HelpPage(ILoggingService loggingService, IOnlineTelevizorConfiguration config, IDialogService dialogService, TVService service) { InitializeComponent(); _config = config; _loggingService = loggingService; _dialogService = dialogService; BindingContext = _viewModel = new HelpViewModel(loggingService, config, dialogService, service); }
// Refresh public static bool UpdateTVChannels() { bool debug = ((Settings.Default.DebugChannels) & (Settings.Default.DebugAdvanced)); Functions.WriteLineToLogFileIfSetting(debug, "EPG: UpdateTVChannels() Running:"); // If we don't have any existing channels at all then get some if ((AllTVChannels == null) || (AllTVChannels.Count < 1)) { Functions.WriteLineToLogFileIfSetting(debug, "EPG: UpdateTVChannels(): No existing TV Channels, populating from cache first..."); if (!PopulateTVChannels(false)) { return(false); } Functions.WriteLineToLogFileIfSetting(debug, "EPG: UpdateTVChannels(): Populated from cache: there are " + AllTVChannels.Count.ToString() + " channels."); if (AllTVChannels.Count < 1) { return(false); } } Functions.WriteLineToLogFileIfSetting(debug, "EPG: UpdateTVChannels(): Backing up " + AllTVChannels.Count.ToString() + " channels."); Dictionary <string, TVService> OldTVChannelsKeyedByChannelNumberString = new Dictionary <string, TVService>(); foreach (TVService tvs in AllTVChannels.Values) { TVService copiedOldService = tvs.DeepCopy(); // Skip duplicate keys otherwise you spend 4 hours on a Sunday trying to remotely debug a native code crash if (OldTVChannelsKeyedByChannelNumberString.ContainsKey(copiedOldService.ChannelNumberString())) { Functions.WriteLineToLogFileIfSetting(debug, "EPG: UpdateTVChannels() Skipping service with duplicate channel num string (" + copiedOldService.ChannelNumberString() + ") Callsign is " + copiedOldService.Callsign); } else { Functions.WriteLineToLogFileIfSetting(debug, "EPG: UpdateTVChannels() Storing " + copiedOldService.ChannelNumberString() + " : " + copiedOldService.Callsign); OldTVChannelsKeyedByChannelNumberString.Add(copiedOldService.ChannelNumberString(), copiedOldService); } } // Re-populate AllTVChannels from MediaCenter Functions.WriteLineToLogFileIfSetting(debug, "EPG: UpdateTVChannels(): Getting newest channels from 7MC..."); PopulateTVChannels(true); Functions.WriteLineToLogFileIfSetting(debug, "EPG: UpdateTVChannels(): Populated from 7MC: there are " + AllTVChannels.Count.ToString() + " channels."); // Go through new channels - retrieve isFavourite information and user sort order from old channels Functions.WriteLineToLogFileIfSetting(debug, "EPG: UpdateTVChannels(): Merging info from old channels into newer list."); List <string> MatchedChannelNumberStrings = new List <string>(); foreach (TVService newService in AllTVChannels.Values) { if (OldTVChannelsKeyedByChannelNumberString.ContainsKey(newService.ChannelNumberString())) { if (!MatchedChannelNumberStrings.Contains(newService.ChannelNumberString())) { TVService oldService = OldTVChannelsKeyedByChannelNumberString[newService.ChannelNumberString()]; // Merge in old user sort and isfavorite information newService.IsFavorite = oldService.IsFavorite; newService.UserSortOrder = oldService.UserSortOrder; if (newService.MCChannelID != oldService.MCChannelID) { Functions.WriteLineToLogFile("EPG: UpdateTVChannels(): INFORMATION: Service " + newService.Callsign + " changed MC-ID from " + oldService.MCChannelID.ToString() + " to " + newService.MCChannelID.ToString() + " - merging in change."); } if (newService.UniqueId != oldService.UniqueId) { Functions.WriteLineToLogFile("EPG: UpdateTVChannels(): INFORMATION: Service " + newService.Callsign + " changed Unique Service ID from " + oldService.UniqueId + " to " + newService.UniqueId + " - merging in change."); } MatchedChannelNumberStrings.Add(newService.ChannelNumberString()); } } else { Functions.WriteLineToLogFileIfSetting(debug, "EPG: UpdateTVChannels(): NEW channel " + newService.Callsign + " was found. (Chan number " + newService.ChannelNumberString() + ")"); } } Functions.WriteLineToLogFileIfSetting(debug, "EPG: UpdateTVChannels(): Merge complete."); // Save it Functions.WriteLineToLogFileIfSetting(debug, "EPG: UpdateTVChannels(): Saving."); SaveChannelsToLocal(); Functions.WriteLineToLogFileIfSetting(debug, "EPG: UpdateTVChannels(): DONE."); return(true); }
public QualitiesPage(ILoggingService loggingService, IOnlineTelevizorConfiguration config, TVService service) { InitializeComponent(); _config = config; var dialogService = new DialogService(this); BindingContext = _viewModel = new StreamQualityViewModel(loggingService, config, dialogService, service); }
protected override async Task OnInitializedAsync() { var data = await TVService.GetPopularTVAsync(Page); SetTVData(data); }
// 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); }