summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlnu <lnu@f70e237a-67f3-0310-a06c-d2b8a7116972>2006-07-11 16:10:42 +0000
committerlnu <lnu@f70e237a-67f3-0310-a06c-d2b8a7116972>2006-07-11 16:10:42 +0000
commita7e4638feee8c58aa2e1178815848ee694eca8b9 (patch)
tree0e2e78fae3cc7e536062befc0f0b586c58804c4f
parent4eaf046fc73d231529ccc636cdcabbaa0c5a0fc0 (diff)
downloadfeed2imap-a7e4638feee8c58aa2e1178815848ee694eca8b9.tar.gz
feed2imap-a7e4638feee8c58aa2e1178815848ee694eca8b9.tar.bz2
feed2imap-a7e4638feee8c58aa2e1178815848ee694eca8b9.zip
snowscripts support + content-transfer-encoding fixed
git-svn-id: svn+ssh://svn.gna.org/svn/feed2imap/trunk/feed2imap@103 f70e237a-67f3-0310-a06c-d2b8a7116972
-rw-r--r--ChangeLog7
-rw-r--r--data/doc/feed2imap/examples/feed2imaprc13
-rw-r--r--lib/feed2imap/config.rb4
-rw-r--r--lib/feed2imap/feed2imap.rb20
-rw-r--r--lib/feed2imap/itemtomail.rb2
5 files changed, 38 insertions, 8 deletions
diff --git a/ChangeLog b/ChangeLog
index 8064425..cc017d5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+Feed2Imap 0.9 (XX/XX/2006)
+============================
+* Now uses Content-Transfer-Encoding: 8bit (thanks Arnt Gulbrandsen
+ <arnt@gulbrandsen.priv.no>)
+* Now supports Snowscripts, using the 'execurl' and 'filter' config
+ keywords. For more information, see the example configuration file.
+
Feed2Imap 0.8 (28/06/2006)
============================
* Uses the http_proxy environment variable to determine the proxy server
diff --git a/data/doc/feed2imap/examples/feed2imaprc b/data/doc/feed2imap/examples/feed2imaprc
index eee49f3..0d0c3ed 100644
--- a/data/doc/feed2imap/examples/feed2imaprc
+++ b/data/doc/feed2imap/examples/feed2imaprc
@@ -16,6 +16,12 @@
# an item is new or has been updated. It doesn't work well with some web apps
# like mediawiki. When this flag is enabled, all items which don't match
# exactly a previously downloaded item are considered as new items.
+# Snownews/Liferea scripts support :
+# execurl: Command to execute that will display the RSS/Atom feed on stdout
+# filter: Command to execute which will receive the RSS/Atom feed on stdin,
+# modify it, and output it on stdout.
+# For more information: http://kiza.kcore.de/software/snownews/snowscripts/
+#
#
# If your login contains an @ character, replace it with %40. Other reserved
# characters can be escaped in the same way (see man ascii to get their code)
@@ -26,10 +32,11 @@ feeds:
- name: lucas
url: http://www.lucas-nussbaum.net/blog/?feed=rss2
target: imap://luser:password@imap.apinc.org/INBOX.Feeds.Lucas
- - name: linuxfr
- url: http://linuxfr.org/backend/news/rss20.rss
- target: imap://luser:password@imap.apinc.org/INBOX.Feeds.LinuxFR
- name: JabberFrWiki
url: http://wiki.jabberfr.org/index.php?title=Special:Recentchanges&feed=rss
target: imaps://luser:password@imap.apinc.org/INBOX.Feeds.JabberFR
always-new: true
+ - name: LeMonde
+ execurl: "wget -q -O /dev/stdout http://www.lemonde.fr/rss/sequence/0,2-3208,1-0,0.xml"
+ filter: "/home/lucas/lemonde_getbody"
+ target: imap://luser:password@imap.apinc.org/INBOX.Feeds.LeMonde
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'