Merge pull request #4272 from ByteHamster/fix-useragent

Fix useragent
This commit is contained in:
H. Lehmann 2020-07-06 22:52:40 +02:00 committed by GitHub
commit 6c4ee6da18
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 4 deletions

View File

@ -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"

View File

@ -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<Chapter> 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);
}

View File

@ -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)) {