示例#1
0
 private void SetDefaults()
 {
     ManualFolderLocations = new Dictionary <int, List <string> >();
     IgnoreSeasons         = new List <int>();
     UseCustomShowName     = false;
     CustomShowName        = "";
     UseCustomLanguage     = false;
     UseSequentialMatch    = false;
     SeasonRules           = new Dictionary <int, List <ShowRule> >();
     SeasonEpisodes        = new Dictionary <int, List <ProcessedEpisode> >();
     ShowNextAirdate       = true;
     TvdbCode                      = -1;
     AutoAddFolderBase             = "";
     AutoAddCustomFolderFormat     = CustomSeasonName.DefaultStyle();
     AutoAddType                   = AutomaticFolderType.libraryDefault;
     DoRename                      = true;
     DoMissingCheck                = true;
     CountSpecials                 = false;
     DvdOrder                      = false;
     CustomSearchUrl               = "";
     UseCustomSearchUrl            = false;
     ForceCheckNoAirdate           = false;
     ForceCheckFuture              = false;
     ManualFoldersReplaceAutomatic = false;
     BannersLastUpdatedOnDisk      = null;                             //assume that the banners are old and have expired
     ShowTimeZone                  = TimeZoneHelper.DefaultTimeZone(); // default, is correct for most shows
     lastFiguredTz                 = "";
 }
示例#2
0
        public ShowConfiguration()
        {
            ManualFolderLocations = new ConcurrentDictionary <int, List <string> >();
            SeasonRules           = new ConcurrentDictionary <int, List <ShowRule> >();
            SeasonEpisodes        = new ConcurrentDictionary <int, List <ProcessedEpisode> >();
            airedSeasons          = new ConcurrentDictionary <int, ProcessedSeason>();
            dvdSeasons            = new ConcurrentDictionary <int, ProcessedSeason>();
            IgnoreSeasons         = new List <int>();

            UseCustomRegion  = false;
            CustomRegionCode = string.Empty;

            UseCustomShowName             = false;
            CustomShowName                = string.Empty;
            UseCustomLanguage             = false;
            TvdbCode                      = -1;
            TVmazeCode                    = -1;
            TmdbCode                      = -1;
            UseCustomSearchUrl            = false;
            CustomSearchUrl               = string.Empty;
            UseCustomNamingFormat         = false;
            CustomNamingFormat            = string.Empty;
            ManualFoldersReplaceAutomatic = false;
            BannersLastUpdatedOnDisk      = null;                                                                            //assume that the banners are old and have expired
            ShowTimeZone                  = TVSettings.Instance.DefaultShowTimezoneName ?? TimeZoneHelper.DefaultTimeZone(); // default, is correct for most shows
            lastFiguredTz                 = string.Empty;

            UseSequentialMatch  = TVSettings.Instance.DefShowSequentialMatching;
            UseAirDateMatch     = TVSettings.Instance.DefShowAirDateMatching;
            UseEpNameMatch      = TVSettings.Instance.DefShowEpNameMatching;
            ShowNextAirdate     = TVSettings.Instance.DefShowNextAirdate;
            DoRename            = TVSettings.Instance.DefShowDoRenaming;
            DoMissingCheck      = TVSettings.Instance.DefShowDoMissingCheck;
            CountSpecials       = TVSettings.Instance.DefShowSpecialsCount;
            DvdOrder            = TVSettings.Instance.DefShowDVDOrder;
            ForceCheckNoAirdate = TVSettings.Instance.DefShowIncludeNoAirdate;
            ForceCheckFuture    = TVSettings.Instance.DefShowIncludeFuture;

            AutoAddCustomFolderFormat = CustomSeasonName.DefaultStyle();

            AutoAddFolderBase =
                !TVSettings.Instance.DefShowAutoFolders ? string.Empty
                : !TVSettings.Instance.DefShowUseDefLocation ? string.Empty
                : TVSettings.Instance.DefShowLocation.EnsureEndsWithSeparator() + TVSettings.Instance.FilenameFriendly(FileHelper.MakeValidPath(ShowName));

            AutoAddType =
                !TVSettings.Instance.DefShowAutoFolders ? AutomaticFolderType.none
                : TVSettings.Instance.DefShowUseBase ? AutomaticFolderType.baseOnly
                : AutomaticFolderType.libraryDefault;
        }
