Search in sources :

Example 1 with TypeGetter

use of de.danoeh.antennapod.parser.feed.util.TypeGetter in project AntennaPod by AntennaPod.

the class FeedHandler method parseFeed.

public FeedHandlerResult parseFeed(Feed feed) throws SAXException, IOException, ParserConfigurationException, UnsupportedFeedtypeException {
    TypeGetter tg = new TypeGetter();
    TypeGetter.Type type = tg.getType(feed);
    SyndHandler handler = new SyndHandler(feed, type);
    SAXParserFactory factory = SAXParserFactory.newInstance();
    factory.setNamespaceAware(true);
    SAXParser saxParser = factory.newSAXParser();
    File file = new File(feed.getFile_url());
    Reader inputStreamReader = new XmlStreamReader(file);
    InputSource inputSource = new InputSource(inputStreamReader);
    saxParser.parse(inputSource, handler);
    inputStreamReader.close();
    return new FeedHandlerResult(handler.state.feed, handler.state.alternateUrls);
}
Also used : InputSource(org.xml.sax.InputSource) SAXParser(javax.xml.parsers.SAXParser) XmlStreamReader(org.apache.commons.io.input.XmlStreamReader) Reader(java.io.Reader) XmlStreamReader(org.apache.commons.io.input.XmlStreamReader) TypeGetter(de.danoeh.antennapod.parser.feed.util.TypeGetter) File(java.io.File) SAXParserFactory(javax.xml.parsers.SAXParserFactory)

Aggregations

TypeGetter (de.danoeh.antennapod.parser.feed.util.TypeGetter)1 File (java.io.File)1 Reader (java.io.Reader)1 SAXParser (javax.xml.parsers.SAXParser)1 SAXParserFactory (javax.xml.parsers.SAXParserFactory)1 XmlStreamReader (org.apache.commons.io.input.XmlStreamReader)1 InputSource (org.xml.sax.InputSource)1