aboutsummaryrefslogtreecommitdiff
path: root/utils.py
diff options
context:
space:
mode:
authorcedricbonhomme <devnull@localhost>2011-06-19 00:10:54 +0200
committercedricbonhomme <devnull@localhost>2011-06-19 00:10:54 +0200
commitf34d5bf48f08c75f7dc4476d197735f41219889b (patch)
tree545a94b804657db4c22b09b21d2e5e6ed3363193 /utils.py
parentNew link to the feed page. (diff)
downloadnewspipe-f34d5bf48f08c75f7dc4476d197735f41219889b.tar.gz
newspipe-f34d5bf48f08c75f7dc4476d197735f41219889b.tar.bz2
newspipe-f34d5bf48f08c75f7dc4476d197735f41219889b.zip
Added a new function which enables to change the URL of a feed (this updates all the data base).
Diffstat (limited to 'utils.py')
-rwxr-xr-xutils.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/utils.py b/utils.py
index 29ca43d3..c31b24f4 100755
--- a/utils.py
+++ b/utils.py
@@ -253,6 +253,31 @@ def add_feed(feed_url):
f.write(feed_url + "\n")
return True
+def change_feed_url(old_feed_url, new_feed_url):
+ """
+ Change the URL of a feed.
+ """
+ # Replace the URL in the text file
+ with open("./var/feed.lst", "r") as f:
+ lines = f.readlines()
+ try:
+ lines[lines.index(old_feed_url+"\n")] = new_feed_url + '\n'
+ except:
+ return
+ with open("./var/feed.lst", "w") as f:
+ f.write("\n".join(lines))
+
+ # Replace the URL in the data base.
+ try:
+ conn = sqlite3.connect(sqlite_base, isolation_level = None)
+ c = conn.cursor()
+ c.execute("UPDATE articles SET feed_link='" + new_feed_url + "' WHERE feed_link='" + old_feed_url +"'")
+ c.execute("UPDATE feeds SET feed_link='" + new_feed_url + "' WHERE feed_link='" + old_feed_url +"'")
+ conn.commit()
+ c.close()
+ except Exception, e:
+ print e
+
def remove_feed(feed_url):
"""
Remove a feed from the file feed.lst and from the SQLite base.
bgstack15