Search in sources :

Example 16 with Chapter

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());
}
Also used : FrameHeader(de.danoeh.antennapod.parser.media.id3.model.FrameHeader) ByteArrayInputStream(java.io.ByteArrayInputStream) CountingInputStream(org.apache.commons.io.input.CountingInputStream) Chapter(de.danoeh.antennapod.model.feed.Chapter) Test(org.junit.Test)

Example 17 with Chapter

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());
}
Also used : CountingInputStream(org.apache.commons.io.input.CountingInputStream) Chapter(de.danoeh.antennapod.model.feed.Chapter) Test(org.junit.Test)

Example 18 with Chapter

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());
}
Also used : CountingInputStream(org.apache.commons.io.input.CountingInputStream) Chapter(de.danoeh.antennapod.model.feed.Chapter) Test(org.junit.Test)

Example 19 with Chapter

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());
}
Also used : InputStream(java.io.InputStream) Chapter(de.danoeh.antennapod.model.feed.Chapter)

Example 20 with Chapter

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);
    }
}
Also used : Chapter(de.danoeh.antennapod.model.feed.Chapter)

Aggregations

Chapter (de.danoeh.antennapod.model.feed.Chapter)20 CountingInputStream (org.apache.commons.io.input.CountingInputStream)7 Test (org.junit.Test)7 NonNull (androidx.annotation.NonNull)4 FrameHeader (de.danoeh.antennapod.parser.media.id3.model.FrameHeader)3 ByteArrayInputStream (java.io.ByteArrayInputStream)3 ChapterStartTimeComparator (de.danoeh.antennapod.core.util.comparator.ChapterStartTimeComparator)2 FeedMedia (de.danoeh.antennapod.model.feed.FeedMedia)2 SimpleChapter (de.danoeh.antennapod.parser.feed.element.SimpleChapter)2 VorbisCommentChapterReader (de.danoeh.antennapod.parser.media.vorbis.VorbisCommentChapterReader)2 Dialog (android.app.Dialog)1 ContentValues (android.content.ContentValues)1 Cursor (android.database.Cursor)1 Bundle (android.os.Bundle)1 Log (android.util.Log)1 LayoutInflater (android.view.LayoutInflater)1 View (android.view.View)1 ViewGroup (android.view.ViewGroup)1 ProgressBar (android.widget.ProgressBar)1 RelativeLayout (android.widget.RelativeLayout)1