|
@@ -13,20 +13,13 @@ class db():
|
|
|
self.c_articles=self.client[self.DB]["articles"]
|
|
self.c_articles=self.client[self.DB]["articles"]
|
|
|
|
|
|
|
|
def change_timezone(self,el):
|
|
def change_timezone(self,el):
|
|
|
- gmt = pytz.timezone("America/Buenos_Aires")
|
|
|
|
|
|
|
+ gmt = pytz.timezone("America/Buenos_Aires") #FIXME
|
|
|
est = pytz.timezone('US/Eastern')
|
|
est = pytz.timezone('US/Eastern')
|
|
|
- #est = pytz.timezone('America/Boston')
|
|
|
|
|
fmt = '%Y-%m-%d %H:%M:%S %Z%z'
|
|
fmt = '%Y-%m-%d %H:%M:%S %Z%z'
|
|
|
|
|
|
|
|
- #print(el["scrap_date"])
|
|
|
|
|
el["scrap_date"]=gmt.localize(el["scrap_date"])
|
|
el["scrap_date"]=gmt.localize(el["scrap_date"])
|
|
|
- #print(el["scrap_date"])
|
|
|
|
|
el["scrap_date"]=el["scrap_date"].astimezone(est)
|
|
el["scrap_date"]=el["scrap_date"].astimezone(est)
|
|
|
- #print(el["scrap_date"])
|
|
|
|
|
el["scrap_date"]=el["scrap_date"].strftime(fmt)
|
|
el["scrap_date"]=el["scrap_date"].strftime(fmt)
|
|
|
- #print(el["scrap_date"])
|
|
|
|
|
- #el["scrap_date"]=est.astimezone(el["scrap_date" ])
|
|
|
|
|
- #est.localize(el["scrap_date"])
|
|
|
|
|
return el
|
|
return el
|
|
|
def jsonable(self, el):
|
|
def jsonable(self, el):
|
|
|
if el is None or "_id" not in el:
|
|
if el is None or "_id" not in el:
|
|
@@ -65,12 +58,18 @@ class db():
|
|
|
if "minweight" not in filter or not isinstance(filter["minweight"],int):
|
|
if "minweight" not in filter or not isinstance(filter["minweight"],int):
|
|
|
filter["minweight"]=1
|
|
filter["minweight"]=1
|
|
|
|
|
|
|
|
|
|
+ if "category" not in filter or filter["category"]=="-1":
|
|
|
|
|
+ filter["category"]=-1
|
|
|
|
|
+
|
|
|
|
|
+ if int(filter["category"])>=0:
|
|
|
|
|
+ db_filter["category"]=int(filter["category"])
|
|
|
|
|
+ #pass
|
|
|
|
|
+
|
|
|
db_filter["weight"]={"$gt":int(filter["minweight"])}
|
|
db_filter["weight"]={"$gt":int(filter["minweight"])}
|
|
|
|
|
+
|
|
|
if "keyword" in filter and len(filter["keyword"]) >0:
|
|
if "keyword" in filter and len(filter["keyword"]) >0:
|
|
|
db_filter["kw"]={"$all": filter["keyword"]}
|
|
db_filter["kw"]={"$all": filter["keyword"]}
|
|
|
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
#db_filter["kw.0"]={"$exists":False}
|
|
#db_filter["kw.0"]={"$exists":False}
|
|
|
pageNumber=0
|
|
pageNumber=0
|
|
|
if "page" in filter:
|
|
if "page" in filter:
|
|
@@ -142,12 +141,12 @@ class db():
|
|
|
"pattern": self.to_regex(k["keyword"].split("|")) } for k in kw.find({}) ]#FIXME, categories
|
|
"pattern": self.to_regex(k["keyword"].split("|")) } for k in kw.find({}) ]#FIXME, categories
|
|
|
return ret
|
|
return ret
|
|
|
|
|
|
|
|
- def add_source(self,url,rss,selector,name):
|
|
|
|
|
|
|
+ def add_source(self,url,rss,selector,name,category):
|
|
|
self.c_sources.insert({"link":url,
|
|
self.c_sources.insert({"link":url,
|
|
|
"rss":rss,
|
|
"rss":rss,
|
|
|
"selector":selector,
|
|
"selector":selector,
|
|
|
"name":name,
|
|
"name":name,
|
|
|
- "category":0})
|
|
|
|
|
|
|
+ "category":category})
|
|
|
|
|
|
|
|
|
|
|
|
|
def reparse_articles(self,articles,kw):
|
|
def reparse_articles(self,articles,kw):
|