From dbbe614c33e583cef14bb109c3d2666e0eeb535a Mon Sep 17 00:00:00 2001 From: ByteHamster Date: Wed, 1 Jul 2020 15:57:52 +0200 Subject: [PATCH 1/2] Set user-agent for file playback --- build.gradle | 2 +- .../de/danoeh/antennapod/core/util/playback/AudioPlayer.java | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index 9774fc3c8..0a5695377 100644 --- a/build.gradle +++ b/build.gradle @@ -65,7 +65,7 @@ project.ext { rxAndroidVersion = "2.1.1" rxJavaVersion = "2.2.2" iconifyVersion = "2.2.2" - audioPlayerVersion = "v1.0.17" + audioPlayerVersion = "v2.0.0" // Google Play build wearableSupportVersion = "2.6.0" diff --git a/core/src/main/java/de/danoeh/antennapod/core/util/playback/AudioPlayer.java b/core/src/main/java/de/danoeh/antennapod/core/util/playback/AudioPlayer.java index 4b3ffa389..aec53da4c 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/util/playback/AudioPlayer.java +++ b/core/src/main/java/de/danoeh/antennapod/core/util/playback/AudioPlayer.java @@ -6,6 +6,7 @@ import android.preference.PreferenceManager; import android.util.Log; import android.view.SurfaceHolder; +import de.danoeh.antennapod.core.ClientConfig; import org.antennapod.audio.MediaPlayer; import de.danoeh.antennapod.core.preferences.UserPreferences; @@ -17,7 +18,7 @@ public class AudioPlayer extends MediaPlayer implements IPlayer { private static final String TAG = "AudioPlayer"; public AudioPlayer(Context context) { - super(context); + super(context, true, ClientConfig.USER_AGENT); PreferenceManager.getDefaultSharedPreferences(context) .registerOnSharedPreferenceChangeListener((sharedPreferences, key) -> { if (key.equals(UserPreferences.PREF_MEDIA_PLAYER)) { From b0d73c89857c19d519784ad3c274c92d9cd92417 Mon Sep 17 00:00:00 2001 From: ByteHamster Date: Wed, 1 Jul 2020 16:03:18 +0200 Subject: [PATCH 2/2] Set user-agent for chapter loading --- .../de/danoeh/antennapod/core/util/ChapterUtils.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/de/danoeh/antennapod/core/util/ChapterUtils.java b/core/src/main/java/de/danoeh/antennapod/core/util/ChapterUtils.java index b75887154..737f902b7 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/util/ChapterUtils.java +++ b/core/src/main/java/de/danoeh/antennapod/core/util/ChapterUtils.java @@ -4,7 +4,10 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; import android.util.Log; +import java.net.URLConnection; import java.util.zip.CheckedOutputStream; + +import de.danoeh.antennapod.core.ClientConfig; import org.apache.commons.io.IOUtils; import java.io.BufferedInputStream; @@ -80,7 +83,9 @@ public class ChapterUtils { CountingInputStream in = null; try { URL url = new URL(p.getStreamUrl()); - in = new CountingInputStream(url.openStream()); + URLConnection urlConnection = url.openConnection(); + urlConnection.setRequestProperty("User-Agent", ClientConfig.USER_AGENT); + in = new CountingInputStream(urlConnection.getInputStream()); List chapters = readChaptersFrom(in); if (!chapters.isEmpty()) { p.setChapters(chapters); @@ -149,7 +154,9 @@ public class ChapterUtils { InputStream input = null; try { URL url = new URL(media.getStreamUrl()); - input = url.openStream(); + URLConnection urlConnection = url.openConnection(); + urlConnection.setRequestProperty("User-Agent", ClientConfig.USER_AGENT); + input = urlConnection.getInputStream(); if (input != null) { readOggChaptersFromInputStream(media, input); }