diff --git a/TVRename/App/ApplicationBase.cs b/TVRename/App/ApplicationBase.cs index 5373395b..878d974e 100644 --- a/TVRename/App/ApplicationBase.cs +++ b/TVRename/App/ApplicationBase.cs @@ -54,9 +54,6 @@ protected override void OnCreateMainForm() SplashScreen.SafeInvoke( () => ((TVRenameSplash)SplashScreen).UpdateStatus("Initializing"), true); - // Update RegVersion to bring the WebBrowser up to speed - RegistryHelper.UpdateBrowserEmulationVersion(); - doc = LoadSettings(parameters); if (TVSettings.Instance.mode == TVSettings.BetaMode.BetaToo || TVSettings.Instance.ShareLogs) diff --git a/TVRename/Forms/Preferences/Preferences.cs b/TVRename/Forms/Preferences/Preferences.cs index 125c0a6a..c33de1cc 100644 --- a/TVRename/Forms/Preferences/Preferences.cs +++ b/TVRename/Forms/Preferences/Preferences.cs @@ -409,7 +409,7 @@ private void UpdateSettings() s.RemoveDownloadDirectoriesFiles = cbCleanUpDownloadDir.Checked; s.RemoveDownloadDirectoriesFilesMatchMovies = cbCleanUpDownloadDirMovies.Checked; s.RemoveDownloadDirectoriesFilesMatchMoviesLengthCheck = cbCleanUpDownloadDirMoviesLength.Checked; - int.TryParse(tbCleanUpDownloadDirMoviesLength.Text, out s.RemoveDownloadDirectoriesFilesMatchMoviesLengthCheckLength); + s.RemoveDownloadDirectoriesFilesMatchMoviesLengthCheckLength = tbCleanUpDownloadDirMoviesLength.Text.ToInt(8); s.DeleteShowFromDisk = cbDeleteShowFromDisk.Checked; s.DeleteMovieFromDisk = cbDeleteMovieFromDisk.Checked; @@ -431,7 +431,7 @@ private void UpdateSettings() s.Tidyup.EmptyIgnoreExtensions = cbEmptyIgnoreExtensions.Checked; s.Tidyup.EmptyIgnoreExtensionList = txtEmptyIgnoreExtensions.Text; s.Tidyup.EmptyMaxSizeCheck = cbEmptyMaxSize.Checked; - int.TryParse(txtEmptyMaxSize.Text, out s.Tidyup.EmptyMaxSizeMB); + s.Tidyup.EmptyMaxSizeMB = txtEmptyMaxSize.Text.ToInt(100); s.BulkAddCompareNoVideoFolders = cbIgnoreNoVideoFolders.Checked; s.BulkAddIgnoreRecycleBin = cbIgnoreRecycleBin.Checked; diff --git a/TVRename/Model/CachePersistor.cs b/TVRename/Model/CachePersistor.cs index 93850de1..5792b96f 100644 --- a/TVRename/Model/CachePersistor.cs +++ b/TVRename/Model/CachePersistor.cs @@ -105,42 +105,40 @@ private static void SaveCacheFileInternal(ConcurrentDictionary kvp in series) + foreach (KeyValuePair kvp in series) + { + if (kvp.Value.SrvLastUpdated != 0) { - if (kvp.Value.SrvLastUpdated != 0) - { - kvp.Value.WriteXml(writer); - } - else - { - Logger.Info( - $"Cannot save TV {kvp.Key} ({kvp.Value.Name}) to {cacheFile.Name} as it has not been updated at all."); - } + kvp.Value.WriteXml(writer); } + else + { + Logger.Info( + $"Cannot save TV {kvp.Key} ({kvp.Value.Name}) to {cacheFile.Name} as it has not been updated at all."); + } + } - foreach (KeyValuePair kvp in movies) + foreach (KeyValuePair kvp in movies) + { + if (!kvp.Value.IsSearchResultOnly) { - if (!kvp.Value.IsSearchResultOnly) - { - kvp.Value.WriteXml(writer); - } - else - { - Logger.Info( - $"Cannot save Movie {kvp.Key} ({kvp.Value.Name}) to {cacheFile.Name} as it is a search result that has not been used."); - } + kvp.Value.WriteXml(writer); } + else + { + Logger.Info( + $"Cannot save Movie {kvp.Key} ({kvp.Value.Name}) to {cacheFile.Name} as it is a search result that has not been used."); + } + } - writer.WriteEndElement(); // data + writer.WriteEndElement(); // data - writer.WriteEndDocument(); - } + writer.WriteEndDocument(); } public static bool LoadTvCache(FileInfo loadFrom, T cache) where T : MediaCache, iTVSource @@ -328,7 +326,7 @@ private static void ProcessXmlBannerCache(XElement r, iTVSource localCache) { int seriesId = bannersXml.ExtractInt("SeriesId") ?? -1; - localCache.GetSeries(seriesId)?.AddBanners(seriesId, bannersXml.Descendants("Banners").Descendants("Banner") + localCache.GetSeries(seriesId)?.AddBanners(bannersXml.Descendants("Banners").Descendants("Banner") .Select(banner => ShowImage.GenerateFromLegacyBannerXml(seriesId, banner, localCache.SourceProvider()))); } } diff --git a/TVRename/Model/CachedSeriesInfo.cs b/TVRename/Model/CachedSeriesInfo.cs index fbe43bb1..9224b678 100644 --- a/TVRename/Model/CachedSeriesInfo.cs +++ b/TVRename/Model/CachedSeriesInfo.cs @@ -209,7 +209,7 @@ private void LoadXml(XElement seriesXml) } } - internal void AddBanners(int seriesId, IEnumerable enumerable) + internal void AddBanners(IEnumerable enumerable) { foreach (ShowImage s in enumerable) { diff --git a/TVRename/ScanActivity/Finders/FinderHelper.cs b/TVRename/ScanActivity/Finders/FinderHelper.cs index 6b3d88bf..63bfeb9f 100644 --- a/TVRename/ScanActivity/Finders/FinderHelper.cs +++ b/TVRename/ScanActivity/Finders/FinderHelper.cs @@ -668,8 +668,7 @@ public static (string title, int? year) SplitIntoTitleYear(string hint) //Seems like we have a year in the date //Work out the year - int.TryParse(m.Groups[1].Value, out int year); - possibleYear = year; + possibleYear = m.Groups[1].Value.ToInt(); //remove year from string hint = Regex.Replace(hint.Trim(), PATTERN, " "); diff --git a/TVRename/Sources/MediaCache.cs b/TVRename/Sources/MediaCache.cs index 14c5f5e0..18639d2d 100644 --- a/TVRename/Sources/MediaCache.cs +++ b/TVRename/Sources/MediaCache.cs @@ -3,6 +3,7 @@ using System.Collections.Concurrent; using System.Collections.Generic; using System.Linq; +using System.Threading; namespace TVRename; @@ -151,4 +152,5 @@ public bool HasMovie(int id) public abstract int PrimaryKey(ISeriesSpecifier ss); public abstract string CacheSourceName(); public abstract void ReConnect(bool b); + public abstract bool GetUpdates(IEnumerable ss, bool showErrorMsgBox, CancellationToken cts); } diff --git a/TVRename/Sources/TMDB/LocalCache.cs b/TVRename/Sources/TMDB/LocalCache.cs index b3bc14d4..be6a3c0a 100644 --- a/TVRename/Sources/TMDB/LocalCache.cs +++ b/TVRename/Sources/TMDB/LocalCache.cs @@ -129,11 +129,11 @@ public override bool EnsureUpdated(ISeriesSpecifier s, bool bannersToo, bool sho } return s.Media == MediaConfiguration.MediaType.movie - ? EnsureMovieUpdated(s, showErrorMsgBox) - : EnsureSeriesUpdated(s, showErrorMsgBox); + ? EnsureMovieUpdated(s) + : EnsureSeriesUpdated(s); } - private bool EnsureSeriesUpdated(ISeriesSpecifier s, bool showErrorMsgBox) + private bool EnsureSeriesUpdated(ISeriesSpecifier s) { lock (SERIES_LOCK) { @@ -146,7 +146,7 @@ private bool EnsureSeriesUpdated(ISeriesSpecifier s, bool showErrorMsgBox) Say($"Series {s.Name} from TMDB"); try { - CachedSeriesInfo downloadedSi = DownloadSeriesNow(s, showErrorMsgBox); + CachedSeriesInfo downloadedSi = DownloadSeriesNow(s); if (downloadedSi.TmdbCode != s.TmdbId && s.TmdbId == -1) { @@ -185,7 +185,7 @@ private bool EnsureSeriesUpdated(ISeriesSpecifier s, bool showErrorMsgBox) return true; } - private bool EnsureMovieUpdated(ISeriesSpecifier id, bool showErrorMsgBox) + private bool EnsureMovieUpdated(ISeriesSpecifier id) { lock (MOVIE_LOCK) { @@ -198,7 +198,7 @@ private bool EnsureMovieUpdated(ISeriesSpecifier id, bool showErrorMsgBox) Say($"Movie: {id.Name} from TMDB"); try { - CachedMovieInfo downloadedSi = DownloadMovieNow(id, showErrorMsgBox); + CachedMovieInfo downloadedSi = DownloadMovieNow(id); if (downloadedSi.TmdbCode != id.TmdbId && id.TmdbId == -1) { @@ -228,7 +228,7 @@ private bool EnsureMovieUpdated(ISeriesSpecifier id, bool showErrorMsgBox) } } - public bool GetUpdates(IEnumerable ss, bool showErrorMsgBox, CancellationToken cts) + public override bool GetUpdates(IEnumerable ss, bool showErrorMsgBox, CancellationToken cts) { Say("Validating TMDB cache"); this.MarkPlaceHoldersDirty(ss); @@ -379,11 +379,11 @@ public void LatestUpdateTimeIs(string time) public override TVDoc.ProviderType Provider() => TVDoc.ProviderType.TMDB; - public CachedMovieInfo GetMovieAndDownload(ISeriesSpecifier id, bool showErrorMsgBox) => HasMovie(id.TmdbId) + public CachedMovieInfo GetMovieAndDownload(ISeriesSpecifier id) => HasMovie(id.TmdbId) ? CachedMovieData[id.TmdbId] - : DownloadMovieNow(id, showErrorMsgBox); + : DownloadMovieNow(id); - internal CachedMovieInfo DownloadMovieNow(ISeriesSpecifier id, bool showErrorMsgBox,bool saveToCache = true) + internal CachedMovieInfo DownloadMovieNow(ISeriesSpecifier id,bool saveToCache = true) { string imageLanguage = $"{id.LanguageToUse().Abbreviation},null"; try @@ -547,7 +547,7 @@ private static void AddMovieImages(Movie downloadedMovie, CachedMovieInfo m) return null; } - internal CachedSeriesInfo DownloadSeriesNow(ISeriesSpecifier ss, bool showErrorMsgBox, bool saveToCache = true) + internal CachedSeriesInfo DownloadSeriesNow(ISeriesSpecifier ss, bool saveToCache = true) { int id = ss.TmdbId > 0 ? ss.TmdbId : GetSeriesIdFromOtherCodes(ss) ?? 0; @@ -832,11 +832,11 @@ public override void Search(string text, bool showErrorMsgBox, MediaConfiguratio switch (type) { case MediaConfiguration.MediaType.tv: - DownloadSeriesNow(ss, showErrorMsgBox); + DownloadSeriesNow(ss); break; case MediaConfiguration.MediaType.movie: - DownloadMovieNow(ss, showErrorMsgBox); + DownloadMovieNow(ss); break; } } @@ -952,14 +952,14 @@ private CachedMovieInfo File(SearchMovie result) return null; } - public CachedMovieInfo? LookupMovieByImdb(string imdbToTest, Locale locale, bool showErrorMsgBox) + public CachedMovieInfo? LookupMovieByImdb(string imdbToTest, Locale locale) { FindContainer? results = Client.FindAsync(FindExternalSource.Imdb, imdbToTest).Result; LOGGER.Info($"Got {results.MovieResults.Count:N0} results searching for {imdbToTest}"); foreach (SearchMovie result in results.MovieResults) { SearchSpecifier ss = new(result.Id, locale, TVDoc.ProviderType.TMDB, MediaConfiguration.MediaType.movie); - DownloadMovieNow(ss, showErrorMsgBox); + DownloadMovieNow(ss); } if (results.MovieResults.Count == 0) @@ -1015,14 +1015,14 @@ public Dictionary GetMovieIdsFromCollection(int collection return returnValue; } - public CachedMovieInfo? LookupMovieByTvdb(int tvdbId, bool showErrorMsgBox,Locale locale) + public CachedMovieInfo? LookupMovieByTvdb(int tvdbId,Locale locale) { FindContainer? results = Client.FindAsync(FindExternalSource.TvDb, tvdbId.ToString()).Result; LOGGER.Info($"Got {results.MovieResults.Count:N0} results searching for {tvdbId}"); foreach (SearchMovie result in results.MovieResults) { SearchSpecifier ss = new(result.Id, locale, TVDoc.ProviderType.TMDB, MediaConfiguration.MediaType.movie); - DownloadMovieNow(ss, showErrorMsgBox); + DownloadMovieNow(ss); } if (results.MovieResults.Count == 0) diff --git a/TVRename/Sources/TMDB/TmdbAccuracyCheck.cs b/TVRename/Sources/TMDB/TmdbAccuracyCheck.cs index 677db590..73a573b3 100644 --- a/TVRename/Sources/TMDB/TmdbAccuracyCheck.cs +++ b/TVRename/Sources/TMDB/TmdbAccuracyCheck.cs @@ -25,7 +25,7 @@ public void ServerAccuracyCheck(CachedMovieInfo si) Logger.Info($"Accuracy Check for {si.Name} on TMDB"); try { - CachedMovieInfo newSi = lc.DownloadMovieNow(si, false,false); + CachedMovieInfo newSi = lc.DownloadMovieNow(si,false); if (!Match(newSi, si)) { @@ -49,7 +49,7 @@ public void ServerAccuracyCheck(CachedSeriesInfo si) Logger.Info($"Accuracy Check for {si.Name} on TMDB"); try { - CachedSeriesInfo newSi = lc.DownloadSeriesNow(si, false,false); + CachedSeriesInfo newSi = lc.DownloadSeriesNow(si,false); if (!Match(newSi, si)) //NB - we use a match method as we can't rely on update time { @@ -68,7 +68,7 @@ public void ServerAccuracyCheck(CachedSeriesInfo si) } } - private bool Match(CachedMovieInfo newSi, CachedMovieInfo si) + private static bool Match(CachedMovieInfo newSi, CachedMovieInfo si) { if (newSi.CollectionName != si.CollectionName) { @@ -103,7 +103,7 @@ private bool Match(CachedMovieInfo newSi, CachedMovieInfo si) return true; } - private bool Match(CachedSeriesInfo newSi, CachedSeriesInfo si) + private static bool Match(CachedSeriesInfo newSi, CachedSeriesInfo si) { if (newSi.Name != si.Name) { diff --git a/TVRename/Sources/TVMAZE/LocalCache.cs b/TVRename/Sources/TVMAZE/LocalCache.cs index 5c0c9e2b..0edb14bf 100644 --- a/TVRename/Sources/TVMAZE/LocalCache.cs +++ b/TVRename/Sources/TVMAZE/LocalCache.cs @@ -116,7 +116,7 @@ public override bool EnsureUpdated(ISeriesSpecifier s, bool bannersToo, bool sho return true; } - public bool GetUpdates(IEnumerable ss, bool showErrorMsgBox, CancellationToken cts) + public override bool GetUpdates(IEnumerable ss, bool showErrorMsgBox, CancellationToken cts) { Say("Validating TVmaze cache"); foreach (ISeriesSpecifier downloadShow in ss.Where(downloadShow => !HasSeries(downloadShow.TvMazeId))) diff --git a/TVRename/Sources/TheTVDB/LocalCache.cs b/TVRename/Sources/TheTVDB/LocalCache.cs index 0e12680e..b31b85cb 100644 --- a/TVRename/Sources/TheTVDB/LocalCache.cs +++ b/TVRename/Sources/TheTVDB/LocalCache.cs @@ -288,7 +288,7 @@ private void HandleConnectionProblem(bool showErrorMsgBox, Exception ex) } } - public bool GetUpdates(bool showErrorMsgBox, IEnumerable ss, CancellationToken cts) + public override bool GetUpdates(IEnumerable ss, bool showErrorMsgBox, CancellationToken cts) { Say("Validating TheTVDB cache"); IEnumerable seriesSpecifiers = ss.ToList(); @@ -2315,7 +2315,7 @@ private void ProcessBannerResponses(int code, CachedSeriesInfo si, Locale locale private static ShowImage CreateShowImage(int tvdbId, JObject bannerData) { double.TryParse((string?)bannerData["ratingsInfo"]?["average"], NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingWhite | NumberStyles.AllowTrailingWhite, CultureInfo.CreateSpecificCulture("en-US"), out double rating); - int.TryParse((string?)bannerData["subKey"], out int seasonId); + int? seasonId = ((string?)bannerData["subKey"]).ToInt(); // { // "fileName": "string", // "id": 0, diff --git a/TVRename/TVRename/CacheUpdater.cs b/TVRename/TVRename/CacheUpdater.cs index 83462805..37c669cb 100644 --- a/TVRename/TVRename/CacheUpdater.cs +++ b/TVRename/TVRename/CacheUpdater.cs @@ -262,7 +262,7 @@ private void Downloader(object? token) if (downloadIds.Any(s => s.Provider == TVDoc.ProviderType.TheTVDB)) { - if (!TheTVDB.LocalCache.Instance.GetUpdates(showErrorMsgBox, downloadIds.Where(specifier => specifier.Provider == TVDoc.ProviderType.TheTVDB), + if (!TheTVDB.LocalCache.Instance.GetUpdates(downloadIds.Where(specifier => specifier.Provider == TVDoc.ProviderType.TheTVDB), showErrorMsgBox, cts)) { DownloadDone = true; diff --git a/TVRename/TVRename/PossibleNewMovie.cs b/TVRename/TVRename/PossibleNewMovie.cs index 8fb641da..9a370f0d 100644 --- a/TVRename/TVRename/PossibleNewMovie.cs +++ b/TVRename/TVRename/PossibleNewMovie.cs @@ -56,7 +56,7 @@ public void GuessMovie(bool showErrorMsgBox) int? tmdbId = FindShowCode("tmdbid", "tmdb").ToInt(); Locale preferredLocale = new(); - int? tmdbCode = ValidateOnTMDB(tmdbId, preferredLocale, showErrorMsgBox); + int? tmdbCode = ValidateOnTMDB(tmdbId, preferredLocale); if (tmdbCode.HasValue) { SetId(tmdbCode.Value, TVDoc.ProviderType.TMDB); @@ -81,7 +81,7 @@ public void GuessMovie(bool showErrorMsgBox) if (imdbToTest.HasValue()) { - CachedMovieInfo? s = TMDB.LocalCache.Instance.LookupMovieByImdb(imdbToTest, preferredLocale, showErrorMsgBox); + CachedMovieInfo? s = TMDB.LocalCache.Instance.LookupMovieByImdb(imdbToTest, preferredLocale); if (s != null) { SetId(s.TmdbCode, TVDoc.ProviderType.TMDB); @@ -110,7 +110,7 @@ public void GuessMovie(bool showErrorMsgBox) int? tvdbId = FindShowCode("tvdbid", "tvdb").ToInt(); if (tvdbId.HasValue) { - CachedMovieInfo? s2 = TMDB.LocalCache.Instance.LookupMovieByTvdb(tvdbId.Value, showErrorMsgBox, preferredLocale); + CachedMovieInfo? s2 = TMDB.LocalCache.Instance.LookupMovieByTvdb(tvdbId.Value, preferredLocale); if (s2 != null) { SetId(s2.TmdbCode, TVDoc.ProviderType.TMDB); @@ -167,7 +167,7 @@ public void SetId(int code, TVDoc.ProviderType provider) return null; } - private static int? ValidateOnTMDB(int? tmdbId, Locale locale, bool showErrorMsgBox) + private static int? ValidateOnTMDB(int? tmdbId, Locale locale) { if (tmdbId.HasValue) { @@ -175,7 +175,7 @@ public void SetId(int code, TVDoc.ProviderType provider) { ISeriesSpecifier ss = new SearchSpecifier(tmdbId.Value, locale, TVDoc.ProviderType.TMDB, MediaConfiguration.MediaType.movie); - CachedMovieInfo series = TMDB.LocalCache.Instance.GetMovieAndDownload(ss, showErrorMsgBox); + CachedMovieInfo series = TMDB.LocalCache.Instance.GetMovieAndDownload(ss); return series.TmdbCode; } catch (MediaNotFoundException) diff --git a/TVRename/Utility/Helper/RegistryHelper.cs b/TVRename/Utility/Helper/RegistryHelper.cs index 84629e48..8ebb716f 100644 --- a/TVRename/Utility/Helper/RegistryHelper.cs +++ b/TVRename/Utility/Helper/RegistryHelper.cs @@ -6,181 +6,14 @@ // Copyright (c) TV Rename. This code is released under GPLv3 https://github.com/TV-Rename/tvrename/blob/master/LICENSE.md // -using Alphaleonis.Win32.Filesystem; -using Microsoft.Win32; using NLog; -using System; -using System.Diagnostics.CodeAnalysis; -using System.Security; namespace TVRename; public static class RegistryHelper { - //From https://www.cyotek.com/blog/configuring-the-emulation-mode-of-an-internet-explorer-webbrowser-control THANKS - //Needed to ensure webBrowser renders HTML 5 content - - private const string INTERNET_EXPLORER_ROOT_KEY = @"Software\Microsoft\Internet Explorer"; - private const string BROWSER_EMULATION_KEY = INTERNET_EXPLORER_ROOT_KEY + @"\Main\FeatureControl\FEATURE_BROWSER_EMULATION"; private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); -#pragma warning disable IDE0079 // Remove unnecessary suppression - [SuppressMessage("ReSharper", "InconsistentNaming")] -#pragma warning restore IDE0079 // Remove unnecessary suppression - private enum BrowserEmulationVersion - { - Default = 0, - Version7 = 7000, - Version8 = 8000, - Version9 = 9000, - Version10 = 10000, - Version11 = 11000 - } - - private static int GetInternetExplorerMajorVersion() - { - try - { - RegistryKey? key = Registry.LocalMachine.OpenSubKey(INTERNET_EXPLORER_ROOT_KEY); - - if (key != null) - { - object? value = key.GetValue("svcVersion", null) ?? key.GetValue("Version", null); - string? version = value?.ToString(); - - if (version != null) - { - int separator = version.IndexOf('.'); - if (separator != -1) - { - int.TryParse(version.AsSpan(0, separator), out int result); - return result; - } - } - } - } - catch (SecurityException se) - { - // The user does not have the permissions required to read from the registry key. - Logger.Error(se); - } - catch (UnauthorizedAccessException uae) - { - // The user does not have the necessary registry rights. - Logger.Error(uae); - } - - return 0; - } - - private static BrowserEmulationVersion GetBrowserEmulationVersion() - { - try - { - RegistryKey? key = Registry.CurrentUser.OpenSubKey(BROWSER_EMULATION_KEY, true); - if (key != null) - { - string programName = Path.GetFileName(Environment.GetCommandLineArgs()[0]); - object? value = key.GetValue(programName, null); - - if (value != null) - { - return (BrowserEmulationVersion)Convert.ToInt32(value); - } - } - } - catch (SecurityException se) - { - // The user does not have the permissions required to read from the registry key. - Logger.Error(se); - } - catch (UnauthorizedAccessException uae) - { - // The user does not have the necessary registry rights. - Logger.Error(uae); - } - - return BrowserEmulationVersion.Default; - } - - private static bool IsBrowserEmulationSet() => GetBrowserEmulationVersion() != BrowserEmulationVersion.Default; - - private static bool UpgradeBrowserEmulationRequired() => GetBrowserEmulationVersion() != GetInternetExplorerVersion(); - - private static bool SetBrowserEmulationVersion(BrowserEmulationVersion browserEmulationVersion) - { - try - { - RegistryKey key = Registry.CurrentUser.CreateSubKey(BROWSER_EMULATION_KEY, true); - - // ReSharper disable once ConditionIsAlwaysTrueOrFalseAccordingToNullableAPIContract - if (key != null) - { - string programName = Path.GetFileName(Environment.GetCommandLineArgs()[0]); - - if (browserEmulationVersion != BrowserEmulationVersion.Default) - { - // if it's a valid value, update or create the value - key.SetValue(programName, (int)browserEmulationVersion, RegistryValueKind.DWord); - Logger.Warn($"SETTING REGISTRY:{key.Name}-{programName}-{(int)browserEmulationVersion}-{RegistryValueKind.DWord}"); - } - else - { - // otherwise, remove the existing value - key.DeleteValue(programName, false); - Logger.Warn($"DELETING REGISTRY KEY:{key.Name}-{programName}"); - } - - return true; - } - - Logger.Warn($"Could not access {BROWSER_EMULATION_KEY}"); - } - catch (SecurityException se) - { - // The user does not have the permissions required to read from the registry key. - Logger.Error(se); - } - catch (UnauthorizedAccessException uae) - { - // The user does not have the necessary registry rights. - Logger.Error(uae); - } - - return false; - } - - private static bool SetBrowserEmulationVersion() => SetBrowserEmulationVersion(GetInternetExplorerVersion()); - - private static BrowserEmulationVersion GetInternetExplorerVersion() - { - int ieVersion = GetInternetExplorerMajorVersion(); - Logger.Info($"IE Version {ieVersion} is identified"); - - if (ieVersion >= 11) - { - return BrowserEmulationVersion.Version11; - } - - return ieVersion switch - { - 10 => BrowserEmulationVersion.Version10, - 9 => BrowserEmulationVersion.Version9, - 8 => BrowserEmulationVersion.Version8, - _ => BrowserEmulationVersion.Version7 - }; - } - public static void UpdateBrowserEmulationVersion() - { - if (!IsBrowserEmulationSet() || UpgradeBrowserEmulationRequired()) - { - Logger.Warn("Updating the registry to ensure that the latest browser version is used"); - if (!SetBrowserEmulationVersion()) - { - Logger.Error("Failed to update the browser emulation version"); - } - } - } } diff --git a/TVRename/Utility/Helper/ShowHtmlHelper.cs b/TVRename/Utility/Helper/ShowHtmlHelper.cs index 05f5df53..660114f0 100644 --- a/TVRename/Utility/Helper/ShowHtmlHelper.cs +++ b/TVRename/Utility/Helper/ShowHtmlHelper.cs @@ -792,7 +792,7 @@ private static void AppendMovie(this StringBuilder sb, MovieConfiguration? si, C case TVDoc.ProviderType.libraryDefault: return EditTvSeriesUrl(si, TVSettings.Instance.DefaultProvider); default: - throw new ArgumentOutOfRangeException(); + throw new ArgumentOutOfRangeException(nameof(source),$"TV Url asked tobe created for {source.PrettyPrint()}"); } } @@ -1379,7 +1379,7 @@ public static string SeasonName(ShowConfiguration si, int snum) ProcessedSeason.SeasonType.alternate => snum == 0 ? "Not in alternate season" : "Alternate " + ProcessedSeason.UISeasonWord(snum), - _ => throw new ArgumentOutOfRangeException() + _ => throw new ArgumentOutOfRangeException($"ShowConfig {si} has invalid Season Order {si.Order.PrettyPrint()}.") }; } @@ -1674,7 +1674,7 @@ private static string ProviderShowUrl(this ShowConfiguration show) TVDoc.ProviderType.TMDB => show.WebsiteUrl ?? string.Empty, TVDoc.ProviderType.libraryDefault => show.WebsiteUrl ?? string.Empty, TVDoc.ProviderType.TVmaze => show.WebsiteUrl ?? string.Empty, - _ => throw new ArgumentOutOfRangeException() + _ => throw new ArgumentOutOfRangeException($"ShowConfig {show} has invalid Provider.") }; }