Browse Source

add soup poster

master
Andreas Demmelbauer 6 years ago
parent
commit
09ffb90f68
1 changed files with 7 additions and 3 deletions
  1. +7
    -3
      tootbot.py

+ 7
- 3
tootbot.py View File

@@ -190,7 +190,7 @@ for p in reversed(s.entries):
shouldpost = False shouldpost = False
print("skip: already posted") print("skip: already posted")
# process only unprocessed tweets less than n days old # process only unprocessed tweets less than n days old
shouldpost = True 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) 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)
@@ -246,7 +246,8 @@ for p in reversed(s.entries):
else: else:
print('Dryrun: not fetching ', pic, ' and not uploading it to mastodon') print('Dryrun: not fetching ', pic, ' and not uploading it to mastodon')



poster = p.title.split(']')[0].strip('[')
poster_text = "\n\nvia %s on soup.io" % poster
# remove all html stuff - python module in use only supports markdown, not pure plaintext # remove all html stuff - python module in use only supports markdown, not pure plaintext
textsrc = h.handle(p.summary_detail.value.replace("<small>", "<br><small>")) textsrc = h.handle(p.summary_detail.value.replace("<small>", "<br><small>"))
# free text from lines without visible characters # free text from lines without visible characters
@@ -265,9 +266,12 @@ for p in reversed(s.entries):
source = '\n\nSource: ' + p.link source = '\n\nSource: ' + p.link


# shorten text if too long # shorten text if too long
maximumlegth = 500 - 1 - len(source) - 50 # 50 ... just in case (if they also count attachement url and so on)
maximumlegth = 500 - 1 - len(poster_text) - len(source) - 50 # 50 ... just in case (if they also count attachement url and so on)
text = (text[:maximumlegth] + '…') if len(text) > maximumlegth else text text = (text[:maximumlegth] + '…') if len(text) > maximumlegth else text


# add poster
text += poster_text

# add source # add source
text += source text += source




Loading…
Cancel
Save