Skip to content

Commit

Permalink
fix(YouTube Music - Disable music video in album): App crashes on And…
Browse files Browse the repository at this point in the history
…roid 5 / 6 devices
  • Loading branch information
inotia00 authored and anddea committed Jan 16, 2025
1 parent e5f4a98 commit 353c0bf
Showing 1 changed file with 17 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import java.net.HttpURLConnection;
import java.net.SocketTimeoutException;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
Expand All @@ -39,11 +40,22 @@ public static void fetchRequestIfNeeded(@NonNull String videoId, @NonNull String
synchronized (cache) {
final long now = System.currentTimeMillis();

cache.values().removeIf(request -> {
final boolean expired = request.isExpired(now);
if (expired) Logger.printDebug(() -> "Removing expired stream: " + request.videoId);
return expired;
});
if (Utils.isSDKAbove(25)) {
cache.values().removeIf(request -> {
final boolean expired = request.isExpired(now);
if (expired) Logger.printDebug(() -> "Removing expired stream: " + request.videoId);
return expired;
});
} else {
Iterator<Map.Entry<String, PipedRequester>> itr = cache.entrySet().iterator();
while (itr.hasNext()) {
Map.Entry<String, PipedRequester> entry = itr.next();
if (entry.getValue().isExpired(now)) {
Logger.printDebug(() -> "Removing expired fetch: " + entry.getValue().videoId);
itr.remove();
}
}
}

if (!cache.containsKey(videoId)) {
PipedRequester pipedRequester = new PipedRequester(videoId, playlistId, playlistIndex);
Expand Down

0 comments on commit 353c0bf

Please sign in to comment.