Bladeren bron

fixing age issue

master
Andreas Demmelbauer 6 jaren geleden
bovenliggende
commit
913c672375
1 gewijzigde bestanden met toevoegingen van 14 en 6 verwijderingen
  1. +14
    -6
      tootbot.py

+ 14
- 6
tootbot.py Bestand weergeven

@@ -91,15 +91,17 @@ for p in reversed(t.entries):
)
last = db.fetchone()

print('Processing: %s' % p.id)
shouldpost = True
posttime = datetime(p.published_parsed.tm_year, p.published_parsed.tm_mon, p.published_parsed.tm_mday, p.published_parsed.tm_hour, p.published_parsed.tm_min, p.published_parsed.tm_sec)
if last is not None:
shouldpost = False
print("skip: already posted")
# process only unprocessed tweets less than n days old
if datetime.now() - posttime > timedelta(days=days):
age = datetime.now() - posttime
if age > timedelta(days=days):
shouldpost = False
print("skip: Tweet older than %s days" % days)
print("skip: Posting older than %s days (%s)" % (days, age) )
# kill tweets with fb links with fire!
if "https://www.facebook.com" in p.title or "https://m.facebook.com" in p.title:
shouldpost = False
@@ -173,6 +175,7 @@ h.body_width = 0

s = feedparser.parse('http://'+soupuser+'/rss')


# start with oldest
for p in reversed(s.entries):
# check if this tweet has been processed
@@ -182,14 +185,19 @@ for p in reversed(s.entries):
)
last = db.fetchone()

print('Processing: %s' % p.id)
if last is not None:
shouldpost = False
print("skip: already posted")
# process only unprocessed tweets less than n days old
if datetime.now() - posttime > timedelta(days=days):
shouldpost = True

posttime = datetime(p.published_parsed.tm_year, p.published_parsed.tm_mon, p.published_parsed.tm_mday, p.published_parsed.tm_hour, p.published_parsed.tm_min, p.published_parsed.tm_sec)
age = datetime.now() - posttime
if age > timedelta(days=days):
shouldpost = False
print("skip: Posting older than %s days" % days)
print("skip: Posting older than %s days (%s)" % (days, age) )

if shouldpost:
# Create application if it does not exist
@@ -216,7 +224,7 @@ for p in reversed(s.entries):
postedtweets.append(postedtweet[0].split('/')[-1])
# check if already tweeted
if tweet_id in postedtweets:
print('Already tweeted: ', j['source'])
print('Already posted the Tweet: ', j['source'])

else:
# collect information about images


Laden…
Annuleren
Opslaan