diff --git a/lumbunglib/feed.py b/lumbunglib/feed.py index 93ae387..5b4ccb1 100644 --- a/lumbunglib/feed.py +++ b/lumbunglib/feed.py @@ -1,6 +1,7 @@ import os import shutil import time +from hashlib import md5 from ast import literal_eval as make_tuple from pathlib import Path from urllib.parse import urlparse @@ -238,6 +239,13 @@ def main(): entry["feed_name"] = feed_name post_name = slugify(entry.title) + # pixelfed returns the whole post text as the post name. max + # filename length is 255 on many systems. here we're shortening + # the name and adding a hash to it to avoid a conflict in a + # situation where 2 posts start with exactly the same text. + if len(post_name) > 150: + post_hash = md5(bytes(post_name, "utf-8")) + post_name = post_name[:150] + "-" + post_hash.hexdigest() post_dir = os.path.join(output_dir, feed_name, post_name) if post_name not in existing_posts: