use of de.danoeh.antennapod.model.feed.Chapter in project AntennaPod by AntennaPod.
the class ChapterReaderTest method testReadChapterWithoutSubframes.
@Test
public void testReadChapterWithoutSubframes() throws IOException, ID3ReaderException {
FrameHeader header = new FrameHeader(ChapterReader.FRAME_ID_CHAPTER, CHAPTER_WITHOUT_SUBFRAME.length, (short) 0);
CountingInputStream inputStream = new CountingInputStream(new ByteArrayInputStream(CHAPTER_WITHOUT_SUBFRAME));
Chapter chapter = new ChapterReader(inputStream).readChapter(header);
assertEquals(CHAPTER_WITHOUT_SUBFRAME_START_TIME, chapter.getStart());
}
use of de.danoeh.antennapod.model.feed.Chapter in project AntennaPod by AntennaPod.
the class ChapterReaderTest method testRealFileMp3chapsPy.
@Test
public void testRealFileMp3chapsPy() throws IOException, ID3ReaderException {
CountingInputStream inputStream = new CountingInputStream(getClass().getClassLoader().getResource("mp3chaps-py.mp3").openStream());
ChapterReader reader = new ChapterReader(inputStream);
reader.readInputStream();
List<Chapter> chapters = reader.getChapters();
assertEquals(4, chapters.size());
assertEquals(0, chapters.get(0).getStart());
assertEquals(7000, chapters.get(1).getStart());
assertEquals(9000, chapters.get(2).getStart());
assertEquals(11000, chapters.get(3).getStart());
assertEquals("Start", chapters.get(0).getTitle());
assertEquals("Chapter 1", chapters.get(1).getTitle());
assertEquals("Chapter 2", chapters.get(2).getTitle());
assertEquals("Chapter 3", chapters.get(3).getTitle());
}
use of de.danoeh.antennapod.model.feed.Chapter in project AntennaPod by AntennaPod.
the class ChapterReaderTest method testRealFileUltraschall.
@Test
public void testRealFileUltraschall() throws IOException, ID3ReaderException {
CountingInputStream inputStream = new CountingInputStream(getClass().getClassLoader().getResource("ultraschall5.mp3").openStream());
ChapterReader reader = new ChapterReader(inputStream);
reader.readInputStream();
List<Chapter> chapters = reader.getChapters();
assertEquals(3, chapters.size());
assertEquals(0, chapters.get(0).getStart());
assertEquals(4004, chapters.get(1).getStart());
assertEquals(7999, chapters.get(2).getStart());
assertEquals("Marke 1", chapters.get(0).getTitle());
assertEquals("Marke 2", chapters.get(1).getTitle());
assertEquals("Marke 3", chapters.get(2).getTitle());
assertEquals("https://example.com", chapters.get(0).getLink());
assertEquals("https://example.com", chapters.get(1).getLink());
assertEquals("https://example.com", chapters.get(2).getLink());
assertEquals(EmbeddedChapterImage.makeUrl(16073, 2750569), chapters.get(0).getImageUrl());
assertEquals(EmbeddedChapterImage.makeUrl(2766765, 15740), chapters.get(1).getImageUrl());
assertEquals(EmbeddedChapterImage.makeUrl(2782628, 2750569), chapters.get(2).getImageUrl());
}
use of de.danoeh.antennapod.model.feed.Chapter in project AntennaPod by AntennaPod.
the class VorbisCommentChapterReaderTest method testRealFileAuphonic.
public void testRealFileAuphonic(String filename) throws IOException, VorbisCommentReaderException {
InputStream inputStream = getClass().getClassLoader().getResource(filename).openStream();
VorbisCommentChapterReader reader = new VorbisCommentChapterReader();
reader.readInputStream(inputStream);
List<Chapter> chapters = reader.getChapters();
assertEquals(4, chapters.size());
assertEquals(0, chapters.get(0).getStart());
assertEquals(3000, chapters.get(1).getStart());
assertEquals(6000, chapters.get(2).getStart());
assertEquals(9000, chapters.get(3).getStart());
assertEquals("Chapter 1 - ❤️😊", chapters.get(0).getTitle());
assertEquals("Chapter 2 - ßöÄ", chapters.get(1).getTitle());
assertEquals("Chapter 3 - 爱", chapters.get(2).getTitle());
assertEquals("Chapter 4", chapters.get(3).getTitle());
assertEquals("https://example.com", chapters.get(0).getLink());
assertEquals("https://example.com", chapters.get(1).getLink());
assertEquals("https://example.com", chapters.get(2).getLink());
assertEquals("https://example.com", chapters.get(3).getLink());
}
use of de.danoeh.antennapod.model.feed.Chapter in project AntennaPod by AntennaPod.
the class ChapterReader method readFrame.
@Override
protected void readFrame(@NonNull FrameHeader frameHeader) throws IOException, ID3ReaderException {
if (FRAME_ID_CHAPTER.equals(frameHeader.getId())) {
Log.d(TAG, "Handling frame: " + frameHeader.toString());
Chapter chapter = readChapter(frameHeader);
Log.d(TAG, "Chapter done: " + chapter);
chapters.add(chapter);
} else {
super.readFrame(frameHeader);
}
}
Aggregations