示例#3
0
        public CustomNameTagsFloatingWindow(ProcessedSeason?pe)
        {
            InitializeComponent();

            foreach (string s in CustomSeasonName.TAGS)
            {
                string txt = s;
                if (pe != null)
                {
                    txt += " - " + CustomSeasonName.NameFor(pe, s);
                }

                label1.Text += txt + "\r\n";
            }
        }
示例#4
0
        private string AutoFolderNameForSeason(Season s)
        {
            string r = AutoAddFolderBase;

            if (string.IsNullOrEmpty(r))
            {
                return(string.Empty);
            }

            if (s is null)
            {
                return(string.Empty);
            }

            if (!r.EndsWith(System.IO.Path.DirectorySeparatorChar.ToString(), StringComparison.Ordinal))
            {
                r += System.IO.Path.DirectorySeparatorChar.ToString();
            }

            if (AutoAddType == AutomaticFolderType.none)
            {
                return(r);
            }

            if (AutoAddType == AutomaticFolderType.baseOnly)
            {
                return(r);
            }

            if (s.IsSpecial())
            {
                return(r + TVSettings.Instance.SpecialsFolderName);
            }

            if (AutoAddType == AutomaticFolderType.libraryDefault)
            {
                return(r + CustomSeasonName.NameFor(s, TVSettings.Instance.SeasonFolderFormat));
            }

            if (AutoAddType == AutomaticFolderType.custom)
            {
                return(r + CustomSeasonName.NameFor(s, AutoAddCustomFolderFormat));
            }

            return(r);
        }
示例#5
0
        private IEnumerable <string> GetSeasonWords()
        {
            //See https://github.com/TV-Rename/tvrename/issues/241 for background
            List <string> results = TVSettings.Instance.searchSeasonWordsArray.ToList();

            if (!TVSettings.Instance.ForceBulkAddToUseSettingsOnly)
            {
                IEnumerable <string> seasonWordsFromShows =
                    from si in Values select CustomSeasonName.GetTextFromPattern(si.AutoAddCustomFolderFormat);

                results = seasonWordsFromShows.Distinct().ToList();

                results.Add(TVSettings.Instance.defaultSeasonWord);
            }

            return(results.Where(t => !string.IsNullOrWhiteSpace(t)).Distinct());
        }
