From adfaaf8a24eae9cea907e79ff5394d29f19868a5 Mon Sep 17 00:00:00 2001 From: Amber Date: Tue, 22 Mar 2022 15:56:35 -0500 Subject: [PATCH] tweaks I made while figureing out how this generates posts --- config.def.json | 5 +++++ functions.py | 3 ++- main.py | 4 +--- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/config.def.json b/config.def.json index 861542e..908b063 100644 --- a/config.def.json +++ b/config.def.json @@ -6,5 +6,10 @@ "mention_handling": 1, "max_thread_length": 15, "strip_paired_punctuation": false, + "limit_length": false, + "length_lower_limit": 5, + "length_upper_limit": 50, + "overlap_ratio_enabled": false, + "overlap_ratio": 0.7, "website": "https://git.nixnet.services/amber/amber-ebooks" } diff --git a/functions.py b/functions.py index d9e38cb..dad8b1a 100755 --- a/functions.py +++ b/functions.py @@ -64,7 +64,7 @@ def make_toot(cfg): pin, pout = multiprocessing.Pipe(False) p = multiprocessing.Process(target=make_sentence, args=[pout, cfg]) p.start() - p.join(5) # wait 5 seconds to get something + p.join(300) # wait 5 seconds to get something if p.is_alive(): # if it's still trying to make a toot after 5 seconds p.terminate() p.join() @@ -77,6 +77,7 @@ def make_toot(cfg): def extract_toot(toot): + toot = re.sub("
", "\n", toot) toot = html.unescape(toot) # convert HTML escape codes to text soup = BeautifulSoup(toot, "html.parser") for lb in soup.select("br"): # replace
with linebreak diff --git a/main.py b/main.py index c7b5f8b..6847e88 100755 --- a/main.py +++ b/main.py @@ -10,9 +10,7 @@ import requests import functions parser = argparse.ArgumentParser(description='Log in and download posts.') -parser.add_argument( - '-c', '--cfg', dest='cfg', default='config.json', nargs='?', - help="Specify a custom location for config.json.") +parser.add_argument('-c', '--cfg', dest='cfg', default='config.json', nargs='?', help="Specify a custom location for config.json.") args = parser.parse_args()