diff options
author | cedricbonhomme <devnull@localhost> | 2011-06-19 00:10:54 +0200 |
---|---|---|
committer | cedricbonhomme <devnull@localhost> | 2011-06-19 00:10:54 +0200 |
commit | f34d5bf48f08c75f7dc4476d197735f41219889b (patch) | |
tree | 545a94b804657db4c22b09b21d2e5e6ed3363193 /utils.py | |
parent | New link to the feed page. (diff) | |
download | newspipe-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-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. |