Removed mime type

This commit is contained in:
ByteHamster 2020-02-12 17:35:09 +01:00
parent 419077043e
commit d4948f91a1
2 changed files with 10 additions and 17 deletions

View File

@ -2,37 +2,31 @@ package de.danoeh.antennapod.core.util;
import android.text.TextUtils;
import de.danoeh.antennapod.core.util.playback.Playable;
import java.util.Objects;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class EmbeddedChapterImage {
private static final Pattern EMBEDDED_IMAGE_MATCHER = Pattern.compile("embedded-image://(.*)@(\\d+):(\\d+)");
final String mime;
final int position;
final int length;
private static final Pattern EMBEDDED_IMAGE_MATCHER = Pattern.compile("embedded-image://(\\d+)/(\\d+)");
private final int position;
private final int length;
private final String imageUrl;
final Playable media;
private final Playable media;
public EmbeddedChapterImage(Playable media, String imageUrl) {
this.media = media;
this.imageUrl = imageUrl;
Matcher m = EMBEDDED_IMAGE_MATCHER.matcher(imageUrl);
if (m.find()) {
this.mime = m.group(1);
this.position = Integer.parseInt(m.group(2));
this.length = Integer.parseInt(m.group(3));
this.position = Integer.parseInt(m.group(1));
this.length = Integer.parseInt(m.group(2));
} else {
throw new IllegalArgumentException("Not an embedded chapter");
}
}
public static String makeUrl(String mime, int position, int length) {
return "embedded-image://" + mime + "@" + position + ":" + length;
}
public String getMime() {
return mime;
public static String makeUrl(int position, int length) {
return "embedded-image://" + position + "/" + length;
}
public int getPosition() {

View File

@ -105,8 +105,7 @@ public class ChapterReader extends ID3Reader {
// Data contains the picture
int length = header.getSize() - read;
if (TextUtils.isEmpty(currentChapter.getImageUrl()) || type == IMAGE_TYPE_COVER) {
currentChapter.setImageUrl(
EmbeddedChapterImage.makeUrl(mime.toString(), input.getCount(), length));
currentChapter.setImageUrl(EmbeddedChapterImage.makeUrl(input.getCount(), length));
}
skipBytes(input, length);
}