Пример #1
0
        private void FigureOutTimeZone()
        {
            string tzstr = ShowTimeZone;

            if (string.IsNullOrEmpty(tzstr))
            {
                tzstr = TimeZoneHelper.DefaultTimeZone();
            }

            try
            {
                seriesTimeZone = TimeZoneInfo.FindSystemTimeZoneById(tzstr);
            }
            catch (Exception ex)
            {
                Logger.Warn(ex, $"Could not work out what timezone '{ShowName}' has. In the settings it uses '{tzstr}', but that is not valid. Please update. Using the default timezone {TimeZoneHelper.DefaultTimeZone()} for the show instead.");
                try
                {
                    tzstr          = TimeZoneHelper.DefaultTimeZone();
                    seriesTimeZone = TimeZoneInfo.FindSystemTimeZoneById(tzstr);
                }
                catch (Exception)
                {
                    Logger.Warn(ex, $"Could not work out what timezone '{ShowName}' has. In the settings it uses '{tzstr}', but that is not valid. Tried to use the default timezone {TimeZoneHelper.DefaultTimeZone()} for the show instead - also invalid.  Please update.");
                    seriesTimeZone = TimeZoneInfo.Local;
                }
            }

            lastFiguredTz = tzstr;
        }
Пример #2
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);
        }
Пример #3
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                 = "";
 }
Пример #4
0
        private static void ConvertSeriesTimeZones([NotNull] TVDoc doc, TheTVDB tvdb)
        {
            //this is just to convert timezones in the TheTVDB into the TVDOC where they should be:
            //it should only do anything the first time it is run and then be entirely benign
            //can be removed after 1/1/19

            foreach (ShowItem si in doc.Library.GetShowItems())
            {
                string newTimeZone = tvdb.GetSeries(si.TvdbCode)?.TempTimeZone;

                if (string.IsNullOrWhiteSpace(newTimeZone))
                {
                    continue;
                }

                if (newTimeZone == TimeZoneHelper.DefaultTimeZone())
                {
                    continue;
                }

                if (si.ShowTimeZone != TimeZoneHelper.DefaultTimeZone())
                {
                    continue;
                }

                si.ShowTimeZone = newTimeZone;
                doc.SetDirty();
                Logger.Info("Copied timezone:{0} onto series {1}", newTimeZone, si.ShowName);
            }
        }
Пример #5
0
        private DateTimeZone FigureOutTimeZone()
        {
            string tzstr = ShowTimeZone;

            if (string.IsNullOrEmpty(tzstr))
            {
                tzstr = TimeZoneHelper.DefaultTimeZone();
            }

            try
            {
                return(DateTimeZoneProviders.Tzdb[tzstr]);
            }
            catch (Exception ex)
            {
                LOGGER.Info($"Could not work out what timezone '{ShowName}' has. In the settings it uses '{tzstr}', Testing to see whether it needs to be upgraded: {ex.Message}");
                try
                {
                    tzstr         = TZConvert.WindowsToIana(tzstr);
                    ShowTimeZone  = tzstr;
                    lastFiguredTz = tzstr;
                    return(DateTimeZoneProviders.Tzdb[tzstr]);
                }
                catch (Exception ex2)
                {
                    LOGGER.Warn(ex2,
                                $"Could not work out what timezone '{ShowName}' has. In the settings it uses '{tzstr}', but that is not valid. Please update. Using the default timezone {TimeZoneHelper.DefaultTimeZone()} for the show instead.");

                    try
                    {
                        tzstr         = TimeZoneHelper.DefaultTimeZone();
                        ShowTimeZone  = tzstr;
                        lastFiguredTz = tzstr;
                        return(DateTimeZoneProviders.Tzdb[tzstr]);
                    }
                    catch (Exception ex3)
                    {
                        LOGGER.Warn(ex3,
                                    $"Could not work out what timezone '{ShowName}' has. In the settings it uses '{tzstr}', but that is not valid. Tried to use the default timezone {TimeZoneHelper.DefaultTimeZone()} for the show instead - also invalid.  Please update.");


                        ShowTimeZone  = DateTimeZoneProviders.Tzdb.GetSystemDefault().Id;
                        lastFiguredTz = tzstr;
                        return(DateTimeZoneProviders.Tzdb.GetSystemDefault());
                    }
                }
            }
        }
