diff --git a/post_parser.py b/post_parser.py
index a119a6c..4bbd430 100644
--- a/post_parser.py
+++ b/post_parser.py
@@ -126,8 +126,11 @@ class PostParser:
text = message.text or message.caption or ''
# Check if the text contains only a URL and nothing else
- if text.strip() and re.match(r'^https?://[^\s]+$', text.strip()):
- return "🔗 Web link"
+ if text.strip():
+ # Remove all URLs from text
+ text_without_urls = re.sub(r'https?://[^\s<>"\']+', '', text.strip())
+ if not text_without_urls:
+ return "🔗 Web link"
if not text:
if message.media == MessageMediaType.PHOTO: return "📷 Photo"
@@ -224,7 +227,7 @@ class PostParser:
# Add flag "video" if the message media is VIDEO or ANIMATION and the body text is up to 100 characters.
if (message.media in [MessageMediaType.VIDEO, MessageMediaType.ANIMATION] and
- len(message_text.strip()) <= 200):
+ len((message.text or message.caption or '').strip()) <= 100):
flags.append("video")
# Add flag for posts without images
@@ -400,7 +403,9 @@ class PostParser:
else: text = ''
text = text.replace('\n', '
') # Replace newlines with
- text = self._add_hyperlinks_to_raw_urls(text) # Add hyperlinks to raw URLs
+ # Add hyperlinks to raw URLs only if original text is short
+ if len((message.text or message.caption or '').strip()) <= 10:
+ text = self._add_hyperlinks_to_raw_urls(text)
if text: # Message text
content_body.append(f'