示例#6
0
        public AddEditShow([NotNull] ShowItem si)
        {
            selectedShow  = si;
            sampleSeason  = si.GetFirstAvailableSeason();
            sampleEpisode = si.GetFirstAvailableEpisode();
            InitializeComponent();

            lblSeasonWordPreview.Text      = TVSettings.Instance.SeasonFolderFormat + "-(" + CustomSeasonName.NameFor(si.GetFirstAvailableSeason(), TVSettings.Instance.SeasonFolderFormat) + ")";
            lblSeasonWordPreview.ForeColor = Color.DarkGray;

            SetupDropDowns(si);

            codeFinderForm =
                new TheTvdbCodeFinder(si.TvdbCode != -1 ? si.TvdbCode.ToString() : "")
            {
                Dock = DockStyle.Fill
            };

            pnlCF.SuspendLayout();
            pnlCF.Controls.Add(codeFinderForm);
            pnlCF.ResumeLayout();

            cntfw = null;
            chkCustomShowName.Checked = si.UseCustomShowName;
            if (chkCustomShowName.Checked)
            {
                txtCustomShowName.Text = si.CustomShowName;
            }

            chkCustomShowName_CheckedChanged(null, null);

            chkCustomLanguage.Checked = si.UseCustomLanguage;
            if (chkCustomLanguage.Checked)
            {
                Language languageFromCode = TheTVDB.Instance.LanguageList.GetLanguageFromCode(si.CustomLanguageCode);
                if (languageFromCode != null)
                {
                    cbLanguage.Text = languageFromCode.Name;
                }
            }

            chkCustomLanguage_CheckedChanged(null, null);

            cbSequentialMatching.Checked = si.UseSequentialMatch;
            chkShowNextAirdate.Checked   = si.ShowNextAirdate;
            chkSpecialsCount.Checked     = si.CountSpecials;
            txtBaseFolder.Text           = si.AutoAddFolderBase;

            cbDoRenaming.Checked     = si.DoRename;
            cbDoMissingCheck.Checked = si.DoMissingCheck;
            cbDoMissingCheck_CheckedChanged(null, null);

            SetAutoAdd(si);

            txtSeasonFormat.Text = si.AutoAddCustomFolderFormat;

            chkDVDOrder.Checked           = si.DvdOrder;
            cbIncludeFuture.Checked       = si.ForceCheckFuture;
            cbIncludeNoAirdate.Checked    = si.ForceCheckNoAirdate;
            chkReplaceAutoFolders.Checked = si.ManualFoldersReplaceAutomatic;

            SetIgnoreSeasons(si);

            SetManualFolders(si);

            txtSeasonNumber_TextChanged(null, null);
            txtFolder_TextChanged();

            ActiveControl = codeFinderForm; // set initial focus to the code entry/show finder control

            foreach (string aliasName in selectedShow.AliasNames)
            {
                lbShowAlias.Items.Add(aliasName);
            }

            SetTagListText();

            cbUseCustomSearch.Checked = si.UseCustomSearchUrl && !string.IsNullOrWhiteSpace(si.CustomSearchUrl);
            txtSearchURL.Text         = si.CustomSearchUrl ?? "";
            EnableDisableCustomSearch();
        }
示例#7
0
        public ShowItem([NotNull] XElement xmlSettings)
        {
            SetDefaults();

            CustomShowName                = xmlSettings.ExtractString("ShowName");
            UseCustomShowName             = xmlSettings.ExtractBool("UseCustomShowName", false);
            UseCustomLanguage             = xmlSettings.ExtractBool("UseCustomLanguage", false);
            CustomLanguageCode            = xmlSettings.ExtractString("CustomLanguageCode");
            CustomShowName                = xmlSettings.ExtractString("CustomShowName");
            TvdbCode                      = xmlSettings.ExtractInt("TVDBID", -1);
            CountSpecials                 = xmlSettings.ExtractBool("CountSpecials", false);
            ShowNextAirdate               = xmlSettings.ExtractBool("ShowNextAirdate", true);
            AutoAddFolderBase             = xmlSettings.ExtractString("FolderBase");
            DoRename                      = xmlSettings.ExtractBool("DoRename", true);
            DoMissingCheck                = xmlSettings.ExtractBool("DoMissingCheck", true);
            DvdOrder                      = xmlSettings.ExtractBool("DVDOrder", false);
            UseCustomSearchUrl            = xmlSettings.ExtractBool("UseCustomSearchURL", false);
            CustomSearchUrl               = xmlSettings.ExtractString("CustomSearchURL");
            ShowTimeZone                  = xmlSettings.ExtractString("TimeZone") ?? TimeZoneHelper.DefaultTimeZone(); // default, is correct for most shows;
            ForceCheckFuture              = xmlSettings.ExtractBoolBackupDefault("ForceCheckFuture", "ForceCheckAll", false);
            ForceCheckNoAirdate           = xmlSettings.ExtractBoolBackupDefault("ForceCheckNoAirdate", "ForceCheckAll", false);
            AutoAddCustomFolderFormat     = xmlSettings.ExtractString("CustomFolderFormat") ?? CustomSeasonName.DefaultStyle();
            AutoAddType                   = GetAutoAddType(xmlSettings.ExtractInt("AutoAddType"));
            BannersLastUpdatedOnDisk      = xmlSettings.ExtractDateTime("BannersLastUpdatedOnDisk");
            UseSequentialMatch            = xmlSettings.ExtractBool("UseSequentialMatch", false);
            ManualFoldersReplaceAutomatic = xmlSettings.ExtractBool("ManualFoldersReplaceAutomatic", false);

            SetupIgnoreRules(xmlSettings);
            SetupAliases(xmlSettings);
            SetupSeasonRules(xmlSettings);
            SetupSeasonFolders(xmlSettings);
            UpgradeFromOldSeasonFormat(xmlSettings);
        }
