コード例 #1
0
ファイル: articlemgr.py プロジェクト: ljheidel/noozjunkie
 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
コード例 #2
0
ファイル: articlemgr.py プロジェクト: ljheidel/noozjunkie
 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
コード例 #3
0
 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
コード例 #4
0
ファイル: articlemgr.py プロジェクト: ljheidel/noozjunkie
 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
コード例 #5
0
ファイル: articlemgr.py プロジェクト: ljheidel/noozjunkie
 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
コード例 #6
0
ファイル: articlemgr.py プロジェクト: ljheidel/noozjunkie
 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
コード例 #7
0
ファイル: articlemgr.py プロジェクト: ljheidel/noozjunkie
 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