Fix redirect checker taking too long (#8501)

### Description

Fix redirect checker taking too long when enriching media items. We
cannot do this here, otherwise the media session takes too long to load
lists with many items. Also, it potentially delays starting playback,
which leads to "service did not start in time" crashes.

Instead, do this in the data source factory and cache the result. That
way, we already start playback earlier and transition the service
earlier.

### Checklist
<!-- 
To help us keep the issue tracker clean and work as efficient as
possible,
  please make sure that you have done all of the following.
You can tick the boxes below by placing an x inside the brackets like
this: [x]
-->
- [x] I have read the contribution guidelines:
https://github.com/AntennaPod/AntennaPod/blob/develop/CONTRIBUTING.md#submit-a-pull-request
- [x] I have performed a self-review of my code, going through my
changes line by line and carefully considering why this line change is
necessary
- [x] I have run the automated code checks using `./gradlew checkstyle
lint`
- [x] My code follows the style guidelines of the AntennaPod project:
https://antennapod.org/contribute/develop/app/code-style
- [x] I have mentioned the corresponding issue and the relevant keyword
(e.g., "Closes: #xy") in the description (see
https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue)
- [x] If it is a core feature, I have added automated tests
This commit is contained in:
Hans-Peter Lehmann
2026-05-30 12:22:26 +02:00
committed by GitHub
parent a0010694a3
commit b1604a503a
3 changed files with 38 additions and 11 deletions

View File

@ -2,6 +2,7 @@ package de.danoeh.antennapod.net.common;
import android.text.TextUtils;
import android.util.Log;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import okhttp3.Request;
import okhttp3.Response;
@ -52,8 +53,8 @@ public abstract class RedirectChecker {
return null;
}
@Nullable
public static String getFinalUrl(String url) {
@NonNull
public static String getFinalUrl(@NonNull String url) {
if (TextUtils.isEmpty(url) || !url.startsWith("http")) {
return url;
}