def addArticleKeyword(self, articleid, keywordid): data = {"articleid": articleid, "keywordid": keywordid} response = None try: response = rest.doPost("articlekeyword", data) return (response.json()['id']) except Exception as e: log.exception(e) return None
def addArticleKeyword(self, articleid, keywordid): data = { "articleid": articleid, "keywordid": keywordid } response = None try: response = rest.doPost("articlekeyword", data) return(response.json()['id']) except Exception as e: log.exception(e) return None
def addFeed(this, title, source, description="", type=2, interval=300, active=0): if this.feedExists(title) == False: log.warn("Adding type %s feed %s to be retrieved from %s to API server." % (type, title, source)) data = { 'title': title, 'source': source, 'type': type, 'interval': interval, 'active': active } response = None try: response = rest.doPost("feed", data) return response except: log.error("Error adding feed %s to API server." % (feed)) raise Exception() return False
def addArticle(self, article): if self.articleExists(article) == False: log.info("adding article %s" % (article.title)) data = { "title": article.title, "link": article.link, "keywords": article.keywords, "description": article.description, "content": article.content, "contenthash": article.contenthash, "retrieved": article.retrieved, "published": article.published } try: response = rest.doPost("article", data) for word in article.keywords: keywordid = self.addKeyword(word) self.addArticleKeyword(response.json()['id'], keywordid) except Exception as e: log.exception(e) return None else: return False
def addKeyword(self, word): ke = self.keywordExists(word) if ke == False: log.debug("adding keyword %s" % (word)) data = { "word": word } response = None try: response = rest.doPost("keyword", data) except Exception as e: log.exception(e) return None return(response.json()['id']) else: return ke
def addKeyword(self, word): ke = self.keywordExists(word) if ke == False: log.debug("adding keyword %s" % (word)) data = {"word": word} response = None try: response = rest.doPost("keyword", data) except Exception as e: log.exception(e) return None return (response.json()['id']) else: return ke