Ejemplo n.º 1
0
 public DBSeries(String SeriesName)
     : base(cTableName)
 {
     InitColumns();
     if (!ReadPrimary(SeriesName))
     {
         InitValues();
     }
     if (this[cID] == 0)
     {
         m_onlineSeries = new DBOnlineSeries(s_nLastLocalID);
         s_nLastLocalID--;
         DBOption.SetOptions(DBOption.cDBSeriesLastLocalID, s_nLastLocalID);
         this[cID] = m_onlineSeries[DBOnlineSeries.cID];
         if (String.IsNullOrEmpty(m_onlineSeries[DBOnlineSeries.cPrettyName]))
         {
             m_onlineSeries[DBOnlineSeries.cPrettyName] = this[cParsedName];
             m_onlineSeries[DBOnlineSeries.cSortName]   = this[cParsedName];
             m_onlineSeries.Commit();
         }
     }
     else
     {
         m_onlineSeries = new DBOnlineSeries(this[cID]);
     }
 }
Ejemplo n.º 2
0
 protected override void OnPageDestroy(int newWindowId)
 {
     currentSelectedItem = m_Facade.SelectedListItemIndex;
     DBOption.SetOptions(DBOption.cRepeatPlaylist, playlistPlayer.RepeatPlaylist);
     DBOption.SetOptions(DBOption.cPlaylistAutoPlay, playlistPlayer.PlaylistAutoPlay);
     prevSelectedEpisode = null;
     Helper.enableNativeAutoplay();
     base.OnPageDestroy(newWindowId);
 }
