Set user-agent for chapter loading
This commit is contained in:
parent
dbbe614c33
commit
b0d73c8985
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue