Skip to content
Browse files

Add skip_links option (default false), requested by d

  • Loading branch information...
1 parent 3410064 commit 21a9003cb1f515dc85937ce207fb8131179af966 @akkana committed
Showing with 33 additions and 15 deletions.
  1. +16 −6 feedme
  2. +17 −9 feedmeparser.py
View
22 feedme
@@ -31,8 +31,6 @@ import re
import shutil
import traceback
-# from ConfigParser import ConfigParser
-
import feedparser
import urllib2
@@ -348,6 +346,7 @@ def get_feed(feedname, config, cache, cachefile, last_time, msglog) :
formats = config.get(feedname, 'formats').split(',')
encoding = config.get(feedname, 'encoding')
ascii = config.getboolean(feedname, 'ascii')
+ skip_links = config.getboolean(feedname, 'skip_links')
# Is this a feed we should only check occasionally?
"""Does this feed specify only gathering at certain times?
@@ -632,15 +631,21 @@ Which (default = s): """)
indexstr += itemlink + '<b>' + item.title + '</b></a>\n'
else :
# For a single-level site, don't put links over each entry.
- itemlink = '<a href=\"' + item.link + '\">'
- indexstr += "\n" + itemlink + item.title + "</a>\n"
+ if skip_links :
+ itemlink = None
+ indexstr += "\n<b>" + item.title + "</b>\n"
+ else :
+ itemlink = '<a href=\"' + item.link + '\">'
+ indexstr += "\n" + itemlink + item.title + "</a>\n"
# Under the title, add a link to jump to the next entry
# if it isn't the last entry.
- if item != feed.entries[-1] :
+ if item != feed.entries[-1] and not skip_links :
indexstr += \
"<br>\n<center><i><a href=\"#%d\">&gt;-&gt;</a></i></center>\n<br>\n" \
% (itemnum+1)
+ else :
+ indexstr += '<br><br>'
# Add either the content or the summary:
if 'summary_detail' in item:
@@ -655,6 +660,10 @@ Which (default = s): """)
if config.getboolean(feedname, 'skip_images') :
content = re.sub('<img .*?>', '', content)
+ # Try to get rid of embedded links if skip_links is true:
+ if skip_links :
+ content = re.sub('<a href=.*>(.*?)</a>', '\\1', content)
+
indexstr += content
if author :
@@ -673,7 +682,8 @@ Which (default = s): """)
else :
short_title = item.title
- indexstr += "\n<br>[[" + itemlink + short_title + "</a>]]\n\n"
+ if itemlink :
+ indexstr += "\n<br>[[" + itemlink + short_title + "</a>]]\n\n"
# If there was an error parsing this entry, we won't save
# a file so decrement the itemnum and loop to the next entry.
View
26 feedmeparser.py
@@ -567,6 +567,10 @@ def tag_skippable(self, tag):
self.config.getboolean(self.feedname, 'skip_images') :
return True
+ if tag == 'a' and \
+ self.config.getboolean(self.feedname, 'skip_links') :
+ return True
+
return False
#
@@ -586,15 +590,19 @@ def read_config_file() :
print >>sys.stderr, "Error: no config file in", conffile
sys.exit(1)
- config = ConfigParser({'verbose':'false', 'levels':'2',
- 'encoding':'', # blank means try several
- 'page_start':'', 'page_end':'',
- 'single_page_pat':'', 'skip_pat':'',
- 'nocache':'false',
- 'logfile':'',
- 'save_days':'7',
- 'when':'', # Day, like tue, or month day, like 14
- 'ascii':'false'})
+ config = ConfigParser({'verbose' : 'false',
+ 'levels' : '2',
+ 'encoding' : '', # blank means try several
+ 'page_start' : '', 'page_end':'',
+ 'single_page_pat' : '', 'skip_pat':'',
+ 'nocache' : 'false',
+ 'logfile' : '',
+ 'save_days' : '7',
+ 'skip_images' : 'true',
+ 'nonlocal_images' : 'false',
+ 'skip_links' : 'false',
+ 'when' : '', # Day, like tue, or month day, like 14
+ 'ascii' : 'false'})
config.read(conffile)
return config

0 comments on commit 21a9003

Please sign in to comment.
Something went wrong with that request. Please try again.