Beispiel #1
0
        public static sdClientVersionResponse sdCheckVersion()
        {
            var sr = sdGetRequestResponse(METHODS.GET, "version/" + userAgent, null, false);

            if (sr == null)
            {
                Logger.WriteError("Did not receive a response from Schedules Direct for a version check.");
                return(null);
            }

            try
            {
                sdClientVersionResponse ret = JsonConvert.DeserializeObject <sdClientVersionResponse>(sr);
                switch (ret.Code)
                {
                case 0:
                    if (ret.Version != grabberVersion)
                    {
                        if (Logger.eventID == 0)
                        {
                            Logger.eventID = 1;
                        }
                        Logger.WriteInformation(string.Format("epg123 is not up to date. Latest version is {0} and can be downloaded from http://epg123.garyan2.net.", ret.Version));
                    }
                    return(ret);

                case 1005:
                    Logger.WriteInformation(string.Format("epg123 is not recognized as an approved app from Schedules Direct. code: {0} , message: {1} , datetime: {2}", ret.Code, ret.Message, ret.Datetime));
                    break;

                case 3000:
                default:
                    Logger.WriteError(string.Format("Failed version check. code: {0} , message: {1} , datetime: {2}", ret.Code, ret.Message, ret.Datetime));
                    break;
                }
            }
            catch (Exception ex)
            {
                Logger.WriteError(string.Format("sdClientVersionResponse() Unknown exception thrown. Message: {0}", ex.Message));
            }
            return(null);
        }
Beispiel #2
0
        public static void Build(epgConfig configuration)
        {
            string errString = string.Empty;

            // initialize schedules direct API
            sdAPI.Initialize("EPG123", epg123Version);

            // copy configuration to local variable
            config = configuration;

            // initialize event buffer
            Logger.WriteInformation(string.Format("Beginning EPG123 update execution. {0:u}", DateTime.Now.ToUniversalTime()));
            Logger.WriteVerbose(string.Format("DaysToDownload: {0} , TheTVDBNumbers : {1} , PrefixEpisodeTitle: {2} , PrefixEpisodeDescription : {3} , AppendEpisodeDesc: {4} , OADOverride : {5} , TMDbCoverArt: {6} , IncludeSDLogos : {7} , AutoAddNew: {8} , CreateXmltv: {9} , ModernMediaUiPlusSupport: {10}",
                                              config.DaysToDownload, config.TheTVDBNumbers, config.PrefixEpisodeTitle, config.PrefixEpisodeDescription, config.AppendEpisodeDesc, config.OADOverride, config.TMDbCoverArt, config.IncludeSDLogos, config.AutoAddNew, config.CreateXmltv, config.ModernMediaUiPlusSupport));

            // populate station prefixes to suppress
            if (config.SuppressStationEmptyWarnings == null)
            {
                suppressedPrefixes = new List <string>(defaultSuppressedPrefixes.Split(','));
            }
            else
            {
                suppressedPrefixes = new List <string>(config.SuppressStationEmptyWarnings.Split(','));
            }

            // login to Schedules Direct and build the mxf file
            if (sdAPI.sdGetToken(config.UserAccount.LoginName, config.UserAccount.PasswordHash, ref errString))
            {
                // check server status
                sdUserStatusResponse susr = sdAPI.sdGetStatus();
                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
                sdClientVersionResponse scvr = sdAPI.sdCheckVersion();
                if ((scvr != null) && !string.IsNullOrEmpty(scvr.Version))
                {
                    sdMxf.Providers[0].DisplayName += " v" + epg123Version;
                    if (epg123Version != scvr.Version)
                    {
                        sdMxf.Providers[0].DisplayName += string.Format(" (v{0} Available)", scvr.Version);
                        BrandLogo.updateAvailable       = true;
                    }
                }

                // make sure cache directory exists
                if (!Directory.Exists(Helper.Epg123CacheFolder))
                {
                    Directory.CreateDirectory(Helper.Epg123CacheFolder);
                }

                // initialize tmdb api
                tmdbAPI.Initialize(false);

                // prepopulate keyword groups
                initializeKeywordGroups();

                // read all image links archived in file
                getImageArchive();

                // 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 (success = buildLineupServices() && serviceCountSafetyCheck() &&
                              getAllScheduleEntryMd5s(config.DaysToDownload) &&
                              buildAllProgramEntries() &&
                              buildAllGenericSeriesInfoDescriptions() && buildAllExtendedSeriesDataForUiPlus() &&
                              getAllMoviePosters() &&
                              getAllSeriesImages() &&
                              buildKeywords() &&
                              writeMxf())
                {
                    // create the xmltv file if desired
                    if (config.CreateXmltv && CreateXmltvFile())
                    {
                        writeXmltv();
                        ++processedObjects; reportProgress();
                    }

                    // save the image links
                    writeImageArchive();

                    // 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();

                    Logger.WriteVerbose(string.Format("Downloaded and processed {0} of data from Schedules Direct.", sdAPI.TotalDownloadBytes));
                    Logger.WriteVerbose(string.Format("Generated .mxf file contains {0} services, {1} series, {2} programs, and {3} people with {4} image links.",
                                                      sdMxf.With[0].Services.Count, sdMxf.With[0].SeriesInfos.Count, sdMxf.With[0].Programs.Count, sdMxf.With[0].People.Count, sdMxf.With[0].GuideImages.Count));
                    Logger.WriteInformation("Completed EPG123 update execution. SUCCESS.");
                }
                else
                {
                    Logger.WriteError("Failed to create MXF file. Exiting.");
                }
            }
            else
            {
                Logger.WriteError(string.Format("Failed to retrieve token from Schedules Direct. message: {0}", errString));
            }
        }