diff options
Diffstat (limited to 'utils.py')
-rwxr-xr-x | utils.py | 25 |
1 files changed, 25 insertions, 0 deletions
@@ -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. |