Пример #6
0
        private void SetDefaults()
        {
            ManualFolderLocations = new Dictionary <int, List <string> >();
            SeasonRules           = new Dictionary <int, List <ShowRule> >();
            SeasonEpisodes        = new Dictionary <int, List <ProcessedEpisode> >();
            IgnoreSeasons         = new List <int>();

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

            UseSequentialMatch  = TVSettings.Instance.DefShowSequentialMatching;
            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 + Path.DirectorySeparatorChar + TVSettings.Instance.FilenameFriendly(FileHelper.MakeValidPath(ShowName));

            AutoAddType =
                !TVSettings.Instance.DefShowAutoFolders ? AutomaticFolderType.none
                :TVSettings.Instance.DefShowUseBase ? AutomaticFolderType.baseOnly
                :AutomaticFolderType.libraryDefault;
        }
Пример #7
0
        private void SetShow()
        {
            int code = codeFinderForm.SelectedCode();

            selectedShow.CustomShowName    = txtCustomShowName.Text;
            selectedShow.UseCustomShowName = chkCustomShowName.Checked;
            selectedShow.UseCustomLanguage = chkCustomLanguage.Checked;
            if (selectedShow.UseCustomLanguage)
            {
                selectedShow.CustomLanguageCode = TheTVDB.Instance.LanguageList
                                                  .GetLanguageFromLocalName(cbLanguage.SelectedItem?.ToString())?.Abbreviation ?? TVSettings.Instance.PreferredLanguageCode;
            }
            selectedShow.ShowTimeZone              = cbTimeZone.SelectedItem?.ToString() ?? TimeZoneHelper.DefaultTimeZone();
            selectedShow.ShowNextAirdate           = chkShowNextAirdate.Checked;
            selectedShow.TvdbCode                  = code;
            selectedShow.CountSpecials             = chkSpecialsCount.Checked;
            selectedShow.DoRename                  = cbDoRenaming.Checked;
            selectedShow.DoMissingCheck            = cbDoMissingCheck.Checked;
            selectedShow.AutoAddCustomFolderFormat = txtSeasonFormat.Text;
            selectedShow.AutoAddFolderBase         = txtBaseFolder.Text;

            selectedShow.AutoAddType = GetAutoAddType();

            selectedShow.DvdOrder                      = chkDVDOrder.Checked;
            selectedShow.ForceCheckFuture              = cbIncludeFuture.Checked;
            selectedShow.ForceCheckNoAirdate           = cbIncludeNoAirdate.Checked;
            selectedShow.UseCustomSearchUrl            = cbUseCustomSearch.Checked;
            selectedShow.CustomSearchUrl               = txtSearchURL.Text;
            selectedShow.ManualFoldersReplaceAutomatic = chkReplaceAutoFolders.Checked;

            selectedShow.UseSequentialMatch = cbSequentialMatching.Checked;

            string slist = txtIgnoreSeasons.Text;

            selectedShow.IgnoreSeasons.Clear();
            foreach (Match match in Regex.Matches(slist, "\\b[0-9]+\\b"))
            {
                selectedShow.IgnoreSeasons.Add(int.Parse(match.Value));
            }

            selectedShow.ManualFolderLocations.Clear();
            foreach (ListViewItem lvi in lvSeasonFolders.Items)
            {
                try
                {
                    int seas = int.Parse(lvi.Text);
                    if (!selectedShow.ManualFolderLocations.ContainsKey(seas))
                    {
                        selectedShow.ManualFolderLocations.Add(seas, new List <string>());
                    }

                    selectedShow.ManualFolderLocations[seas].Add(lvi.SubItems[1].Text);
                }
                catch
                {
                    // ignored
                }
            }

            selectedShow.AliasNames.Clear();
            foreach (string showAlias in lbShowAlias.Items)
            {
                if (!selectedShow.AliasNames.Contains(showAlias))
                {
                    selectedShow.AliasNames.Add(showAlias);
                }
            }
        }
