Skip to content

Commit

Permalink
bugfix for uniq feeds
Browse files Browse the repository at this point in the history
  • Loading branch information
thesues committed Apr 21, 2011
1 parent 6604509 commit 501e930
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 17 deletions.
17 changes: 6 additions & 11 deletions smthtop10/buildbook.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ def getContent(smth,parser,board,articleid,feed,next):
print find_url(origout)
for imageurl in find_url(unicode(origout,"gbk")):
a.imagefilenameList.append(down_image(smth,imageurl,archive))
feed.title=result['t']
feed.append(a)
elif next==1:
out=smth.get_url_data(smthurl+"?act=article&board="+board+"&id="+articleid+"&p=tn")
Expand All @@ -58,7 +57,7 @@ def getContent(smth,parser,board,articleid,feed,next):
#print result["c"]
a=Post(author=result["a"],content=result["c"],signature=result["sign"],reference=result["ref"],attached=False)
feed.append(a)
if(feed.numOfPosts==2):
if(feed.numOfPosts==20):
return
#to be contented
if result["id"]!=articleid:
Expand All @@ -85,25 +84,26 @@ def login(smth):
#get top10 topics
out=smth.get_url_data("http://www.newsmth.net/rssi.php?h=1")

previousFeedTitle=[e.title for e in UniqueFeed.objects.filter(date=today)]

top10parser=Top10Parser(out)
articleparser=BeautyArticleProcessor()
#read data from disk
try:
f=open(archive+"/sm.data","r")
sumaryFeeds=cPickle.load(f)
print "SumaryFeeds exist"
f.close()
except IOError:
sumaryFeeds=[]
pass

previousFeedTitle=[e.title for e in sumaryFeeds]

for article in top10parser.getall():
if article['t'] in previousFeedTitle:
if article['t']=='' or article['t'] in previousFeedTitle:
continue
temp=UniqueFeed.objects.create(title=article['t'])
temp.save()
feed=Feed()
feed.title=article['t']
getContent(smth,articleparser,article['b'],article['gid'],feed,0)
getContent(smth,articleparser,article['b'],article['gid'],feed,1)
sumaryFeeds.append(feed)
Expand Down Expand Up @@ -136,8 +136,3 @@ def login(smth):
p.lastUpdate=datetime.now()
p.save()






6 changes: 0 additions & 6 deletions smthtop10/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,6 @@ class Thread(models.Model):
location=models.FilePathField(path=None)
mobiLocation=models.FilePathField(path=None)
lastUpdate=models.DateTimeField(auto_now_add=True)
class UniqueFeed(models.Model):
date=models.DateField(auto_now_add=True)
title=models.CharField(max_length=40)






0 comments on commit 501e930

Please sign in to comment.