handle post length limit to pnut
This commit is contained in:
parent
b4bede5b97
commit
b0d99c7d3c
1 changed files with 15 additions and 0 deletions
15
feedbot.py
15
feedbot.py
|
@ -1,8 +1,10 @@
|
|||
import feedparser
|
||||
import requests
|
||||
import textwrap
|
||||
import logging
|
||||
import pnutpy
|
||||
import click
|
||||
import time
|
||||
import re
|
||||
import os
|
||||
|
||||
|
@ -126,6 +128,19 @@ def pnutpost(entry, source, token):
|
|||
rx = re.compile('<.*?>')
|
||||
text = re.sub(rx, '', entry.summary)
|
||||
|
||||
lchk = textwrap.wrap(text, 256)
|
||||
if len(lchk) > 1:
|
||||
pretext = textwrap.wrap(text, 250)
|
||||
longpost = {
|
||||
'type': "nl.chimpnut.blog.post",
|
||||
'value': {
|
||||
'body': text,
|
||||
'tstamp': time.time() * 1000
|
||||
}
|
||||
}
|
||||
raw.append(longpost)
|
||||
text = pretext + " [...](" + entry.link + ")"
|
||||
|
||||
if dr:
|
||||
logging.info({'text': text, 'raw': raw})
|
||||
else:
|
||||
|
|
Loading…
Reference in a new issue