public static void Build(epgConfig configuration) { var errString = string.Empty; // initialize schedules direct API SdApi.Initialize("EPG123"); SdMxf.InitializeMxf(); // copy configuration to local variable config = configuration; // initialize event buffer Logger.WriteInformation($"Beginning EPG123 update execution. {DateTime.Now.ToUniversalTime():u}"); Logger.WriteVerbose($"DaysToDownload: {config.DaysToDownload} , TheTVDBNumbers : {config.TheTvdbNumbers} , PrefixEpisodeTitle: {config.PrefixEpisodeTitle} , PrefixEpisodeDescription : {config.PrefixEpisodeDescription} , AppendEpisodeDesc: {config.AppendEpisodeDesc} , OADOverride : {config.OadOverride} , SeasonEventImages : {config.SeasonEventImages} , TMDbCoverArt: {config.TMDbCoverArt} , IncludeSDLogos : {config.IncludeSdLogos} , AutoAddNew: {config.AutoAddNew} , CreateXmltv: {config.CreateXmltv} , ModernMediaUiPlusSupport: {config.ModernMediaUiPlusSupport}"); // populate station prefixes to suppress suppressedPrefixes = new List <string>(config.SuppressStationEmptyWarnings.Split(',')); // login to Schedules Direct and build the mxf file if (SdApi.GetToken(config.UserAccount.LoginName, config.UserAccount.PasswordHash, ref errString)) { // check server status var susr = SdApi.GetUserStatus(); if (susr == null) { return; } else if (susr.SystemStatus[0].Status.ToLower().Equals("offline")) { Logger.WriteError("Schedules Direct server is offline. Aborting update."); return; } // check for latest version and update the display name that shows in About Guide var scvr = SdApi.GetClientVersion(); if (scvr != null && scvr.Version != Helper.Epg123Version) { SdMxf.Providers[0].DisplayName += $" (v{scvr.Version} Available)"; BrandLogo.UpdateAvailable = true; } // make sure cache directory exists if (!Directory.Exists(Helper.Epg123CacheFolder)) { Directory.CreateDirectory(Helper.Epg123CacheFolder); } epgCache.LoadCache(); // initialize tmdb api if (config.TMDbCoverArt) { tmdbApi.Initialize(false); } // prepopulate keyword groups InitializeKeywordGroups(); // read all included and excluded station from configuration PopulateIncludedExcludedStations(config.StationId); // if all components of the mxf file have been successfully created, save the file if (BuildLineupServices() && ServiceCountSafetyCheck() && GetAllScheduleEntryMd5S(config.DaysToDownload) && BuildAllProgramEntries() && BuildAllGenericSeriesInfoDescriptions() && BuildAllExtendedSeriesDataForUiPlus() && GetAllMoviePosters() && GetAllSeriesImages() && GetAllSeasonImages() && GetAllSportsImages() && BuildKeywords() && WriteMxf()) { Success = true; // create the xmltv file if desired if (config.CreateXmltv && CreateXmltvFile()) { WriteXmltv(); ++processedObjects; ReportProgress(); } // remove the guide images xml file Helper.DeleteFile(Helper.Epg123GuideImagesXmlPath); // create the ModernMedia UI+ json file if desired if (config.ModernMediaUiPlusSupport) { ModernMediaUiPlus.WriteModernMediaUiPlusJson(config.ModernMediaUiPlusJsonFilepath ?? null); ++processedObjects; ReportProgress(); } // clean the cache folder of stale data CleanCacheFolder(); epgCache.WriteCache(); Logger.WriteVerbose($"Downloaded and processed {SdApi.TotalDownloadBytes} of data from Schedules Direct."); Logger.WriteVerbose($"Generated .mxf file contains {SdMxf.With.Services.Count - 1} services, {SdMxf.With.SeriesInfos.Count} series, {SdMxf.With.Seasons.Count} seasons, {SdMxf.With.Programs.Count} programs, {SdMxf.With.ScheduleEntries.Sum(x => x.ScheduleEntry.Count)} schedule entries, and {SdMxf.With.People.Count} people with {SdMxf.With.GuideImages.Count} image links."); Logger.WriteInformation("Completed EPG123 update execution. SUCCESS."); } } else { Logger.WriteError($"Failed to retrieve token from Schedules Direct. message: {errString}"); } SdMxf = null; GC.Collect(); Helper.SendPipeMessage("Download Complete"); }