示例#8
0
        public AddEditShow([NotNull] ShowConfiguration si, TVDoc doc)
        {
            selectedShow          = si;
            mDoc                  = doc;
            sampleProcessedSeason = si.GetFirstAvailableSeason();
            sampleEpisode         = si.GetFirstAvailableEpisode();
            addingNewShow         = (si.TvdbCode == -1 && si.TmdbCode == -1 && si.TVmazeCode == -1);
            InitializeComponent();

            if (sampleProcessedSeason != null)
            {
                lblSeasonWordPreview.Text = TVSettings.Instance.SeasonFolderFormat + "-(" +
                                            CustomSeasonName.NameFor(sampleProcessedSeason,
                                                                     TVSettings.Instance.SeasonFolderFormat) + ")";
            }
            else
            {
                lblSeasonWordPreview.Text = TVSettings.Instance.SeasonFolderFormat;
            }

            lblSeasonWordPreview.ForeColor = Color.DarkGray;

            SetupDropDowns(si);

            codeFinderForm = new CombinedCodeFinder(si.Code != -1 ? si.Code.ToString() : "", MediaConfiguration.MediaType.tv, si.Provider)
            {
                Dock = DockStyle.Fill
            };

            codeFinderForm.SelectionChanged += MTCCF_SelectionChanged;

            pnlCF.SuspendLayout();
            pnlCF.Controls.Add(codeFinderForm);
            pnlCF.ResumeLayout();

            cntfw = null;
            chkCustomShowName.Checked = si.UseCustomShowName;
            if (chkCustomShowName.Checked)
            {
                txtCustomShowName.Text = si.CustomShowName;
            }

            UpdateCustomShowNameEnabled();

            SetupLanguages(si);

            cbSequentialMatching.Checked = si.UseSequentialMatch;
            cbAirdateMatching.Checked    = si.UseAirDateMatch;
            cbEpNameMatching.Checked     = si.UseEpNameMatch;

            chkShowNextAirdate.Checked = si.ShowNextAirdate;
            chkSpecialsCount.Checked   = si.CountSpecials;
            txtBaseFolder.Text         = si.AutoAddFolderBase;

            cbDoRenaming.Checked     = si.DoRename;
            cbDoMissingCheck.Checked = si.DoMissingCheck;
            cbDoMissingCheck_CheckedChanged(null, null);

            SetAutoAdd(si);
            SetProvider(si);

            txtSeasonFormat.Text = si.AutoAddCustomFolderFormat;

            chkDVDOrder.Checked           = si.DvdOrder;
            cbIncludeFuture.Checked       = si.ForceCheckFuture;
            cbIncludeNoAirdate.Checked    = si.ForceCheckNoAirdate;
            chkReplaceAutoFolders.Checked = si.ManualFoldersReplaceAutomatic;

            SetIgnoreSeasons(si);

            SetManualFolders(si);

            CheckToEnableAddButton();
            txtFolder_TextChanged();

            ActiveControl = codeFinderForm; // set initial focus to the code entry/show finder control

            PopulateAliasses();
            SetTagListText();

            cbUseCustomSearch.Checked       = si.UseCustomSearchUrl && !string.IsNullOrWhiteSpace(si.CustomSearchUrl);
            cbUseCustomNamingFormat.Checked = si.UseCustomNamingFormat && !string.IsNullOrWhiteSpace(si.CustomNamingFormat);

            txtSearchURL.Text = si.CustomSearchUrl;
            txtCustomEpisodeNamingFormat.Text = si.CustomNamingFormat;

            EnableDisableCustomSearch();
            EnableDisableCustomNaming();
            UpdateIgnore();
        }