Ejemplo n.º 3
0
        }                        // prevent instances

        public static void saveToDB(List <string> entries)
        {
            StringBuilder logoB = new StringBuilder();

            foreach (string entry in entries)
            {
                logoB.Append(entry).Append(entriesSplit);
            }
            if (logoB.Length > entriesSplit.Length)
            {
                logoB.Remove(logoB.Length - entriesSplit.Length, entriesSplit.Length);
            }
            DBOption.SetOptions(optionName, logoB.ToString());
            entriesInMemory = false;
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Read Logo Rules and Import into Database
        /// </summary>
        /// <param name="doc"></param>
        private static void GetLogoRules(XmlDocument doc)
        {
            XmlNode node = null;

            node = doc.DocumentElement.SelectSingleNode("/settings/logos");
            if (node != null && node.Attributes.GetNamedItem("import").Value.ToLower() == "true")
            {
                MPTVSeriesLog.Write("Loading Skin Logo Rules", MPTVSeriesLog.LogLevel.Normal);

                DBOption.SetOptions("logoConfig", "");
                List <string> logos = new List <string>();
                foreach (string rule in node.InnerText.Split('\n'))
                {
                    logos.Add(rule.Trim());
                }
                localLogos.saveToDB(logos);
                ImportLogos = true;
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Read Graphics Quality Settings and Import into Database
        /// </summary>
        /// <param name="doc"></param>
        private static void GetGraphicsQuality(XmlDocument doc)
        {
            XmlNode node      = null;
            XmlNode innerNode = null;

            node = doc.DocumentElement.SelectSingleNode("/settings/graphicsquality");
            if (node != null && node.Attributes.GetNamedItem("import").Value.ToLower() == "true")
            {
                MPTVSeriesLog.Write("Loading Skin Thumbnail Graphics Quality", MPTVSeriesLog.LogLevel.Normal);

                innerNode = node.SelectSingleNode("seriesbanners");
                if (innerNode != null)
                {
                    DBOption.SetOptions(DBOption.cQualitySeriesBanners, innerNode.InnerText.Trim());
                }
                innerNode = node.SelectSingleNode("seriesposters");
                if (innerNode != null)
                {
                    DBOption.SetOptions(DBOption.cQualitySeriesPosters, innerNode.InnerText.Trim());
                }
                innerNode = node.SelectSingleNode("seriescoverflow");
                if (innerNode != null)
                {
                    DBOption.SetOptions(DBOption.cQualitySeriesPosters, innerNode.InnerText.Trim());
                }
                innerNode = node.SelectSingleNode("seasonbanners");
                if (innerNode != null)
                {
                    DBOption.SetOptions(DBOption.cQualitySeasonBanners, innerNode.InnerText.Trim());
                }
                innerNode = node.SelectSingleNode("episodethumbs");
                if (innerNode != null)
                {
                    DBOption.SetOptions(DBOption.cQualityEpisodeImages, innerNode.InnerText.Trim());
                }

                ImportGraphics = true;
            }
        }
Ejemplo n.º 6
0
        static DBExpression()
        {
            // make sure the table is created - create a dummy object
            DBExpression dummy = new DBExpression();

            DBExpression[] expressions = DBExpression.GetAll();

            if (expressions == null || expressions.Length == 0)
            {
                // no expressions in the db, add defaults
                AddDefaults();
            }
            else
            {
                // upgrade, add any new expressions
                int nCurrentDBVersion = cDBVersion;
                int nUpgradeDBVersion = DBOption.GetOptions(DBOption.cDBExpressionsVersion);

                while (nUpgradeDBVersion != nCurrentDBVersion)
                {
                    DBExpression expression = new DBExpression();
                    switch (nUpgradeDBVersion)
                    {
                    case 4:
                        expression[DBExpression.cEnabled]    = "1";
                        expression[DBExpression.cIndex]      = expressions.Length;
                        expression[DBExpression.cType]       = DBExpression.cType_Regexp;
                        expression[DBExpression.cExpression] = @"(^.*?\\?(?<series>[^\\$]+?)[ .-]+(?<firstaired>\d{2,4}[.-]\d{2}[.-]\d{2,4})[ .-]*(?<title>(?![^\\]*?(?<!the)[ .(-]sample[ .)-]).*?)\.(?<ext>[^.]*)$)";
                        expression.Commit();
                        break;
                    }
                    nUpgradeDBVersion++;
                }

                DBOption.SetOptions(DBOption.cDBExpressionsVersion, nCurrentDBVersion);
            }
        }
Ejemplo n.º 7
0
        static DBSeason()
        {
            DBSeason dummy = new DBSeason();

            ////////////////////////////////////////////////////////////////////////////////
            #region Pretty Names displayed in Configuration Details Tab
            s_FieldToDisplayNameMap.Add(cID, "Composite Season ID");
            s_FieldToDisplayNameMap.Add(cSeriesID, "Series ID");
            s_FieldToDisplayNameMap.Add(cIndex, "Season Index");
            s_FieldToDisplayNameMap.Add(cEpisodeCount, "Episodes");
            s_FieldToDisplayNameMap.Add(cEpisodesUnWatched, "Episodes UnWatched");
            s_FieldToDisplayNameMap.Add(cMyRating, "My Rating");
            #endregion
            ////////////////////////////////////////////////////////////////////////////////

            int nCurrentDBVersion = cDBVersion;
            int nUpgradeDBVersion = DBOption.GetOptions(DBOption.cDBSeasonVersion);
            while (nUpgradeDBVersion != nCurrentDBVersion)
            {
                SQLCondition    condEmpty  = new SQLCondition();
                List <DBSeason> AllSeasons = Get(condEmpty, true);
                // take care of the upgrade in the table
                switch (nUpgradeDBVersion)
                {
                case 1:
                    // upgrade to version 2; clear the season table (series table format changed)
                    try
                    {
                        String sqlQuery = "DROP TABLE season";
                        DBTVSeries.Execute(sqlQuery);
                        nUpgradeDBVersion++;
                    }
                    catch { }
                    break;

                case 2:
                    DBSeason.GlobalSet(DBSeason.cHidden, 0, new SQLCondition());
                    DBSeries.GlobalSet(DBOnlineSeries.cGetEpisodesTimeStamp, 0, new SQLCondition());
                    nUpgradeDBVersion++;
                    break;

                case 3:
                    // create the unwatcheditem value by parsin the episodes
                    foreach (DBSeason season in AllSeasons)
                    {
                        DBEpisode episode = DBEpisode.GetFirstUnwatched(season[DBSeason.cSeriesID], season[DBSeason.cIndex]);
                        if (episode != null)
                        {
                            season[DBSeason.cUnwatchedItems] = true;
                        }
                        else
                        {
                            season[DBSeason.cUnwatchedItems] = false;
                        }
                        season.Commit();
                    }
                    nUpgradeDBVersion++;
                    break;

                case 4:
                    // Set number of watched/unwatched episodes
                    foreach (DBSeason season in AllSeasons)
                    {
                        int epsTotal     = 0;
                        int epsUnWatched = 0;
                        DBEpisode.GetSeasonEpisodeCounts(season, out epsTotal, out epsUnWatched);
                        season[DBSeason.cEpisodeCount]      = epsTotal;
                        season[DBSeason.cEpisodesUnWatched] = epsUnWatched;
                        season.Commit();
                    }
                    nUpgradeDBVersion++;
                    break;

                default:
                    nUpgradeDBVersion = nCurrentDBVersion;
                    break;
                }
            }
            DBOption.SetOptions(DBOption.cDBSeasonVersion, nCurrentDBVersion);
        }
Ejemplo n.º 8
0
        static DBOption()
        {
            CreateTable();

            #region Set Default Options
            if (GetOptions(cConfigLogCollapsed) == null)
            {
                SetOptions(cConfigLogCollapsed, false);
            }

            if (GetOptions(cDBSeriesLastLocalID) == null)
            {
                SetOptions(cDBSeriesLastLocalID, -1);
            }

            if (GetOptions(cShowHiddenItems) == null)
            {
                SetOptions(cShowHiddenItems, false);
            }

            if (GetOptions(cOnlineParseEnabled) == null)
            {
                SetOptions(cOnlineParseEnabled, true);
            }

            if (GetOptions(cFullSeriesRetrieval) == null)
            {
                SetOptions(cFullSeriesRetrieval, false);
            }

            if (GetOptions(cGetEpisodeSnapshots) == null)
            {
                SetOptions(cGetEpisodeSnapshots, true);
            }

            if (GetOptions(cAutoChooseSeries) == null)
            {
                SetOptions(cAutoChooseSeries, true);
            }

            if (GetOptions(cAutoChooseOrder) == null)
            {
                SetOptions(cAutoChooseOrder, true);
            }

            if (GetOptions(cOnlyShowLocalFiles) == null)
            {
                SetOptions(cOnlyShowLocalFiles, true);
            }

            if (GetOptions(cHideUnwatchedSummary) == null)
            {
                SetOptions(cHideUnwatchedSummary, false);
            }

            if (GetOptions(cHideUnwatchedThumbnail) == null)
            {
                SetOptions(cHideUnwatchedThumbnail, false);
            }

            if (GetOptions(cImportFolderWatch) == null)
            {
                SetOptions(cImportFolderWatch, true);
            }

            if (GetOptions(cImportScanRemoteShare) == null)
            {
                SetOptions(cImportScanRemoteShare, true);
            }

            if (GetOptions(cImportScanRemoteShareLapse) == null)
            {
                SetOptions(cImportScanRemoteShareLapse, 5);
            }

            if (GetOptions(cImportAutoUpdateOnlineData) == null)
            {
                SetOptions(cImportAutoUpdateOnlineData, true);
            }

            if (GetOptions(cImportAutoUpdateOnlineDataLapse) == null)
            {
                SetOptions(cImportAutoUpdateOnlineDataLapse, 12);
            }

            if (GetOptions(cImportOnlineUpdateScanLastTime) == null)
            {
                SetOptions(cImportOnlineUpdateScanLastTime, 0);
            }

            if (GetOptions(cImportDontClearMissingLocalFiles) == null)
            {
                SetOptions(cImportDontClearMissingLocalFiles, 0);
            }

            if (GetOptions(cCheckArtwork) == null)
            {
                SetOptions(cCheckArtwork, 0);
            }

            if (GetOptions(cPluginName) == null)
            {
                SetOptions(cPluginName, "My TV Series");
            }

            if (GetOptions(cViewAutoHeight) == null)
            {
                SetOptions(cViewAutoHeight, true);
            }

            if (GetOptions(cViewSeriesListFormat) == null)
            {
                SetOptions(cViewSeriesListFormat, "ListPosters");
            }

            if (GetOptions(cViewSeasonListFormat) == null)
            {
                SetOptions(cViewSeasonListFormat, 0);
            }

            if (GetOptions(cViewSeriesColOne) == null)
            {
                SetOptions(cViewSeriesColOne, "");
            }

            if (GetOptions(cViewSeriesColTwo) == null)
            {
                SetOptions(cViewSeriesColTwo, "<" + DBSeries.cOutName + "." + DBOnlineSeries.cPrettyName + ">");
            }

            if (GetOptions(cViewSeriesColThree) == null)
            {
                SetOptions(cViewSeriesColThree, "<" + DBSeries.cOutName + "." + DBOnlineSeries.cAirsDay + ">");
            }

            if (GetOptions(cViewSeriesTitle) == null)
            {
                SetOptions(cViewSeriesTitle, "<" + DBSeries.cOutName + "." + DBOnlineSeries.cPrettyName + ">");
            }

            if (GetOptions(cViewSeriesSecondTitle) == null)
            {
                SetOptions(cViewSeriesSecondTitle, "<" + DBSeries.cOutName + "." + DBOnlineSeries.cGenre + ">");
            }

            if (GetOptions(cViewSeriesMain) == null)
            {
                SetOptions(cViewSeriesMain, "<" + DBSeries.cOutName + "." + DBOnlineSeries.cSummary + ">");
            }

            if (GetOptions(cUseSortName) == null)
            {
                SetOptions(cUseSortName, 0); // default sort is by pretty name
            }
            if (GetOptions(cViewSeasonColOne) == null)
            {
                SetOptions(cViewSeasonColOne, "");
            }

            if (GetOptions(cViewSeasonColTwo) == null)
            {
                SetOptions(cViewSeasonColTwo, "Season <" + DBSeason.cOutName + "." + DBSeason.cIndex + ">");
            }

            if (GetOptions(cViewSeasonColThree) == null)
            {
                SetOptions(cViewSeasonColThree, "");
            }

            if (GetOptions(cViewSeasonTitle) == null)
            {
                SetOptions(cViewSeasonTitle, "<" + DBSeries.cOutName + "." + DBOnlineSeries.cPrettyName + "> Season <" + DBSeason.cOutName + "." + DBSeason.cIndex + ">");
            }

            if (GetOptions(cViewSeasonSecondTitle) == null)
            {
                SetOptions(cViewSeasonSecondTitle, "<" + DBSeries.cOutName + "." + DBOnlineSeries.cGenre + ">");
            }

            if (GetOptions(cViewSeasonMain) == null)
            {
                SetOptions(cViewSeasonMain, "<" + DBSeries.cOutName + "." + DBOnlineSeries.cSummary + ">");
            }

            if (GetOptions(cViewEpisodeColOne) == null)
            {
                SetOptions(cViewEpisodeColOne, "");
            }

            if (GetOptions(cViewEpisodeColTwo) == null)
            {
                SetOptions(cViewEpisodeColTwo, "<" + DBEpisode.cOutName + "." + DBEpisode.cEpisodeIndex + ">: <" + DBEpisode.cOutName + "." + DBEpisode.cEpisodeName + ">");
            }

            if (GetOptions(cViewEpisodeColThree) == null)
            {
                SetOptions(cViewEpisodeColThree, "<" + DBEpisode.cOutName + "." + DBOnlineEpisode.cFirstAired + ">");
            }

            if (GetOptions(cViewEpisodeTitle) == null)
            {
                SetOptions(cViewEpisodeTitle, "<" + DBEpisode.cOutName + "." + DBEpisode.cSeasonIndex + ">x<" + DBEpisode.cOutName + "." + DBEpisode.cEpisodeIndex + ">: <" + DBEpisode.cOutName + "." + DBEpisode.cEpisodeName + ">");
            }

            if (GetOptions(cViewEpisodeSecondTitle) == null)
            {
                SetOptions(cViewEpisodeSecondTitle, "<" + DBSeries.cOutName + "." + DBOnlineSeries.cGenre + ">");
            }

            if (GetOptions(cViewEpisodeMain) == null)
            {
                SetOptions(cViewEpisodeMain, "<" + DBEpisode.cOutName + "." + DBOnlineEpisode.cEpisodeSummary + ">");
            }

            if (GetOptions(cRandomBanner) == null)
            {
                SetOptions(cRandomBanner, 0);
            }

            if (GetOptions(cWatchedAfter) == null)
            {
                SetOptions(cWatchedAfter, 95);
            }

            // this is the default main mirrors
            if (GetOptions(DBOption.cMainMirror) == null || GetOptions(DBOption.cMainMirror) == "http://thetvdb.com/interfaces")
            {
                DBOption.SetOptions(DBOption.cMainMirror, cMainMirrorHardCoded);
            }

            if (GetOptions(cNewAPIUpgradeDone) == null)
            {
                SetOptions(cNewAPIUpgradeDone, 0);
            }

            int oldLangOptionSet;
            if (GetOptions(cOnlineLanguage) == null || int.TryParse(GetOptions(cOnlineLanguage), out oldLangOptionSet))
            {
                SetOptions(cOnlineLanguage, "en"); // old api used index for onlinelang, new one two letters
            }
            if (GetOptions(cAppendFirstLogoToList) == null)
            {
                SetOptions(cAppendFirstLogoToList, 0); //default no (most skins don't seem to use this)
            }
            if (GetOptions(cGraphicalGroupView) == null)
            {
                SetOptions(cGraphicalGroupView, 0); //default yes (should work on all skins)
            }
            if (GetOptions(cQualitySeriesBanners) == null)
            {
                SetOptions(cQualitySeriesBanners, 75);
            }

            if (GetOptions(cQualitySeriesPosters) == null)
            {
                SetOptions(cQualitySeriesPosters, 50);
            }

            if (GetOptions(cQualitySeriesCoverflow) == null)
            {
                SetOptions(cQualitySeriesCoverflow, 50);
            }

            if (GetOptions(cQualitySeasonBanners) == null)
            {
                SetOptions(cQualitySeasonBanners, 75);
            }

            if (GetOptions(cQualitySeasonCoverflow) == null)
            {
                SetOptions(cQualitySeasonCoverflow, 90);
            }

            if (GetOptions(cQualityEpisodeImages) == null)
            {
                SetOptions(cQualityEpisodeImages, 100);
            }

            if (GetOptions(cFanartRandom) == null)
            {
                SetOptions(cFanartRandom, true);
            }

            if (GetOptions(cOnlineFavourites) == null)
            {
                SetOptions(cOnlineFavourites, false);
            }

            if (GetOptions(cPlaylistPath) == null)
            {
                string playListFolder = Environment.GetFolderPath(Environment.SpecialFolder.Personal) + @"\My Playlists";
                SetOptions(cPlaylistPath, playListFolder);
            }

            if (GetOptions(cRepeatPlaylist) == null)
            {
                SetOptions(cRepeatPlaylist, false);
            }

            if (GetOptions(cPlaylistAutoPlay) == null)
            {
                SetOptions(cPlaylistAutoPlay, true);
            }

            if (GetOptions(cPlaylistAutoShuffle) == null)
            {
                SetOptions(cPlaylistAutoShuffle, false);
            }

            if (GetOptions(cImportScanOnStartup) == null)
            {
                SetOptions(cImportScanOnStartup, true);
            }

            if (GetOptions(cAutoDownloadMissingArtwork) == null)
            {
                SetOptions(cAutoDownloadMissingArtwork, true);
            }

            if (GetOptions(cAutoUpdateEpisodeRatings) == null)
            {
                SetOptions(cAutoUpdateEpisodeRatings, false);
            }

            if (GetOptions(cAutoUpdateAllFanart) == null)
            {
                SetOptions(cAutoUpdateAllFanart, false);
            }

            if (GetOptions(cAutoDownloadFanart) == null)
            {
                SetOptions(cAutoDownloadFanart, true);
            }

            if (GetOptions(cAutoDownloadFanartCount) == null)
            {
                SetOptions(cAutoDownloadFanartCount, 3);
            }

            if (GetOptions(cAutoDownloadFanartResolution) == null)
            {
                SetOptions(cAutoDownloadFanartResolution, 0); //0=Both,1=1280x720,2=1920x1080
            }
            if (GetOptions(cFanartThumbnailResolutionFilter) == null)
            {
                SetOptions(cFanartThumbnailResolutionFilter, 0);
            }

            if (GetOptions(cFanartCurrentView) == null)
            {
                SetOptions(cFanartCurrentView, 2); // Large Icons
            }
            if (GetOptions(cUseRegionalDateFormatString) == null)
            {
                SetOptions(cUseRegionalDateFormatString, 0);
            }

            if (GetOptions(cDefaultRating) == null)
            {
                SetOptions(cDefaultRating, 7);                 // Scale 1 - 10
            }
            if (GetOptions(cRatingDisplayStars) == null)
            {
                SetOptions(cRatingDisplayStars, 10);                 // 5 or 10 Stars
            }
            if (GetOptions(cSortSpecials) == null)
            {
                SetOptions(cSortSpecials, 0);
            }

            if (GetOptions(cBackdropLoadingDelay) == null)
            {
                SetOptions(cBackdropLoadingDelay, 250); //milliseconds
            }
            if (GetOptions(cArtworkLoadingDelay) == null)
            {
                SetOptions(cArtworkLoadingDelay, 250); //milliseconds
            }
            if (GetOptions(cRandomFanartInterval) == null)
            {
                SetOptions(cRandomFanartInterval, 30000); //milliseconds
            }
            if (GetOptions(cAutoDownloadFanartSeriesNames) == null)
            {
                SetOptions(cAutoDownloadFanartSeriesNames, 0);
            }

            if (GetOptions(cParentalControlPinCode) == null)
            {
                SetOptions(cParentalControlPinCode, string.Empty);
            }

            if (GetOptions(cMarkRatedEpisodeAsWatched) == null)
            {
                SetOptions(cMarkRatedEpisodeAsWatched, 0);
            }

            if (GetOptions(cSubstituteMissingArtwork) == null)
            {
                SetOptions(cSubstituteMissingArtwork, 1);
            }

            if (GetOptions(cAskToRate) == null)
            {
                SetOptions(cAskToRate, 0);
            }

            if (GetOptions(cSkipSeasonViewOnSingleSeason) == null)
            {
                SetOptions(cSkipSeasonViewOnSingleSeason, 1);
            }

            if (GetOptions(cImportScanWhileFullscreenVideo) == null)
            {
                SetOptions(cImportScanWhileFullscreenVideo, 0);
            }

            if (GetOptions(cInvokeExtBeforePlayback) == null)
            {
                SetOptions(cInvokeExtBeforePlayback, string.Empty);
            }

            if (GetOptions(cInvokeExtBeforePlaybackArgs) == null)
            {
                SetOptions(cInvokeExtBeforePlaybackArgs, "\"<Episode.EpisodeFilename>\"");
            }

            if (GetOptions(cInvokeExtBeforePlaybackWaitForExit) == null)
            {
                SetOptions(cInvokeExtBeforePlaybackWaitForExit, 0);
            }

            if (GetOptions(cInvokeExtAfterPlayback) == null)
            {
                SetOptions(cInvokeExtAfterPlayback, string.Empty);
            }

            if (GetOptions(cInvokeExtAfterPlaybackArgs) == null)
            {
                SetOptions(cInvokeExtAfterPlaybackArgs, "\"<Episode.EpisodeFilename>\"");
            }

            if (GetOptions(cInvokeExtAfterPlaybackWaitForExit) == null)
            {
                SetOptions(cInvokeExtAfterPlaybackWaitForExit, 0);
            }

            if (GetOptions(cCountEmptyAndFutureAiredEps) == null)
            {
                SetOptions(cCountEmptyAndFutureAiredEps, 1);
            }

            if (GetOptions(cOnPlaySeriesOrSeasonAction) == null)
            {
                SetOptions(cOnPlaySeriesOrSeasonAction, 2); // set first unwatched as default
            }
            if (GetOptions(cNewEpisodeThumbType) == null)
            {
                SetOptions(cNewEpisodeThumbType, (int)NewEpisodeIndicatorType.recentlyadded); // Recently Added Episodes
            }
            if (GetOptions(cNewEpisodeRecentDays) == null)
            {
                SetOptions(cNewEpisodeRecentDays, 7);
            }

            if (GetOptions(cSubCentralEnabled) == null)
            {
                SetOptions(cSubCentralEnabled, true);
            }

            if (GetOptions(cSubCentralEnabledForEpisodes) == null)
            {
                SetOptions(cSubCentralEnabledForEpisodes, true);
            }

            if (GetOptions(cSubCentralSubtitleDownloadOnPlay) == null)
            {
                SetOptions(cSubCentralSubtitleDownloadOnPlay, false);
            }

            if (GetOptions(cPlaylistUnwatchedOnly) == null)
            {
                SetOptions(cPlaylistUnwatchedOnly, false);
            }

            if (GetOptions(cDisableMediaInfo) == null)
            {
                SetOptions(cDisableMediaInfo, false);
            }

            if (GetOptions(cMediaInfoParseSpeed) == null)
            {
                SetOptions(cMediaInfoParseSpeed, "0.1"); // Default is 0.5 (scan 50% of file) but we dont need that for TVSeries.
            }
            if (GetOptions(cImportDelay) == null)
            {
                SetOptions(cImportDelay, 30);
            }

            if (GetOptions(cDelayImportPathMonitoringValue) == null)
            {
                SetOptions(cDelayImportPathMonitoringValue, 20);
            }

            if (GetOptions(cSetHiddenSeriesAsScanIgnore) == null)
            {
                SetOptions(cSetHiddenSeriesAsScanIgnore, true);
            }

            if (GetOptions(cGetBlankBanners) == null)
            {
                SetOptions(cGetBlankBanners, false);
            }

            if (GetOptions(cGetTextBanners) == null)
            {
                SetOptions(cGetTextBanners, false);
            }

            if (GetOptions(cArtworkLimitSeriesWideBanners) == null)
            {
                SetOptions(cArtworkLimitSeriesWideBanners, 3);
            }

            if (GetOptions(cArtworkLimitSeriesPosters) == null)
            {
                SetOptions(cArtworkLimitSeriesPosters, 3);
            }

            if (GetOptions(cArtworkLimitSeasonPosters) == null)
            {
                SetOptions(cArtworkLimitSeasonPosters, 2); // 20 seasons = 40 posters
            }
            if (GetOptions(cMaxConsecutiveDownloadErrors) == null)
            {
                SetOptions(cMaxConsecutiveDownloadErrors, 3);
            }

            if (GetOptions(cSortSpecialSeasonLast) == null)
            {
                SetOptions(cSortSpecialSeasonLast, true);
            }

            if (GetOptions(cActorLayout) == null)
            {
                SetOptions(cActorLayout, 0);
            }

            if (GetOptions(cArtworkChooserLayout) == null)
            {
                SetOptions(cArtworkChooserLayout, 0);
            }

            if (GetOptions(cAutoGenerateEpisodeTitles) == null)
            {
                SetOptions(cAutoGenerateEpisodeTitles, true);
            }

            if (GetOptions(cParentalControlDisableAfter) == null)
            {
                SetOptions(cParentalControlDisableAfter, new DateTime(2018, 02, 25, 21, 0, 0).ToShortTimeString());
            }

            if (GetOptions(cParentalControlDisableBefore) == null)
            {
                SetOptions(cParentalControlDisableBefore, new DateTime(2018, 02, 26, 3, 0, 0).ToShortTimeString());
            }

            if (GetOptions(cParentalControlResetInterval) == null)
            {
                SetOptions(cParentalControlResetInterval, 60);
            }

            if (GetOptions(cShowDeleteMenu) == null)
            {
                SetOptions(cShowDeleteMenu, true);
            }

            if (GetOptions(cSQLLoggingEnabled) == null)
            {
                SetOptions(cSQLLoggingEnabled, false);
            }

            if (GetOptions(cCheckPlayOutOfOrder) == null)
            {
                SetOptions(cCheckPlayOutOfOrder, true);
            }

            if (GetOptions(cFilterUnwatched) == null)
            {
                SetOptions(cFilterUnwatched, false);
            }

            if (GetOptions(cAutoDownloadActors) == null)
            {
                SetOptions(cAutoDownloadActors, false);
            }

            if (GetOptions(cCleanOnlineEpisodes) == null)
            {
                SetOptions(cCleanOnlineEpisodes, true);
            }

            if (GetOptions(cCleanOnlineEpisodeZero) == null)
            {
                SetOptions(cCleanOnlineEpisodeZero, false);
            }

            if (GetOptions(cOverrideLanguage) == null)
            {
                SetOptions(cOverrideLanguage, false);
            }

            if (GetOptions(cCountSpecialEpisodesAsWatched) == null)
            {
                SetOptions(cCountSpecialEpisodesAsWatched, false);
            }

            if (GetOptions(cTraktCommunityRatings) == null)
            {
                SetOptions(cTraktCommunityRatings, true);
            }

            if (GetOptions(cParsedNameFromFolder) == null)
            {
                SetOptions(cParsedNameFromFolder, false);
            }

            if (GetOptions(cDisableMediaInfoInConfigImports) == null)
            {
                SetOptions(cDisableMediaInfoInConfigImports, false);
            }

            if (GetOptions(cCheckShowOnlyEpisodesRequiringManualSelection) == null)
            {
                SetOptions(cCheckShowOnlyEpisodesRequiringManualSelection, false);
            }

            #endregion
        }
Ejemplo n.º 9
0
        static DBSeries()
        {
            // make sure the table is created on first run (and columns are added before we call SET)
            DBSeries dummy = new DBSeries();

            s_nLastLocalID = DBOption.GetOptions(DBOption.cDBSeriesLastLocalID);

            s_FieldToDisplayNameMap.Add(cParsedName, "Parsed Name");

            int nCurrentDBVersion = cDBVersion;
            int nUpgradeDBVersion = DBOption.GetOptions(DBOption.cDBSeriesVersion);

            while (nUpgradeDBVersion != nCurrentDBVersion)
            {
                SQLCondition    condEmpty = new SQLCondition();
                List <DBSeries> AllSeries = Get(condEmpty);

                // take care of the upgrade in the table
                switch (nUpgradeDBVersion)
                {
                case 1:
                case 2:
                    // upgrade to version 3; clear the series table (we use 2 other tables now)
                    try
                    {
                        String sqlQuery = "DROP TABLE series";
                        DBTVSeries.Execute(sqlQuery);
                        nUpgradeDBVersion++;
                    }
                    catch { }
                    break;

                case 3:
                    // set all new perseries timestamps to 0
                    DBOnlineSeries.GlobalSet(new DBOnlineSeries(), DBOnlineSeries.cGetEpisodesTimeStamp, 0, new SQLCondition());
                    DBOnlineSeries.GlobalSet(new DBOnlineSeries(), DBOnlineSeries.cUpdateBannersTimeStamp, 0, new SQLCondition());
                    nUpgradeDBVersion++;
                    break;

                case 4:
                    DBSeries.GlobalSet(new DBSeries(), DBSeries.cHidden, 0, new SQLCondition());
                    nUpgradeDBVersion++;
                    break;

                case 5:
                    // copy all local parsed name into the online series if seriesID = 0
                    SQLCondition conditions = new SQLCondition();
                    conditions.Add(new DBOnlineSeries(), DBOnlineSeries.cID, 0, SQLConditionType.LessThan);
                    // just getting the series should be enough
                    List <DBSeries> seriesList = DBSeries.Get(conditions);
                    nUpgradeDBVersion++;
                    break;

                case 6:
                    // set all watched flag timestamp to 0 (will be created)
                    DBOnlineSeries.GlobalSet(new DBOnlineSeries(), DBOnlineSeries.cWatchedFileTimeStamp, 0, new SQLCondition());
                    nUpgradeDBVersion++;
                    break;

                case 7:
                    // all series no tagged for auto download at first
                    DBOnlineSeries.GlobalSet(new DBOnlineSeries(), DBOnlineSeries.cTaggedToDownload, 0, new SQLCondition());
                    nUpgradeDBVersion++;
                    break;

                case 8:
                    // create the unwatcheditem value by parsin the episodes
                    foreach (DBSeries series in AllSeries)
                    {
                        DBEpisode episode = DBEpisode.GetFirstUnwatched(series[DBSeries.cID]);
                        if (episode != null)
                        {
                            series[DBOnlineSeries.cUnwatchedItems] = true;
                        }
                        else
                        {
                            series[DBOnlineSeries.cUnwatchedItems] = false;
                        }
                        series.Commit();
                    }
                    nUpgradeDBVersion++;
                    break;

                case 9:
                    // Set number of watched/unwatched episodes
                    foreach (DBSeries series in AllSeries)
                    {
                        int epsTotal     = 0;
                        int epsUnWatched = 0;
                        DBEpisode.GetSeriesEpisodeCounts(series[DBSeries.cID], out epsTotal, out epsUnWatched);
                        series[DBOnlineSeries.cEpisodeCount]      = epsTotal;
                        series[DBOnlineSeries.cEpisodesUnWatched] = epsUnWatched;
                        series.Commit();
                    }
                    nUpgradeDBVersion++;
                    break;

                case 10:
                    // Update Sort Name Column
                    foreach (DBSeries series in AllSeries)
                    {
                        series[DBOnlineSeries.cSortName] = Helper.GetSortByName(series[DBOnlineSeries.cPrettyName]);
                        series.Commit();
                    }
                    nUpgradeDBVersion++;
                    break;

                case 11:
                    // Migrate isFavourite to new Tagged View
                    conditions = new SQLCondition();
                    conditions.Add(new DBOnlineSeries(), DBOnlineSeries.cIsFavourite, "1", SQLConditionType.Equal);
                    seriesList = DBSeries.Get(conditions);

                    MPTVSeriesLog.Write("Migrating Favourite Series");
                    foreach (DBSeries series in seriesList)
                    {
                        // Tagged view are seperated with the pipe "|" character
                        string tagName = "|" + DBView.cTranslateTokenFavourite + "|";
                        series[DBOnlineSeries.cViewTags] = Helper.GetSeriesViewTags(series, true, tagName);
                        series.Commit();
                    }

                    // Migrate isOnlineFavourite to new TaggedView
                    conditions = new SQLCondition();
                    conditions.Add(new DBOnlineSeries(), DBOnlineSeries.cIsOnlineFavourite, "1", SQLConditionType.Equal);
                    seriesList = DBSeries.Get(conditions);

                    MPTVSeriesLog.Write("Migrating Online Favourite Series");
                    foreach (DBSeries series in seriesList)
                    {
                        // Tagged view are seperated with the pipe "|" character
                        string tagName = "|" + DBView.cTranslateTokenOnlineFavourite + "|";
                        series[DBOnlineSeries.cViewTags] = Helper.GetSeriesViewTags(series, true, tagName);
                        series.Commit();
                    }

                    nUpgradeDBVersion++;
                    break;

                case 12:
                    // we now have parsed_series names as titlecased
                    // to avoid users having to re-identify series for new episodes, and to avoid duplicate entries, we upgrade existing series names

                    foreach (var series in AllSeries)
                    {
                        string oldName = series[DBSeries.cParsedName];
                        string newName = oldName.ToTitleCase();
                        MPTVSeriesLog.Write(string.Format("Upgrading Parsed Series Name: {0} to {1}", oldName, newName));
                        series[DBSeries.cParsedName] = newName;
                        series.Commit();
                    }

                    nUpgradeDBVersion++;
                    break;

                case 13:
                    // original name not working in previous release
                    DBOnlineSeries.GlobalSet(new DBOnlineSeries(), DBOnlineSeries.cOriginalName, (DBValue)string.Empty, new SQLCondition());
                    nUpgradeDBVersion++;
                    break;

                case 14:
                    // original name not working in previous release
                    DBOnlineSeries.GlobalSet(new DBOnlineSeries(), DBOnlineSeries.cTraktIgnore, 0, new SQLCondition());
                    nUpgradeDBVersion++;
                    break;

                default:
                    // new DB, nothing special to do
                    nUpgradeDBVersion = nCurrentDBVersion;
                    break;
                }
            }
            DBOption.SetOptions(DBOption.cDBSeriesVersion, nCurrentDBVersion);
        }
Ejemplo n.º 10
0
        public static void fillDefaults()
        {
            DBView dummy = new DBView();

            DBView[] views = DBView.getAll(true);
            if (views == null || views.Length == 0)
            {
                // no views in the db => put the default ones
                DBView view = new DBView();
                view[cIndex]      = "0";
                view[cEnabled]    = "1";
                view[cSort]       = "1";
                view[cTransToken] = cTranslateTokenAll;
                view[cPrettyName] = "";
                view[cViewConfig] = @"series<;><;><;>" +
                                    "<nextStep>season<;><;><Season.seasonIndex>;asc<;>" +
                                    "<nextStep>episode<;><;><Episode.EpisodeIndex>;asc<;>";
                view[cTaggedView]      = "0";
                view[cParentalControl] = "0";
                view.Commit();

                view                   = new DBView();
                view[cIndex]           = "1";
                view[cEnabled]         = "1";
                view[cSort]            = "2";
                view[cTransToken]      = cTranslateTokenFavourite;
                view[cPrettyName]      = "";
                view[cViewConfig]      = GetTaggedViewConfigString(cTranslateTokenFavourite);
                view[cTaggedView]      = "1";
                view[cParentalControl] = "0";
                view.Commit();

                view                   = new DBView();
                view[cIndex]           = "2";
                view[cEnabled]         = "1";
                view[cSort]            = "3";
                view[cTransToken]      = cTranslateTokenOnlineFavourite;
                view[cPrettyName]      = "";
                view[cViewConfig]      = GetTaggedViewConfigString(cTranslateTokenOnlineFavourite);
                view[cTaggedView]      = "1";
                view[cParentalControl] = "0";
                view.Commit();

                view              = new DBView();
                view[cIndex]      = "3";
                view[cEnabled]    = "1";
                view[cSort]       = "4";
                view[cTransToken] = cTranslateTokenUnwatched;
                view[cPrettyName] = "";
                view[cViewConfig] = @"series<;><Episode.Watched>;=;0<;><;>" +
                                    "<nextStep>season<;><;><Season.seasonIndex>;asc<;>" +
                                    "<nextStep>episode<;><;><Episode.EpisodeIndex>;asc<;>";
                view[cTaggedView]      = "0";
                view[cParentalControl] = "0";
                view.Commit();

                view              = new DBView();
                view[cIndex]      = "4";
                view[cEnabled]    = "1";
                view[cSort]       = "5";
                view[cTransToken] = cTranslateTokenChannels;
                view[cPrettyName] = "";
                view[cViewConfig] = @"group:<Series.Network><;><;><;>" +
                                    "<nextStep>series<;><;><;>" +
                                    "<nextStep>season<;><;><Season.seasonIndex>;asc<;>" +
                                    "<nextStep>episode<;><;><Episode.EpisodeIndex>;asc<;>";
                view[cTaggedView]      = "0";
                view[cParentalControl] = "0";
                view.Commit();

                view              = new DBView();
                view[cIndex]      = "5";
                view[cEnabled]    = "1";
                view[cSort]       = "6";
                view[cTransToken] = cTranslateTokenGenres;
                view[cPrettyName] = "";
                view[cViewConfig] = @"group:<Series.Genre><;><;><;>" +
                                    "<nextStep>series<;><;><;>" +
                                    "<nextStep>season<;><;><Season.seasonIndex>;asc<;>" +
                                    "<nextStep>episode<;><;><Episode.EpisodeIndex>;asc<;>";
                view[cTaggedView]      = "0";
                view[cParentalControl] = "0";
                view.Commit();

                view              = new DBView();
                view[cIndex]      = "6";
                view[cEnabled]    = "1";
                view[cSort]       = "7";
                view[cTransToken] = cTranslateTokenContentRating;
                view[cPrettyName] = "";
                view[cViewConfig] = @"group:<Series.ContentRating><;><;><;>" +
                                    "<nextStep>series<;><;><;>" +
                                    "<nextStep>season<;><;><Season.seasonIndex>;asc<;>" +
                                    "<nextStep>episode<;><;><Episode.EpisodeIndex>;asc<;>";
                view[cTaggedView]      = "0";
                view[cParentalControl] = "0";
                view.Commit();

                view              = new DBView();
                view[cIndex]      = "7";
                view[cEnabled]    = "1";
                view[cSort]       = "8";
                view[cTransToken] = cTranslateTokenViewTags;
                view[cPrettyName] = "";
                view[cViewConfig] = @"group:<Series.ViewTags><;><;><;>" +
                                    "<nextStep>series<;><;><;>" +
                                    "<nextStep>season<;><;><Season.seasonIndex>;asc<;>" +
                                    "<nextStep>episode<;><;><Episode.EpisodeIndex>;asc<;>";
                view[cTaggedView]      = "0";
                view[cParentalControl] = "0";
                view.Commit();

                view                   = new DBView();
                view[cIndex]           = "8";
                view[cEnabled]         = "1";
                view[cSort]            = "9";
                view[cTransToken]      = cTranslateTokenLatest;
                view[cPrettyName]      = "";
                view[cViewConfig]      = @"episode<;><Episode.FirstAired>;<=;<today><cond><Episode.FirstAired>;>=;<today-30><;><Episode.FirstAired>;desc<;>";
                view[cTaggedView]      = "0";
                view[cParentalControl] = "0";
                view.Commit();

                view                   = new DBView();
                view[cIndex]           = "9";
                view[cEnabled]         = "1";
                view[cSort]            = "10";
                view[cTransToken]      = cTranslateTokenRecentlyAdded;
                view[cPrettyName]      = "";
                view[cViewConfig]      = @"episode<;><Episode.FileDateCreated>;>=;<today-7><;><Episode.FileDateCreated>;desc<;>";
                view[cTaggedView]      = "0";
                view[cParentalControl] = "0";
                view.Commit();
            }

            int nCurrentDBVersion = cDBVersion;
            int nUpgradeDBVersion = DBOption.GetOptions(DBOption.cDBViewsVersion);

            while (nUpgradeDBVersion != nCurrentDBVersion)
            {
                // WARNING: as of version 4, we can now remove and add views.
                // Be particularly carefull if adding/Removing/Updating

                // take care of the upgrade in the table
                switch (nUpgradeDBVersion)
                {
                case 1:
                    //Upgrade to version 2; 'Latest' view doesn't show anything from the future, and shows only from the last 30 days
                    DBView view = new DBView(5);
                    view[cViewConfig] = @"episode<;><Episode.FirstAired>;<=;<today><cond><Episode.FirstAired>;>=;<today-30><;><Episode.FirstAired>;desc<;>";
                    view.Commit();
                    nUpgradeDBVersion++;
                    break;

                case 2:
                    // Upgrade to version 3, new view 'Recently Added'
                    view              = new DBView();
                    view[cIndex]      = "6";
                    view[cEnabled]    = "1";
                    view[cSort]       = "7";
                    view[cTransToken] = cTranslateTokenRecentlyAdded;
                    view[cPrettyName] = "";
                    view[cViewConfig] = @"episode<;><Episode.FileDateCreated>;>=;<today-7><;><Episode.FileDateCreated>;desc<;>";
                    view.Commit();
                    nUpgradeDBVersion++;
                    break;

                case 3:
                    // Upgrade to version 4, new view 'Content Rating'
                    view              = new DBView();
                    view[cIndex]      = "7";
                    view[cEnabled]    = "1";
                    view[cSort]       = "8";
                    view[cTransToken] = cTranslateTokenContentRating;
                    view[cPrettyName] = "";
                    view[cViewConfig] = @"group:<Series.ContentRating><;><;><;>" +
                                        "<nextStep>series<;><;><;>" +
                                        "<nextStep>season<;><;><Season.seasonIndex>;asc<;>" +
                                        "<nextStep>episode<;><;><Episode.EpisodeIndex>;asc<;>";
                    view[cParentalControl] = "0";
                    view.Commit();

                    // New view 'View Tags'
                    view              = new DBView();
                    view[cIndex]      = "8";
                    view[cEnabled]    = "1";
                    view[cSort]       = "9";
                    view[cTransToken] = cTranslateTokenViewTags;
                    view[cPrettyName] = "";
                    view[cViewConfig] = @"group:<Series.ViewTags><;><;><;>" +
                                        "<nextStep>series<;><;><;>" +
                                        "<nextStep>season<;><;><Season.seasonIndex>;asc<;>" +
                                        "<nextStep>episode<;><;><Episode.EpisodeIndex>;asc<;>";
                    view[cParentalControl] = "0";
                    view.Commit();
                    nUpgradeDBVersion++;
                    break;

                case 4:
                    // Get All current Views
                    DBView[] viewList = DBView.getAll(true);

                    // Update old Favourite View to Tagged View
                    foreach (DBView v in viewList)
                    {
                        if (v[DBView.cTransToken] == cTranslateTokenFavourite)
                        {
                            v[cTaggedView] = "1";
                            v[cTransToken] = cTranslateTokenFavourite;
                            v[cPrettyName] = "";
                            v[cViewConfig] = GetTaggedViewConfigString(cTranslateTokenFavourite);
                            v.Commit();
                        }
                    }

                    // Add Online Favourites as Taqged View
                    view                   = new DBView();
                    view[cIndex]           = viewList.Length;
                    view[cEnabled]         = "1";
                    view[cSort]            = viewList.Length + 1;
                    view[cTransToken]      = cTranslateTokenOnlineFavourite;
                    view[cPrettyName]      = "";
                    view[cViewConfig]      = GetTaggedViewConfigString(cTranslateTokenOnlineFavourite);
                    view[cParentalControl] = "0";
                    view[cTaggedView]      = "1";
                    view.Commit();

                    nUpgradeDBVersion++;
                    break;

                default:
                    nUpgradeDBVersion = nCurrentDBVersion;
                    break;
                }
            }
            DBOption.SetOptions(DBOption.cDBViewsVersion, nCurrentDBVersion);
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Read View Settings and Import into Database
        /// </summary>
        /// <param name="doc">XML Document</param>
        private static void GetViews(XmlDocument doc)
        {
            XmlNode node      = null;
            XmlNode innerNode = null;

            node = doc.DocumentElement.SelectSingleNode("/settings/views");
            if (node != null && node.Attributes.GetNamedItem("import").Value.ToLower() == "true")
            {
                List <string> layouts = null;

                // Append First Logo/Image to List
                try {
                    if (node.Attributes.GetNamedItem("AppendlmageToList").Value.ToLower() == "true")
                    {
                        DBOption.SetOptions(DBOption.cAppendFirstLogoToList, "1");
                    }
                    else
                    {
                        DBOption.SetOptions(DBOption.cAppendFirstLogoToList, "0");
                    }
                }
                catch {
                    MPTVSeriesLog.Write("Error reading AppendlmageToList skin setting");
                }

                string layout = string.Empty;

                #region Group Views
                innerNode = node.SelectSingleNode("group");
                if (innerNode != null)
                {
                    MPTVSeriesLog.Write("Loading Skin Group View Settings", MPTVSeriesLog.LogLevel.Normal);

                    // Dont override default Layout if skin can change from GUI
                    if (GetLayoutCount("Group") == 0)
                    {
                        layout = innerNode.Attributes.GetNamedItem("layout").Value;
                        switch (layout.ToLower())
                        {
                        case "list":
                            DBOption.SetOptions(DBOption.cGraphicalGroupView, "0");
                            break;

                        case "smallicons":
                        case "bigicons":
                            DBOption.SetOptions(DBOption.cGraphicalGroupView, "1");
                            break;

                        default:
                            DBOption.SetOptions(DBOption.cGraphicalGroupView, "0");
                            break;
                        }
                    }
                    // Confirm that the current layout is really supported
                    // May have come from another skin that used an unsupported layout for this skin
                    if (GetLayoutCount("Group") > 0 && !IsLayoutSupported("Group"))
                    {
                        // Set First Supported Type
                        layouts = GetViewLayouts("Group");
                        if (layouts == null || layouts.Count == 0)
                        {
                            DBOption.SetOptions(DBOption.cGraphicalGroupView, "0");
                        }
                        else
                        {
                            DBOption.SetOptions(DBOption.cGraphicalGroupView, layouts[0]);
                        }
                    }
                }
                #endregion

                #region Series Views
                innerNode = node.SelectSingleNode("series");
                if (innerNode != null)
                {
                    MPTVSeriesLog.Write("Loading Skin Series View Settings", MPTVSeriesLog.LogLevel.Normal);

                    if (GetLayoutCount("Series") == 0)
                    {
                        layout = innerNode.Attributes.GetNamedItem("layout").Value;
                        switch (layout.ToLower())
                        {
                        case "listposters":
                            DBOption.SetOptions(DBOption.cViewSeriesListFormat, "ListPosters");
                            break;

                        case "listbanners":
                            DBOption.SetOptions(DBOption.cViewSeriesListFormat, "ListBanners");
                            break;

                        case "filmstrip":
                            DBOption.SetOptions(DBOption.cViewSeriesListFormat, "Filmstrip");
                            break;

                        case "widebanners":
                            DBOption.SetOptions(DBOption.cViewSeriesListFormat, "WideBanners");
                            break;

                        case "coverflow":
                            DBOption.SetOptions(DBOption.cViewSeriesListFormat, "Coverflow");
                            break;

                        default:
                            DBOption.SetOptions(DBOption.cViewSeriesListFormat, "WideBanners");
                            break;
                        }
                    }
                    // Confirm that the current layout is really supported
                    // May have come from another skin that used an unsupported layout for this skin
                    if (GetLayoutCount("Series") > 0 && !IsLayoutSupported("Series"))
                    {
                        // Set First Supported Type
                        layouts = GetViewLayouts("Series");
                        if (layouts == null || layouts.Count == 0)
                        {
                            DBOption.SetOptions(DBOption.cViewSeriesListFormat, "WideBanners");
                        }
                        else
                        {
                            DBOption.SetOptions(DBOption.cViewSeriesListFormat, layouts[0]);
                        }
                    }
                }

                innerNode = node.SelectSingleNode("series/item1");
                if (innerNode != null)
                {
                    DBOption.SetOptions(DBOption.cViewSeriesColOne, innerNode.InnerText.Trim());
                }
                innerNode = node.SelectSingleNode("series/item2");
                if (innerNode != null)
                {
                    DBOption.SetOptions(DBOption.cViewSeriesColTwo, innerNode.InnerText.Trim());
                }
                innerNode = node.SelectSingleNode("series/item3");
                if (innerNode != null)
                {
                    DBOption.SetOptions(DBOption.cViewSeriesColThree, innerNode.InnerText.Trim());
                }
                #endregion

                #region Season Views
                innerNode = node.SelectSingleNode("season");
                if (innerNode != null)
                {
                    MPTVSeriesLog.Write("Loading Skin Season View Settings", MPTVSeriesLog.LogLevel.Normal);

                    if (GetLayoutCount("Season") == 0)
                    {
                        layout = innerNode.Attributes.GetNamedItem("layout").Value;
                        switch (layout.ToLower())
                        {
                        case "list":
                            DBOption.SetOptions(DBOption.cViewSeasonListFormat, "0");
                            break;

                        case "smallicons":
                        case "bigicons":
                        case "filmstrip":
                            DBOption.SetOptions(DBOption.cViewSeasonListFormat, "1");
                            break;

                        case "coverflow":
                            DBOption.SetOptions(DBOption.cViewSeasonListFormat, "2");
                            break;

                        default:
                            DBOption.SetOptions(DBOption.cViewSeasonListFormat, "0");
                            break;
                        }
                    }
                    // Confirm that the current layout is really supported
                    // May have come from another skin that used an unsupported layout for this skin
                    if (GetLayoutCount("Season") > 0 && !IsLayoutSupported("Season"))
                    {
                        // Set First Supported Type
                        layouts = GetViewLayouts("Season");
                        if (layouts == null || layouts.Count == 0)
                        {
                            DBOption.SetOptions(DBOption.cViewSeasonListFormat, "0");
                        }
                        else
                        {
                            DBOption.SetOptions(DBOption.cViewSeasonListFormat, layouts[0]);
                        }
                    }
                }

                innerNode = node.SelectSingleNode("season/item1");
                if (innerNode != null)
                {
                    DBOption.SetOptions(DBOption.cViewSeasonColOne, innerNode.InnerText.Trim());
                }
                innerNode = node.SelectSingleNode("season/item2");
                if (innerNode != null)
                {
                    DBOption.SetOptions(DBOption.cViewSeasonColTwo, innerNode.InnerText.Trim());
                }
                innerNode = node.SelectSingleNode("season/item3");
                if (innerNode != null)
                {
                    DBOption.SetOptions(DBOption.cViewSeasonColThree, innerNode.InnerText.Trim());
                }
                #endregion

                #region Episode Views
                MPTVSeriesLog.Write("Loading Skin Episode View Settings", MPTVSeriesLog.LogLevel.Normal);

                innerNode = node.SelectSingleNode("episode/item1");
                if (innerNode != null)
                {
                    DBOption.SetOptions(DBOption.cViewEpisodeColOne, innerNode.InnerText.Trim());
                }
                innerNode = node.SelectSingleNode("episode/item2");
                if (innerNode != null)
                {
                    DBOption.SetOptions(DBOption.cViewEpisodeColTwo, innerNode.InnerText.Trim());
                }
                innerNode = node.SelectSingleNode("episode/item3");
                if (innerNode != null)
                {
                    DBOption.SetOptions(DBOption.cViewEpisodeColThree, innerNode.InnerText.Trim());
                }
                #endregion

                ImportViews = true;
            }
        }
Ejemplo n.º 12
0
        static DBReplacements()
        {
            s_FieldToDisplayNameMap.Add(cEnabled, "Enabled");
            s_FieldToDisplayNameMap.Add(cTagEnabled, "Used As Tag");
            s_FieldToDisplayNameMap.Add(cBefore, "Run before matching");
            s_FieldToDisplayNameMap.Add(cToReplace, "Replace this..");
            s_FieldToDisplayNameMap.Add(cWith, "With this");
            s_FieldToDisplayNameMap.Add(cIsRegex, "Is Regex");

            DBReplacements dummy = new DBReplacements();

            int nCurrentDBVersion = cDBVersion;
            int nUpgradeDBVersion = DBOption.GetOptions(DBOption.cDBReplacementsVersion);

            while (nUpgradeDBVersion != nCurrentDBVersion)
            // take care of the upgrade in the table
            {
                DBReplacements replacement = new DBReplacements();
                switch (nUpgradeDBVersion)
                {
                case 2:
                    //Add tagEnabled colum
                    DBReplacements.GlobalSet(new DBReplacements(), DBReplacements.cTagEnabled, new DBValue(0), new SQLCondition());

                    replacement = new DBReplacements(3);
                    replacement[DBReplacements.cTagEnabled] = 1;
                    replacement.Commit();

                    replacement = new DBReplacements(4);
                    replacement[DBReplacements.cTagEnabled] = 1;
                    replacement.Commit();

                    replacement = new DBReplacements(5);
                    replacement[DBReplacements.cTagEnabled] = 1;
                    replacement.Commit();

                    //adding new replacement
                    DBReplacements[] replacements = DBReplacements.GetAll();

                    replacement = new DBReplacements();
                    replacement[DBReplacements.cIndex]      = replacements.Length;
                    replacement[DBReplacements.cEnabled]    = 1;
                    replacement[DBReplacements.cTagEnabled] = 1;
                    replacement[DBReplacements.cBefore]     = "0";
                    replacement[DBReplacements.cToReplace]  = "DSR";
                    replacement[DBReplacements.cWith]       = @"<empty>";
                    try
                    {
                        replacement.Commit();
                    }
                    catch (Exception) { }

                    replacement = new DBReplacements();
                    replacement[DBReplacements.cIndex]      = replacements.Length + 1;
                    replacement[DBReplacements.cEnabled]    = 1;
                    replacement[DBReplacements.cTagEnabled] = 1;
                    replacement[DBReplacements.cBefore]     = "0";
                    replacement[DBReplacements.cToReplace]  = "HR-HDTV";
                    replacement[DBReplacements.cWith]       = @"<empty>";
                    try
                    {
                        replacement.Commit();
                    }
                    catch (Exception) { }

                    replacement = new DBReplacements();
                    replacement[DBReplacements.cIndex]      = replacements.Length + 2;
                    replacement[DBReplacements.cEnabled]    = 1;
                    replacement[DBReplacements.cTagEnabled] = 1;
                    replacement[DBReplacements.cBefore]     = "0";
                    replacement[DBReplacements.cToReplace]  = "HR.HDTV";
                    replacement[DBReplacements.cWith]       = @"<empty>";
                    try
                    {
                        replacement.Commit();
                    }
                    catch (Exception) { }

                    replacement = new DBReplacements();
                    replacement[DBReplacements.cIndex]      = replacements.Length + 3;
                    replacement[DBReplacements.cEnabled]    = 1;
                    replacement[DBReplacements.cTagEnabled] = 1;
                    replacement[DBReplacements.cBefore]     = "0";
                    replacement[DBReplacements.cToReplace]  = "HDTV";
                    replacement[DBReplacements.cWith]       = @"<empty>";
                    try
                    {
                        replacement.Commit();
                    }
                    catch (Exception) { }

                    replacement = new DBReplacements();
                    replacement[DBReplacements.cIndex]      = replacements.Length + 4;
                    replacement[DBReplacements.cEnabled]    = 1;
                    replacement[DBReplacements.cTagEnabled] = 1;
                    replacement[DBReplacements.cBefore]     = "0";
                    replacement[DBReplacements.cToReplace]  = "DVDMux";
                    replacement[DBReplacements.cWith]       = @"<empty>";
                    try
                    {
                        replacement.Commit();
                    }
                    catch (Exception) { }

                    nUpgradeDBVersion++;
                    break;

                case 3:
                    //Disable regex setting for all
                    DBReplacements.GlobalSet(new DBReplacements(), DBReplacements.cIsRegex, new DBValue(0), new SQLCondition());
                    nUpgradeDBVersion++;
                    break;

                case 4:
                    // add the part/roman stuff - defaults for comments
                    var newIndex = DBReplacements.GetAll().Length;
                    replacement = new DBReplacements();
                    replacement[DBReplacements.cIndex]      = newIndex++;
                    replacement[DBReplacements.cEnabled]    = 1;
                    replacement[DBReplacements.cTagEnabled] = 0;
                    replacement[DBReplacements.cBefore]     = "1";
                    replacement[DBReplacements.cToReplace]  = @"(?<=(\s?\.?P[ar]*t\s?)) (X)?(IX|IV|V?I{0,3})";
                    replacement[DBReplacements.cWith]       = @"<RomanToArabic>";
                    try
                    {
                        replacement.Commit();
                    }
                    catch (Exception) { }

                    replacement = new DBReplacements();
                    replacement[DBReplacements.cIndex]      = newIndex++;
                    replacement[DBReplacements.cEnabled]    = 1;
                    replacement[DBReplacements.cTagEnabled] = 0;
                    replacement[DBReplacements.cBefore]     = "1";
                    replacement[DBReplacements.cToReplace]  = @"(?<!(?:S\d+.?E\\d+\-E\d+.*|S\d+.?E\d+.*|\s\d+x\d+.*))P[ar]*t\s?(\d+)(\s?of\s\d{1,2})?";
                    replacement[DBReplacements.cWith]       = @" S01E${1} ";
                    try
                    {
                        replacement.Commit();
                    }
                    catch (Exception) { }

                    replacement = new DBReplacements();
                    replacement[DBReplacements.cIndex]      = newIndex++;
                    replacement[DBReplacements.cEnabled]    = 1;
                    replacement[DBReplacements.cTagEnabled] = 0;
                    replacement[DBReplacements.cBefore]     = "1";
                    replacement[DBReplacements.cToReplace]  = @"(?<!(?:S\d+.?E\\d+\-E\d+.*|S\d+.?E\d+.*|\s\d+x\d+\s.*))(\d{1,2})\s?of\s\d{1,2}";
                    replacement[DBReplacements.cWith]       = @" S01E${1} ";
                    replacement[DBReplacements.cIsRegex]    = true;
                    try
                    {
                        replacement.Commit();
                    }
                    catch (Exception) { }

                    nUpgradeDBVersion++;
                    break;

                case 5:
                    newIndex = DBReplacements.GetAll().Length;

                    replacement = new DBReplacements();
                    replacement[DBReplacements.cIndex]      = newIndex++;
                    replacement[DBReplacements.cEnabled]    = 1;
                    replacement[DBReplacements.cTagEnabled] = 0;
                    replacement[DBReplacements.cBefore]     = "1";
                    replacement[DBReplacements.cToReplace]  = @"(?-i)([A-Z])\.(?=[A-Z])";
                    replacement[DBReplacements.cWith]       = @"${1}";
                    replacement[DBReplacements.cIsRegex]    = true;
                    try
                    {
                        replacement.Commit();
                    }
                    catch (Exception) { }

                    replacement = new DBReplacements();
                    replacement[DBReplacements.cIndex]      = newIndex++;
                    replacement[DBReplacements.cEnabled]    = 1;
                    replacement[DBReplacements.cTagEnabled] = 0;
                    replacement[DBReplacements.cBefore]     = "0";
                    replacement[DBReplacements.cToReplace]  = "<space><space>";
                    replacement[DBReplacements.cWith]       = @"<space>";
                    replacement[DBReplacements.cIsRegex]    = false;
                    try
                    {
                        replacement.Commit();
                    }
                    catch (Exception) { }

                    nUpgradeDBVersion++;
                    break;

                default:
                {
                    // no replacements in the db => put the default ones
                    AddDefaults();

                    nUpgradeDBVersion = 6;
                }
                break;
                }
            }

            DBOption.SetOptions(DBOption.cDBReplacementsVersion, nCurrentDBVersion);
        }
Ejemplo n.º 13
0
        public static void Init()
        {
            if (!DBOption.GetOptions(DBOption.cNewAPIUpgradeDone)) // upgrade
            {
                String sqlDel = "drop table if exists " + cTableName;
                DBTVSeries.Execute(sqlDel);
            }

            if (String.IsNullOrEmpty(cApiKey))
            {
                MPTVSeriesLog.Write("No APIKey...if you compile yourself you need to register an APIKey at theTVDB.com and add it to the resourceFile, nothing will be downloaded!");
                return;
            }

            // no mirrors yet - refresh using "seed"
            IsMirrorsAvailable = true;
            string sMirror = DBOption.GetOptions(DBOption.cMainMirror).ToString().Replace("http://", "https://");

            if (!LoadMirrorList(sMirror))
            {
                IsMirrorsAvailable = false;
                // Try again using the Hardcoded mirror
                if (!sMirror.Equals(DBOption.cMainMirrorHardCoded))
                {
                    MPTVSeriesLog.Write("Attempting to retrieve Mirrors from default location");
                    if (LoadMirrorList(DBOption.cMainMirrorHardCoded))
                    {
                        DBOption.SetOptions(DBOption.cMainMirror, DBOption.cMainMirrorHardCoded);
                        IsMirrorsAvailable = true;
                    }
                }
                if (!IsMirrorsAvailable)
                {
                    MPTVSeriesLog.Write("Warning: No mirrors received, nothing will be downloaded!");
                    return;
                }
            }

            //This is now handled server-side using mod_rewrite and round-robin DNS,
            //so the mirrors file is somewhat deprecated.

            var xmlMirrors    = new List <DBOnlineMirror>(mMemoryMirrors);
            var zipMirrors    = new List <DBOnlineMirror>(mMemoryMirrors);
            var bannerMirrors = new List <DBOnlineMirror>(mMemoryMirrors);

            // seperate them by which one can do what
            CheckMirrorCapable(xmlMirrors, TypeMask.XML);
            CheckMirrorCapable(zipMirrors, TypeMask.Zip);
            CheckMirrorCapable(bannerMirrors, TypeMask.Banners);

            // select a random one for each of them
            var r = new Random();

            if (xmlMirrors.Count > 0)
            {
                mCurrentInterface = xmlMirrors[r.Next(xmlMirrors.Count)][cMirrorpath].ToString().Replace("http://", "https://");
            }
            if (zipMirrors.Count > 0)
            {
                mCurrentZip = zipMirrors[r.Next(zipMirrors.Count)][cMirrorpath].ToString().Replace("http://", "https://") + "/";
            }
            if (bannerMirrors.Count > 0)
            {
                mCurrentBanner = bannerMirrors[r.Next(bannerMirrors.Count)][cMirrorpath].ToString().Replace("http://", "https://") + "/banners/";
            }
        }