diff --git a/post_parser.py b/post_parser.py index 87aa6b0..fb57b5f 100644 --- a/post_parser.py +++ b/post_parser.py @@ -159,6 +159,10 @@ class PostParser: first_line = re.sub(r'\.$', '', first_line) #Remove dot first_line = first_line.strip() + # Handle uppercase text - convert to title case if the text is all uppercase + if first_line.isupper(): + first_line = first_line.lower().capitalize() + # Process long strings cut_at = 37 if len(first_line) > cut_at: return f"{first_line[:cut_at]}..." @@ -260,7 +264,7 @@ class PostParser: flags.append("fwd") # Add flag "video" if the message media is VIDEO or ANIMATION and the body text is up to 200 characters. - if (message.media in [MessageMediaType.VIDEO, MessageMediaType.ANIMATION] and + if (message.media in [MessageMediaType.VIDEO, MessageMediaType.ANIMATION, MessageMediaType.VIDEO_NOTE] and len((message.text or message.caption or '').strip()) <= 200): flags.append("video") diff --git a/tests/test_post_parser.py b/tests/test_post_parser.py index ffeec43..761292f 100644 --- a/tests/test_post_parser.py +++ b/tests/test_post_parser.py @@ -109,6 +109,10 @@ class TestPostParserGenerateTitle(unittest.TestCase): message = self._create_mock_message(media=MessageMediaType.PHOTO, caption="Look at this photo! https://example.com/image.jpg") self.assertEqual(self.parser._generate_title(message), "Look at this photo!") + def test_generate_title_caption_with_uppercase_text(self): + message = self._create_mock_message(text="ЖИЗНЬ НА ОБОЯХ") + self.assertEqual(self.parser._generate_title(message), "Жизнь на обоях") #downcase + def test_generate_title_long_text_trimming(self): long_text = "This is a very long line of text that definitely exceeds the maximum length allowed for a title, so it should be trimmed intelligently at the last space before the limit." message = self._create_mock_message(text=long_text)