From 8bbffb942971f5f85299f52d247dab5aff154a51 Mon Sep 17 00:00:00 2001 From: Sven Slootweg Date: Wed, 30 Jan 2013 22:30:13 +0100 Subject: [PATCH] Add topic_exists and item_exists methods to Scraper class --- updater/shared/scraper.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/updater/shared/scraper.py b/updater/shared/scraper.py index 594be7b..df1978d 100644 --- a/updater/shared/scraper.py +++ b/updater/shared/scraper.py @@ -24,6 +24,16 @@ class Scraper(object): def run(self, *args, **kwargs): raise Exception("No run() method was specified for this scraper.") + def topic_exists(self, unique_id): + c = self.db.cursor() + c.execute("SELECT `Id` FROM topics WHERE `Provider` = ? AND `ProviderId` = ? LIMIT 1", (self.provider_id, unique_id)) + return (len(c.fetchall()) > 0) + + def item_exists(self, unique_id): + c = self.db.cursor() + c.execute("SELECT `Id` FROM items WHERE `Provider` = ? AND `ProviderId` = ? LIMIT 1", (self.provider_id, unique_id)) + return (len(c.fetchall()) > 0) + def insert_topic(self, unique_id, title, override=False, **kwargs): defaults = { "needs_enrollment": False,