示例#9
0
        public AddEditShow(ShowItem si)
        {
            selectedShow = si;
            sampleSeason = si.GetFirstAvailableSeason();
            InitializeComponent();

            lblSeasonWordPreview.Text      = TVSettings.Instance.SeasonFolderFormat + "-(" + CustomSeasonName.NameFor(si.GetFirstAvailableSeason(), TVSettings.Instance.SeasonFolderFormat) + ")";
            lblSeasonWordPreview.ForeColor = Color.DarkGray;

            SetupDropDowns(si);

            codeFinderForm =
                new TheTvdbCodeFinder(si.TvdbCode != -1 ? si.TvdbCode.ToString() : "")
            {
                Dock = DockStyle.Fill
            };

            pnlCF.SuspendLayout();
            pnlCF.Controls.Add(codeFinderForm);
            pnlCF.ResumeLayout();

            cntfw = null;
            chkCustomShowName.Checked = si.UseCustomShowName;
            if (chkCustomShowName.Checked)
            {
                txtCustomShowName.Text = si.CustomShowName;
            }
            chkCustomShowName_CheckedChanged(null, null);

            chkCustomLanguage.Checked = si.UseCustomLanguage;
            if (chkCustomLanguage.Checked)
            {
                cbLanguage.Text = TheTVDB.Instance.LanguageList.GetLanguageFromCode(si.CustomLanguageCode).Name;
            }
            chkCustomLanguage_CheckedChanged(null, null);

            cbSequentialMatching.Checked = si.UseSequentialMatch;
            chkShowNextAirdate.Checked   = si.ShowNextAirdate;
            chkSpecialsCount.Checked     = si.CountSpecials;
            txtBaseFolder.Text           = si.AutoAddFolderBase;

            cbDoRenaming.Checked     = si.DoRename;
            cbDoMissingCheck.Checked = si.DoMissingCheck;
            cbDoMissingCheck_CheckedChanged(null, null);

            switch (si.AutoAddType)
            {
            case ShowItem.AutomaticFolderType.none:
                chkAutoFolders.Checked = false;
                break;

            case ShowItem.AutomaticFolderType.baseOnly:
                chkAutoFolders.Checked    = true;
                rdoFolderBaseOnly.Checked = true;
                break;

            case ShowItem.AutomaticFolderType.custom:
                chkAutoFolders.Checked  = true;
                rdoFolderCustom.Checked = true;
                break;

            case ShowItem.AutomaticFolderType.libraryDefault:
            default:
                chkAutoFolders.Checked          = true;
                rdoFolderLibraryDefault.Checked = true;
                break;
            }

            txtSeasonFormat.Text = si.AutoAddCustomFolderFormat;

            chkDVDOrder.Checked        = si.DvdOrder;
            cbIncludeFuture.Checked    = si.ForceCheckFuture;
            cbIncludeNoAirdate.Checked = si.ForceCheckNoAirdate;

            bool first = true;

            si.IgnoreSeasons.Sort();
            foreach (int i in si.IgnoreSeasons)
            {
                if (!first)
                {
                    txtIgnoreSeasons.Text += " ";
                }
                txtIgnoreSeasons.Text += i.ToString();
                first = false;
            }

            foreach (KeyValuePair <int, List <string> > kvp in si.ManualFolderLocations)
            {
                foreach (string s in kvp.Value)
                {
                    ListViewItem lvi = new ListViewItem {
                        Text = kvp.Key.ToString()
                    };
                    lvi.SubItems.Add(s);

                    lvSeasonFolders.Items.Add(lvi);
                }
            }
            lvSeasonFolders.Sort();

            txtSeasonNumber_TextChanged(null, null);
            txtFolder_TextChanged();

            ActiveControl = codeFinderForm; // set initial focus to the code entry/show finder control

            foreach (string aliasName in selectedShow.AliasNames)
            {
                lbShowAlias.Items.Add(aliasName);
            }

            StringBuilder tl = new StringBuilder();

            foreach (string s in CustomEpisodeName.TAGS)
            {
                tl.AppendLine(s);
            }
            txtTagList.Text = tl.ToString();

            cbUseCustomSearch.Checked = si.UseCustomSearchUrl && !string.IsNullOrWhiteSpace(si.CustomSearchUrl);
            txtSearchURL.Text         = si.CustomSearchUrl ?? "";
            EnableDisableCustomSearch();
        }