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 androidx.annotation.Nullable;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
|
import java.net.URLConnection;
|
||||||
import java.util.zip.CheckedOutputStream;
|
import java.util.zip.CheckedOutputStream;
|
||||||
|
|
||||||
|
import de.danoeh.antennapod.core.ClientConfig;
|
||||||
import org.apache.commons.io.IOUtils;
|
import org.apache.commons.io.IOUtils;
|
||||||
|
|
||||||
import java.io.BufferedInputStream;
|
import java.io.BufferedInputStream;
|
||||||
@ -80,7 +83,9 @@ public class ChapterUtils {
|
|||||||
CountingInputStream in = null;
|
CountingInputStream in = null;
|
||||||
try {
|
try {
|
||||||
URL url = new URL(p.getStreamUrl());
|
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);
|
List<Chapter> chapters = readChaptersFrom(in);
|
||||||
if (!chapters.isEmpty()) {
|
if (!chapters.isEmpty()) {
|
||||||
p.setChapters(chapters);
|
p.setChapters(chapters);
|
||||||
@ -149,7 +154,9 @@ public class ChapterUtils {
|
|||||||
InputStream input = null;
|
InputStream input = null;
|
||||||
try {
|
try {
|
||||||
URL url = new URL(media.getStreamUrl());
|
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) {
|
if (input != null) {
|
||||||
readOggChaptersFromInputStream(media, input);
|
readOggChaptersFromInputStream(media, input);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user