handle post length limit to pnut

This commit is contained in:
Morgan McMillian 2022-04-30 10:01:42 -07:00
parent b4bede5b97
commit b0d99c7d3c

View file

@ -1,8 +1,10 @@
import feedparser import feedparser
import requests import requests
import textwrap
import logging import logging
import pnutpy import pnutpy
import click import click
import time
import re import re
import os import os
@ -126,6 +128,19 @@ def pnutpost(entry, source, token):
rx = re.compile('<.*?>') rx = re.compile('<.*?>')
text = re.sub(rx, '', entry.summary) 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: if dr:
logging.info({'text': text, 'raw': raw}) logging.info({'text': text, 'raw': raw})
else: else: