aboutsummaryrefslogtreecommitdiff
path: root/utils.py
diff options
context:
space:
mode:
authorcedricbonhomme <devnull@localhost>2010-06-10 09:12:54 +0200
committercedricbonhomme <devnull@localhost>2010-06-10 09:12:54 +0200
commite6bbb708cde59b3f32b69e50f6312652332f3a83 (patch)
tree786593b6a74313141329f41dd73d87b39d5aac81 /utils.py
parentRemoved xkcd (diff)
downloadnewspipe-e6bbb708cde59b3f32b69e50f6312652332f3a83.tar.gz
newspipe-e6bbb708cde59b3f32b69e50f6312652332f3a83.tar.bz2
newspipe-e6bbb708cde59b3f32b69e50f6312652332f3a83.zip
Remove a feed from the file feed.lst. Some improvements.
Diffstat (limited to 'utils.py')
-rwxr-xr-xutils.py26
1 files changed, 23 insertions, 3 deletions
diff --git a/utils.py b/utils.py
index a23584e0..38e077b2 100755
--- a/utils.py
+++ b/utils.py
@@ -196,20 +196,40 @@ def add_feed(feed_url):
"""
Add the URL feed_url in the file feed.lst.
"""
- for ligne in open("./var/feed.lst", "r"):
- if feed_url in ligne:
+ for line in open("./var/feed.lst", "r"):
+ if feed_url in line:
return False
with open("./var/feed.lst", "a") as f:
f.write(feed_url + "\n")
return True
+def remove_feed(feed_url):
+ """
+ Remove a feed from the file feed.lst and from the SQLite base.
+ """
+ feeds = []
+ # Remove the URL from the file feed.lst
+ for line in open("./var/feed.lst", "r"):
+ if feed_url not in line:
+ feeds.append(line.replace("\n", ""))
+ with open("./var/feed.lst", "w") as f:
+ f.write("\n".join(feeds))
+ # Remove articles from this feed from the SQLite base.
+ conn = sqlite3.connect(sqlite_base, isolation_level = None)
+ c = conn.cursor()
+ c.execute("")
+ conn.commit()
+ c.close()
+
def search_feed(url):
"""
Search a feed in a HTML page.
"""
page = urllib2.urlopen(url)
soup = BeautifulSoup(page)
- for feed_link in soup('link', type='application/atom+xml'):
+ feed_links = soup('link', type='application/atom+xml')
+ feed_links.append(soup('link', type='application/rss+xml'))
+ for feed_link in feed_links:
if url not in feed_link['href']:
return urlparse.urljoin(url, feed_link['href'])
return feed_link['href']
bgstack15