From ecb81236c757a5454441760d1bc634ac8a9bec83 Mon Sep 17 00:00:00 2001 From: Thomas <71355143+thomas694@users.noreply.github.com> Date: Tue, 11 Jun 2024 23:58:59 +0200 Subject: [PATCH] Fix issue #532/#547 Twitter/X download not working --- src/TumblThree/SharedAssemblyInfo.cs | 4 ++-- .../Controllers/ModuleController.cs | 9 ++++++++- .../Crawler/AbstractCrawler.cs | 13 +++++++++++++ .../Crawler/TwitterCrawler.cs | 2 +- .../Properties/Resources.Designer.cs | 9 +++++++++ .../Properties/Resources.de.resx | 3 +++ .../Properties/Resources.es.resx | 3 +++ .../Properties/Resources.fr.resx | 3 +++ .../Properties/Resources.resx | 3 +++ 9 files changed, 45 insertions(+), 4 deletions(-) diff --git a/src/TumblThree/SharedAssemblyInfo.cs b/src/TumblThree/SharedAssemblyInfo.cs index 3780b51e..a95e6a52 100644 --- a/src/TumblThree/SharedAssemblyInfo.cs +++ b/src/TumblThree/SharedAssemblyInfo.cs @@ -12,5 +12,5 @@ [assembly: ComVisible(false)] [assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.MainAssembly)] -[assembly: AssemblyVersion("2.14.0.0")] -[assembly: AssemblyFileVersion("2.14.0.0")] +[assembly: AssemblyVersion("2.14.1.0")] +[assembly: AssemblyFileVersion("2.14.1.0")] diff --git a/src/TumblThree/TumblThree.Applications/Controllers/ModuleController.cs b/src/TumblThree/TumblThree.Applications/Controllers/ModuleController.cs index 852c1768..80495eec 100644 --- a/src/TumblThree/TumblThree.Applications/Controllers/ModuleController.cs +++ b/src/TumblThree/TumblThree.Applications/Controllers/ModuleController.cs @@ -147,7 +147,7 @@ public void Initialize() QueueController.Initialize(); DetailsController.Initialize(); CrawlerController.Initialize(); - _cookieService.SetUriCookie(CleanOldTumblrCookies(_cookieList)); + _cookieService.SetUriCookie(CleanOldTwitterCookies(CleanOldTumblrCookies(_cookieList))); } public async void Run() @@ -494,5 +494,12 @@ private static List CleanOldTumblrCookies(List cookies) } return cookies; } + + private static List CleanOldTwitterCookies(List cookies) + { + cookies.RemoveAll(x => x.Name == "_twitter_sess"); + cookies.ForEach(x => x.Domain = x.Domain.Replace("twitter.com", "x.com")); + return cookies; + } } } diff --git a/src/TumblThree/TumblThree.Applications/Crawler/AbstractCrawler.cs b/src/TumblThree/TumblThree.Applications/Crawler/AbstractCrawler.cs index f24d893c..462eb0b7 100644 --- a/src/TumblThree/TumblThree.Applications/Crawler/AbstractCrawler.cs +++ b/src/TumblThree/TumblThree.Applications/Crawler/AbstractCrawler.cs @@ -627,6 +627,19 @@ protected bool HandleUnauthorizedWebException(WebException webException) return true; } + protected bool HandleUnauthorizedWebException2(WebException webException) + { + var resp = (HttpWebResponse)webException?.Response; + if (resp == null || resp.StatusCode != HttpStatusCode.Unauthorized) + { + return false; + } + + Logger.Error("{0}, {1}", string.Format(CultureInfo.CurrentCulture, Resources.NotLoggedInX, Blog.Name), webException.Message); + ShellService.ShowError(webException, Resources.NotLoggedInX, Blog.Name); + return true; + } + protected bool HandleUnauthorizedWebExceptionRetry(WebException webException) { if (!ShellService.Settings.TumblrAuthErrorAutoRetry) diff --git a/src/TumblThree/TumblThree.Applications/Crawler/TwitterCrawler.cs b/src/TumblThree/TumblThree.Applications/Crawler/TwitterCrawler.cs index bff6f5a4..ddb1a61a 100644 --- a/src/TumblThree/TumblThree.Applications/Crawler/TwitterCrawler.cs +++ b/src/TumblThree/TumblThree.Applications/Crawler/TwitterCrawler.cs @@ -97,7 +97,7 @@ public override async Task IsBlogOnlineAsync() return; } - if (HandleUnauthorizedWebException(webException)) + if (HandleUnauthorizedWebException2(webException)) { Blog.Online = true; } diff --git a/src/TumblThree/TumblThree.Applications/Properties/Resources.Designer.cs b/src/TumblThree/TumblThree.Applications/Properties/Resources.Designer.cs index 79b7bd19..befe3894 100644 --- a/src/TumblThree/TumblThree.Applications/Properties/Resources.Designer.cs +++ b/src/TumblThree/TumblThree.Applications/Properties/Resources.Designer.cs @@ -877,6 +877,15 @@ public static string NotLoggedInNT { } } + /// + /// Looks up a localized string similar to You need to login to x.com for downloading {0}. Go to the Settings->Connection->Authenticate.. + /// + public static string NotLoggedInX { + get { + return ResourceManager.GetString("NotLoggedInX", resourceCulture); + } + } + /// /// Looks up a localized string similar to online checking. /// diff --git a/src/TumblThree/TumblThree.Applications/Properties/Resources.de.resx b/src/TumblThree/TumblThree.Applications/Properties/Resources.de.resx index 04451b40..fe5c5b43 100644 --- a/src/TumblThree/TumblThree.Applications/Properties/Resources.de.resx +++ b/src/TumblThree/TumblThree.Applications/Properties/Resources.de.resx @@ -504,4 +504,7 @@ Trotzdem fortfahren und schließen? Die zwischengespeicherte Sammlung „{0}“ kann nicht aktualisiert werden, da sie nicht mehr online ist. Trotzdem fortfahren und schließen? + + Sie müssen sich bei x.com anmelden zum Laden von {0}. Dazu in den Einstellungen->Authentifizieren klicken. + \ No newline at end of file diff --git a/src/TumblThree/TumblThree.Applications/Properties/Resources.es.resx b/src/TumblThree/TumblThree.Applications/Properties/Resources.es.resx index 45c0aab7..fd1d4ca5 100644 --- a/src/TumblThree/TumblThree.Applications/Properties/Resources.es.resx +++ b/src/TumblThree/TumblThree.Applications/Properties/Resources.es.resx @@ -498,4 +498,7 @@ De lo contrario, debe cambiar al menos las entradas de ubicación "Descargar" y La colección almacenada en caché '{0}' no se puede actualizar porque ya no está en línea. ¿Continuar cerca de todos modos? + + Debes iniciar sesión en x.com para descargar {0}. Vaya a Configuración-> Autenticar. + \ No newline at end of file diff --git a/src/TumblThree/TumblThree.Applications/Properties/Resources.fr.resx b/src/TumblThree/TumblThree.Applications/Properties/Resources.fr.resx index 08e43c71..a3928cad 100644 --- a/src/TumblThree/TumblThree.Applications/Properties/Resources.fr.resx +++ b/src/TumblThree/TumblThree.Applications/Properties/Resources.fr.resx @@ -516,4 +516,7 @@ Continuer à fermer quand même ? La collection mise en cache « {0} » ne peut pas être mise à jour, car elle n'est plus en ligne. Continuer à fermer quand même ? + + Vous devez vous connecter à x.com pour télécharger {0}. Accédez aux Paramètres-> Authentification. + \ No newline at end of file diff --git a/src/TumblThree/TumblThree.Applications/Properties/Resources.resx b/src/TumblThree/TumblThree.Applications/Properties/Resources.resx index 842536c3..49f52534 100644 --- a/src/TumblThree/TumblThree.Applications/Properties/Resources.resx +++ b/src/TumblThree/TumblThree.Applications/Properties/Resources.resx @@ -535,4 +535,7 @@ Continue close anyway? The cached collection '{0}' cannot be updated, because it is no longer online. Continue close anyway? + + You need to login to x.com for downloading {0}. Go to the Settings->Connection->Authenticate. + \ No newline at end of file