From a7e4638feee8c58aa2e1178815848ee694eca8b9 Mon Sep 17 00:00:00 2001 From: lnu Date: Tue, 11 Jul 2006 16:10:42 +0000 Subject: snowscripts support + content-transfer-encoding fixed git-svn-id: svn+ssh://svn.gna.org/svn/feed2imap/trunk/feed2imap@103 f70e237a-67f3-0310-a06c-d2b8a7116972 --- lib/feed2imap/feed2imap.rb | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'lib/feed2imap/feed2imap.rb') diff --git a/lib/feed2imap/feed2imap.rb b/lib/feed2imap/feed2imap.rb index fcbb357..3cf46aa 100644 --- a/lib/feed2imap/feed2imap.rb +++ b/lib/feed2imap/feed2imap.rb @@ -18,7 +18,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA =end # Feed2Imap version -F2I_VERSION = '0.8' +F2I_VERSION = '0.9' require 'feed2imap/config' require 'feed2imap/cache' @@ -27,6 +27,7 @@ require 'logger' require 'thread' require 'feedparser' require 'feed2imap/itemtomail' +require 'open3' class Feed2Imap def Feed2Imap.version @@ -98,7 +99,7 @@ class Feed2Imap end end # for each feed, fetch, upload to IMAP and cache - @logger.info("Fetching feeds") + @logger.info("Fetching and filtering feeds") ths = [] mutex = Mutex::new @config.feeds.each do |f| @@ -108,7 +109,20 @@ class Feed2Imap lastcheck = @cache.get_last_check(feed.name) if feed.needfetch(lastcheck) mutex.unlock - s = HTTPFetcher::fetch(feed.url, @cache.get_last_check(feed.name)) + if feed.url + s = HTTPFetcher::fetch(feed.url, @cache.get_last_check(feed.name)) + elsif feed.execurl + s = %x{#{feed.execurl}} + else + @logger.warn("No way to fetch feed #{feed.name} !") + end + if feed.filter + Open3::popen3(feed.filter) do |stdin, stdout| + stdin.puts s + stdin.close + s = stdout.read + end + end mutex.lock feed.body = s @cache.set_last_check(feed.name, Time::now) -- cgit v1.2.3-54-g00ecf