mirror of
https://github.com/Athou/commafeed.git
synced 2026-03-21 21:37:29 +00:00
display error messages
This commit is contained in:
@@ -43,6 +43,13 @@ public class FeedFetcher {
|
||||
HttpResponse response = httpclient.execute(httpget);
|
||||
HttpEntity entity = response.getEntity();
|
||||
String content = EntityUtils.toString(entity, "UTF-8");
|
||||
String extractedUrl = extractFeedUrl(content);
|
||||
if (extractedUrl != null) {
|
||||
httpget = new HttpGet(feedUrl);
|
||||
response = httpclient.execute(httpget);
|
||||
entity = response.getEntity();
|
||||
content = EntityUtils.toString(entity, "UTF-8");
|
||||
}
|
||||
feed = parser.parse(feedUrl, content);
|
||||
} catch (Exception e) {
|
||||
throw new FeedException(e.getMessage(), e);
|
||||
@@ -52,7 +59,7 @@ public class FeedFetcher {
|
||||
return feed;
|
||||
}
|
||||
|
||||
public String extractFeedUrl(String html) {
|
||||
private String extractFeedUrl(String html) {
|
||||
String foundUrl = null;
|
||||
|
||||
Document doc = Jsoup.parse(html);
|
||||
|
||||
@@ -27,11 +27,11 @@ public class FeedParser {
|
||||
@SuppressWarnings("unchecked")
|
||||
public Feed parse(String feedUrl, String xml) throws FeedException {
|
||||
Feed feed = new Feed();
|
||||
feed.setUrl(feedUrl);
|
||||
feed.setLastUpdated(Calendar.getInstance().getTime());
|
||||
|
||||
try {
|
||||
SyndFeed rss = new SyndFeedInput().build(new StringReader(xml));
|
||||
feed.setUrl(rss.getLink() != null ? rss.getLink() : feedUrl);
|
||||
feed.setTitle(rss.getTitle());
|
||||
List<SyndEntry> items = rss.getEntries();
|
||||
for (SyndEntry item : items) {
|
||||
|
||||
Reference in New Issue
Block a user