diff --git a/instaloader/structures.py b/instaloader/structures.py index 6b56ee0..0efe36d 100644 --- a/instaloader/structures.py +++ b/instaloader/structures.py @@ -252,6 +252,14 @@ class Post: mention_regex = re.compile(r"(?:@)(\w(?:(?:\w|(?:\.(?!\.))){0,28}(?:\w))?)") return re.findall(mention_regex, self.caption.lower()) + @property + def pcaption(self) -> str: + """Printable caption, useful as a format specifier for --filename-pattern.""" + def _elliptify(caption): + pcaption = ' '.join([s.replace('/', '∕') for s in caption.splitlines() if s]).strip() + return (pcaption[:30] + u"\u2026") if len(pcaption) > 31 else pcaption + return _elliptify(self.caption) if self.caption else '' + @property def tagged_users(self) -> List[str]: """List of all lowercased users that are tagged in the Post."""