Ejemplo n.º 1
0
 public void start() throws ApiException {
   for (NewsConfig newsConfig : config.getNewsConfigs()) {
     if (newsConfig.isActive()) {
       log.info("Working on '" + newsConfig.getId() + "'");
       RssNews rss = new RssNews(newsConfig.getRssFeedUrl());
       List<RssNewsEntry> filteredRssNewsEntries =
           rss.getFilteredRssNewsEntries(newsConfig.getFilters(), newsConfig.getMaxAge());
       postRssNews(filteredRssNewsEntries, newsConfig);
     }
   }
 }
Ejemplo n.º 2
0
 private void postRssNews(List<RssNewsEntry> rssNews, NewsConfig newsConfig) {
   int counter = 0;
   for (RssNewsEntry entry : rssNews) {
     try {
       if (!hasEntryBeenPosted(entry, newsConfig)) {
         fluentReddit
             .subreddit(newsConfig.getSubreddit())
             .submit(new URL(entry.getLink()), entry.getTitle());
         log.info("Posted: " + entry.getTitle() + ".");
         counter++;
       }
     } catch (ApiException e) {
       log.fatal("ApiException");
       log.fatal(e.getMessage());
       return;
     } catch (MalformedURLException e) {
       log.fatal("MalformedURLException");
       log.fatal(e.getMessage());
     }
   }
   log.info("Done posting " + counter + " new links");
 }