Пример #8
0
        private void SetShow()
        {
            int code = codeFinderForm.SelectedCode();

            selectedShow.CustomShowName    = txtCustomShowName.Text;
            selectedShow.UseCustomShowName = chkCustomShowName.Checked;
            selectedShow.UseCustomLanguage = chkCustomLanguage.Checked;
            if (selectedShow.UseCustomLanguage)
            {
                selectedShow.CustomLanguageCode = TheTVDB.LocalCache.Instance.LanguageList?.GetLanguageFromLocalName(cbLanguage.SelectedItem?.ToString())?.Abbreviation
                                                  ?? TVSettings.Instance.PreferredLanguageCode;
            }

            selectedShow.UseCustomRegion = chkCustomRegion.Checked;
            if (selectedShow.UseCustomRegion)
            {
                selectedShow.CustomRegionCode = TMDB.LocalCache.COUNTRIES
                                                .FirstOrDefault(x => x.Name == cbLanguage.SelectedItem?.ToString()).Code ?? TVSettings.Instance.TMDBRegion;
            }

            selectedShow.ShowTimeZone    = cbTimeZone.SelectedItem?.ToString() ?? TVSettings.Instance.DefaultShowTimezoneName ?? TimeZoneHelper.DefaultTimeZone();
            selectedShow.ShowNextAirdate = chkShowNextAirdate.Checked;

            selectedShow.SetId(GetProviderTypeInUse(), code);
            selectedShow.CountSpecials             = chkSpecialsCount.Checked;
            selectedShow.DoRename                  = cbDoRenaming.Checked;
            selectedShow.DoMissingCheck            = cbDoMissingCheck.Checked;
            selectedShow.AutoAddCustomFolderFormat = txtSeasonFormat.Text;
            selectedShow.AutoAddFolderBase         = txtBaseFolder.Text;

            selectedShow.AutoAddType           = GetAutoAddType();
            selectedShow.ConfigurationProvider = GetConfigurationProviderType();

            selectedShow.DvdOrder                      = chkDVDOrder.Checked;
            selectedShow.ForceCheckFuture              = cbIncludeFuture.Checked;
            selectedShow.ForceCheckNoAirdate           = cbIncludeNoAirdate.Checked;
            selectedShow.UseCustomSearchUrl            = cbUseCustomSearch.Checked;
            selectedShow.CustomSearchUrl               = txtSearchURL.Text;
            selectedShow.UseCustomNamingFormat         = cbUseCustomNamingFormat.Checked;
            selectedShow.CustomNamingFormat            = txtCustomEpisodeNamingFormat.Text;
            selectedShow.ManualFoldersReplaceAutomatic = chkReplaceAutoFolders.Checked;

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

            SetupDropDowns();
        }
Пример #9
0
        private void SetShow()
        {
            int code = codeFinderForm.SelectedCode();

            selectedShow.CustomShowName    = txtCustomShowName.Text;
            selectedShow.UseCustomShowName = chkCustomShowName.Checked;
            selectedShow.UseCustomLanguage = chkCustomLanguage.Checked;
            if (selectedShow.UseCustomLanguage)
            {
                selectedShow.CustomLanguageCode = TheTVDB.Instance.LanguageList
                                                  .GetLanguageFromLocalName(cbLanguage.SelectedItem?.ToString())?.Abbreviation ?? TVSettings.Instance.PreferredLanguageCode;
            }
            selectedShow.ShowTimeZone              = cbTimeZone.SelectedItem?.ToString() ?? TVSettings.Instance.DefaultShowTimezoneName ?? TimeZoneHelper.DefaultTimeZone();
            selectedShow.ShowNextAirdate           = chkShowNextAirdate.Checked;
            selectedShow.TvdbCode                  = code;
            selectedShow.CountSpecials             = chkSpecialsCount.Checked;
            selectedShow.DoRename                  = cbDoRenaming.Checked;
            selectedShow.DoMissingCheck            = cbDoMissingCheck.Checked;
            selectedShow.AutoAddCustomFolderFormat = txtSeasonFormat.Text;
            selectedShow.AutoAddFolderBase         = txtBaseFolder.Text;

            selectedShow.AutoAddType = GetAutoAddType();

            selectedShow.DvdOrder                      = chkDVDOrder.Checked;
            selectedShow.ForceCheckFuture              = cbIncludeFuture.Checked;
            selectedShow.ForceCheckNoAirdate           = cbIncludeNoAirdate.Checked;
            selectedShow.UseCustomSearchUrl            = cbUseCustomSearch.Checked;
            selectedShow.CustomSearchUrl               = txtSearchURL.Text;
            selectedShow.ManualFoldersReplaceAutomatic = chkReplaceAutoFolders.Checked;

            selectedShow.UseSequentialMatch = cbSequentialMatching.Checked;

            SetupDropDowns();
        }