diff options
author | ByteHamster <ByteHamster@users.noreply.github.com> | 2023-01-29 12:12:08 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-29 12:12:08 +0100 |
commit | e261514c5ba18a028ced8cf68c04c4f485409902 (patch) | |
tree | 8302632dfddcdfc2ac83b130b06c47d20e03ea31 /core/src/main | |
parent | 73a6ff1f6003c776fb37bd8e7315045e69e710d2 (diff) | |
download | AntennaPod-e261514c5ba18a028ced8cf68c04c4f485409902.zip |
Update feed url when server returns itunes:new-feed-url (#6291)
Diffstat (limited to 'core/src/main')
-rw-r--r-- | core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadService.java | 12 | ||||
-rw-r--r-- | core/src/main/java/de/danoeh/antennapod/core/service/download/handler/FeedSyncTask.java | 11 |
2 files changed, 15 insertions, 8 deletions
diff --git a/core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadService.java b/core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadService.java index 30745a60d..a18d7d1d0 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadService.java +++ b/core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadService.java @@ -273,8 +273,8 @@ public class DownloadService extends Service { if (type == Feed.FEEDFILETYPE_FEED) { Log.d(TAG, "Handling completed Feed Download"); - FeedSyncTask task = new FeedSyncTask(DownloadService.this, request); - boolean success = task.run(); + FeedSyncTask feedSyncTask = new FeedSyncTask(DownloadService.this, request); + boolean success = feedSyncTask.run(); if (success) { if (request.getFeedfileId() == 0) { @@ -283,18 +283,20 @@ public class DownloadService extends Service { // we create a 'successful' download log if the feed's last refresh failed List<DownloadStatus> log = DBReader.getFeedDownloadLog(request.getFeedfileId()); if (log.size() > 0 && !log.get(0).isSuccessful()) { - saveDownloadStatus(task.getDownloadStatus()); + saveDownloadStatus(feedSyncTask.getDownloadStatus()); } if (!request.isInitiatedByUser()) { // Was stored in the database before and not initiated manually - newEpisodesNotification.showIfNeeded(DownloadService.this, task.getSavedFeed()); + newEpisodesNotification.showIfNeeded(DownloadService.this, feedSyncTask.getSavedFeed()); } if (downloader.permanentRedirectUrl != null) { DBWriter.updateFeedDownloadURL(request.getSource(), downloader.permanentRedirectUrl); + } else if (feedSyncTask.getRedirectUrl() != null) { + DBWriter.updateFeedDownloadURL(request.getSource(), feedSyncTask.getRedirectUrl()); } } else { DBWriter.setFeedLastUpdateFailed(request.getFeedfileId(), true); - saveDownloadStatus(task.getDownloadStatus()); + saveDownloadStatus(feedSyncTask.getDownloadStatus()); } } else if (type == FeedMedia.FEEDFILETYPE_FEEDMEDIA) { Log.d(TAG, "Handling completed FeedMedia Download"); diff --git a/core/src/main/java/de/danoeh/antennapod/core/service/download/handler/FeedSyncTask.java b/core/src/main/java/de/danoeh/antennapod/core/service/download/handler/FeedSyncTask.java index 07670bff3..e3010fe24 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/service/download/handler/FeedSyncTask.java +++ b/core/src/main/java/de/danoeh/antennapod/core/service/download/handler/FeedSyncTask.java @@ -14,6 +14,7 @@ public class FeedSyncTask { private final Context context; private Feed savedFeed; private final FeedParserTask task; + private FeedHandlerResult feedHandlerResult; public FeedSyncTask(Context context, DownloadRequest request) { this.request = request; @@ -22,15 +23,15 @@ public class FeedSyncTask { } public boolean run() { - FeedHandlerResult result = task.call(); + feedHandlerResult = task.call(); if (!task.isSuccessful()) { return false; } - savedFeed = DBTasks.updateFeed(context, result.feed, false); + savedFeed = DBTasks.updateFeed(context, feedHandlerResult.feed, false); // If loadAllPages=true, check if another page is available and queue it for download final boolean loadAllPages = request.getArguments().getBoolean(DownloadRequest.REQUEST_ARG_LOAD_ALL_PAGES); - final Feed feed = result.feed; + final Feed feed = feedHandlerResult.feed; if (loadAllPages && feed.getNextPageLink() != null) { feed.setId(savedFeed.getId()); DBTasks.loadNextPageOfFeed(context, feed, true); @@ -46,4 +47,8 @@ public class FeedSyncTask { public Feed getSavedFeed() { return savedFeed; } + + public String getRedirectUrl() { + return feedHandlerResult.redirectUrl; + } } |