Beispiel #1
0
        private void btnCreateDefault_Click(object sender, EventArgs e)
        {
            Cursor = Cursors.WaitCursor;
            var mxf = new Mxf();

            foreach (MergedChannel mergedChannel in WmcStore.WmcMergedLineup.UncachedChannels)
            {
                if (mergedChannel.UserBlockedState > UserBlockedState.Enabled && cbEnabled.Checked)
                {
                    continue;
                }

                var svcType = GetMergedChannelServiceType(mergedChannel);
                if (svcType == 2 && !cbRadio.Checked)
                {
                    continue;
                }
                if (svcType == 3 && !cbData.Checked)
                {
                    continue;
                }
                mxf.AddChannel(mergedChannel, cbEncrypted.Checked);
            }

            // create the temporary mxf file
            using (var stream = new StreamWriter(Helper.DefaultSatellitesPath, false, Encoding.UTF8))
                using (var writer = XmlWriter.Create(stream, new XmlWriterSettings {
                    Indent = true
                }))
                {
                    var serializer = new XmlSerializer(typeof(Mxf));
                    var ns         = new XmlSerializerNamespaces();
                    ns.Add("", "");
                    serializer.Serialize(writer, mxf, ns);
                }
            Cursor = Cursors.Arrow;
        }
Beispiel #2
0
        public static bool UpdateDvbsTransponders(bool ignoreDefault)
        {
            var ret     = false;
            var mxfPath = Helper.TransponderMxfPath;

            try
            {
                // if defaultsatellites.mxf exists, import it and return
                if (!ignoreDefault && File.Exists(Helper.DefaultSatellitesPath))
                {
                    mxfPath = Helper.DefaultSatellitesPath;
                    goto ImportAndLock;
                }

                // read the satellites.xml file from either the file system or the resource file
                var satXml = new Satellites();
                if (File.Exists(Helper.SatellitesXmlPath))
                {
                    using (var stream = new StreamReader(Helper.SatellitesXmlPath, Encoding.UTF8))
                    {
                        var        serializer = new XmlSerializer(typeof(Satellites));
                        TextReader reader     = new StringReader(stream.ReadToEnd());
                        satXml = (Satellites)serializer.Deserialize(reader);
                        reader.Close();
                    }
                }
                else
                {
                    using (var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("epg123Client.satellites.xml"))
                        using (var reader = new StreamReader(stream, Encoding.UTF8))
                        {
                            var        serializer = new XmlSerializer(typeof(Satellites));
                            TextReader tr         = new StringReader(reader.ReadToEnd());
                            satXml = (Satellites)serializer.Deserialize(tr);
                            tr.Close();
                        }
                }

                // populate the mxf class
                var mxf    = new Mxf();
                var unique = satXml.Satellite.GroupBy(arg => arg.Name).Select(arg => arg.FirstOrDefault());
                foreach (var sat in unique)
                {
                    var freqs  = new HashSet <string>();
                    var mxfSat = new MxfDvbsSatellite {
                        Name = sat.Name, PositionEast = sat.Position, _transponders = new List <MxfDvbsTransponder>()
                    };
                    var matches = satXml.Satellite.Where(arg => arg.Name == sat.Name);
                    foreach (var match in matches)
                    {
                        foreach (var txp in match.Transponder.Where(txp => freqs.Add($"{txp.Frequency}_{txp.Polarization}")))
                        {
                            mxfSat._transponders.Add(new MxfDvbsTransponder
                            {
                                _satellite       = mxfSat,
                                CarrierFrequency = txp.Frequency,
                                Polarization     = txp.Polarization,
                                SymbolRate       = txp.SymbolRate
                            });
                        }
                    }
                    mxf.DvbsDataSet._allSatellites.Add(mxfSat);
                }

                // create the temporary mxf file
                using (var stream = new StreamWriter(Helper.TransponderMxfPath, false, Encoding.UTF8))
                    using (var writer = XmlWriter.Create(stream, new XmlWriterSettings {
                        Indent = true
                    }))
                    {
                        var serializer = new XmlSerializer(typeof(Mxf));
                        var ns         = new XmlSerializerNamespaces();
                        ns.Add("", "");
                        serializer.Serialize(writer, mxf, ns);
                    }

                // import the mxf file with new satellite transponders
ImportAndLock:
                ret = ImportMxfFile(mxfPath);
                var uid = WmcStore.WmcObjectStore.UIds["!DvbsDataSet"];
                uid.Lock();
                uid.Update();
            }
            catch (Exception ex)
            {
                Logger.WriteError($"Exception thrown during UpdateDvbsTransponders(). {ex.Message}\n{ex.StackTrace}");
            }
            return(ret);
        }
Beispiel #3
0
        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");
        }