Skip to content

Commit

Permalink
Fix issue #532/#547 Twitter/X download not working
Browse files Browse the repository at this point in the history
  • Loading branch information
thomas694 committed Jun 11, 2024
1 parent d7abc11 commit ecb8123
Show file tree
Hide file tree
Showing 9 changed files with 45 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/TumblThree/SharedAssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -494,5 +494,12 @@ private static List<Cookie> CleanOldTumblrCookies(List<Cookie> cookies)
}
return cookies;
}

private static List<Cookie> CleanOldTwitterCookies(List<Cookie> cookies)
{
cookies.RemoveAll(x => x.Name == "_twitter_sess");
cookies.ForEach(x => x.Domain = x.Domain.Replace("twitter.com", "x.com"));
return cookies;
}
}
}
13 changes: 13 additions & 0 deletions src/TumblThree/TumblThree.Applications/Crawler/AbstractCrawler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public override async Task IsBlogOnlineAsync()
return;
}

if (HandleUnauthorizedWebException(webException))
if (HandleUnauthorizedWebException2(webException))
{
Blog.Online = true;
}
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -504,4 +504,7 @@ Trotzdem fortfahren und schließen?</value>
<value>Die zwischengespeicherte Sammlung „{0}“ kann nicht aktualisiert werden, da sie nicht mehr online ist.
Trotzdem fortfahren und schließen?</value>
</data>
<data name="NotLoggedInX" xml:space="preserve">
<value>Sie müssen sich bei x.com anmelden zum Laden von {0}. Dazu in den Einstellungen-&gt;Authentifizieren klicken.</value>
</data>
</root>
Original file line number Diff line number Diff line change
Expand Up @@ -498,4 +498,7 @@ De lo contrario, debe cambiar al menos las entradas de ubicación "Descargar" y
<value>La colección almacenada en caché '{0}' no se puede actualizar porque ya no está en línea.
¿Continuar cerca de todos modos?</value>
</data>
<data name="NotLoggedInX" xml:space="preserve">
<value>Debes iniciar sesión en x.com para descargar {0}. Vaya a Configuración-&gt; Autenticar.</value>
</data>
</root>
Original file line number Diff line number Diff line change
Expand Up @@ -516,4 +516,7 @@ Continuer à fermer quand même ?</value>
<value>La collection mise en cache « {0} » ne peut pas être mise à jour, car elle n'est plus en ligne.
Continuer à fermer quand même ?</value>
</data>
<data name="NotLoggedInX" xml:space="preserve">
<value>Vous devez vous connecter à x.com pour télécharger {0}. Accédez aux Paramètres-&gt; Authentification.</value>
</data>
</root>
Original file line number Diff line number Diff line change
Expand Up @@ -535,4 +535,7 @@ Continue close anyway?</value>
<value>The cached collection '{0}' cannot be updated, because it is no longer online.
Continue close anyway?</value>
</data>
<data name="NotLoggedInX" xml:space="preserve">
<value>You need to login to x.com for downloading {0}. Go to the Settings-&gt;Connection-&gt;Authenticate.</value>
</data>
</root>

0 comments on commit ecb8123

Please sign in to comment.