private static TvShowEpisodeToXbmcNfoConnector parseNfoPart(String part) throws Exception { Unmarshaller um = context.createUnmarshaller(); if (um == null) { throw new Exception("could not create unmarshaller"); } try { Reader in = new StringReader(part); return (TvShowEpisodeToXbmcNfoConnector) um.unmarshal(in); } catch (UnmarshalException e) { LOGGER.error("tried to unmarshal; now trying to clean xml stream"); } catch (IllegalArgumentException e) { LOGGER.warn("tried to unmarshal; now trying to clean xml stream"); } // clean NFO string and retry StringReader in = new StringReader(ParserUtils.cleanNfo(part)); return (TvShowEpisodeToXbmcNfoConnector) um.unmarshal(in); }
private static TvShowToXbmcNfoConnector parseNFO(File nfoFile) throws Exception { Unmarshaller um = context.createUnmarshaller(); if (um == null) { MessageManager.instance.pushMessage(new Message(MessageLevel.ERROR, nfoFile, "message.nfo.readerror")); throw new Exception("could not create unmarshaller"); } try { Reader in = new InputStreamReader(new FileInputStream(nfoFile), "UTF-8"); return (TvShowToXbmcNfoConnector) um.unmarshal(in); } catch (UnmarshalException e) { LOGGER.error("tried to unmarshal; now trying to clean xml stream"); } // now trying to parse it via string String completeNFO = FileUtils.readFileToString(nfoFile, "UTF-8").trim().replaceFirst("^([\\W]+)<", "<"); Reader in = new StringReader(ParserUtils.cleanNfo(completeNFO)); return (TvShowToXbmcNfoConnector) um.unmarshal(in); }
in = new StringReader(ParserUtils.cleanNfo(completeNFO)); kodi = (MovieToKodiNfoConnector) um.unmarshal(in);
"<movie xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">"); try { in = new StringReader(ParserUtils.cleanNfo(completeNFO)); mp = (MovieToMpNfoConnector) um.unmarshal(in);
in = new StringReader(ParserUtils.cleanNfo(completeNFO)); xbmc = (MovieToXbmcNfoConnector) um.unmarshal(in);