diff options
Diffstat (limited to '')
-rw-r--r-- | lib/feed2imap/config.rb | 4 | ||||
-rw-r--r-- | lib/feed2imap/feed2imap.rb | 20 | ||||
-rw-r--r-- | lib/feed2imap/itemtomail.rb | 2 |
3 files changed, 21 insertions, 5 deletions
diff --git a/lib/feed2imap/config.rb b/lib/feed2imap/config.rb index 38a1faa..10c4d82 100644 --- a/lib/feed2imap/config.rb +++ b/lib/feed2imap/config.rb @@ -71,7 +71,7 @@ end # A configured feed. simple data container. class ConfigFeed - attr_reader :name, :url, :imapaccount, :folder, :always_new + attr_reader :name, :url, :imapaccount, :folder, :always_new, :execurl, :filter attr_accessor :body def initialize(f, imapaccount, folder) @@ -81,6 +81,8 @@ class ConfigFeed @imapaccount, @folder = imapaccount, folder @freq = f['min-frequency'] @always_new = (f['always-new'] and f['always-new'] != 'false') + @execurl = f['execurl'] + @filter = f['filter'] @freq = @freq.to_i if @freq end 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) diff --git a/lib/feed2imap/itemtomail.rb b/lib/feed2imap/itemtomail.rb index 755a436..2f569b9 100644 --- a/lib/feed2imap/itemtomail.rb +++ b/lib/feed2imap/itemtomail.rb @@ -77,7 +77,7 @@ def item_to_mail(item, index, updated, from = 'Feed2Imap') end textpart = RMail::Message::new textpart.header['Content-Type'] = 'text/plain; charset=utf-8' - textpart.header['Content-Transfer-Encoding'] = '7bit' + textpart.header['Content-Transfer-Encoding'] = '8bit' textpart.body = item.to_text htmlpart = RMail::Message::new htmlpart.header['Content-Type'] = 'text/html; charset=utf-8' |