diff --git a/MastodonFeedHTML/MastodonFeedHTML.py b/MastodonFeedHTML/MastodonFeedHTML.py
old mode 100644
new mode 100755
index 833720f..3d67b7a
--- a/MastodonFeedHTML/MastodonFeedHTML.py
+++ b/MastodonFeedHTML/MastodonFeedHTML.py
@@ -12,8 +12,6 @@ from email.mime.text import MIMEText
from urllib.request import urlopen, Request
from Config import *
-StripWS = '\t\r\n'
-
def SureList(Item):
return Item if type(Item) == list else [Item]
@@ -26,7 +24,7 @@ def MakePathStr(Str):
def HandleFeed(URLs, IncludeRetoots, IncludeReplies, LocalSave, SendMail, MailTo):
for URL in URLs:
- URL = URL.rstrip('/').rstrip('/with_replies') + '/with_replies'
+ URL = URL.removesuffix('/').removesuffix('/with_replies') + '/with_replies'
Usertag = f"{URL.split('/')[-2]}@{URL.split('/')[-3]}"
try:
Response = urlopen(Request(URL, headers={'User-Agent':UserAgent}))
@@ -39,26 +37,26 @@ def HandleFeed(URLs, IncludeRetoots, IncludeReplies, LocalSave, SendMail, MailTo
Attached = ''
GlobalId = Entry.find('a', class_='u-url')
if GlobalId:
- GlobalId = GlobalId['href'].lstrip('https://').lstrip('http://')
+ GlobalId = GlobalId['href'].removeprefix('https://').removeprefix('http://')
else:
continue
if os.path.isfile(f'{AppName}.db'):
with open(f'{AppName}.db', 'r') as Db:
- if GlobalId in Db.read().splitlines():
+ if f'{Usertag} {GlobalId}' in Db.read().splitlines():
continue
LocalId = GlobalId.split('/')[-1]
- Username = Entry.find('a', class_='status__display-name').get_text().strip(StripWS)
+ Username = Entry.find('a', class_='status__display-name').get_text().strip()
Content = Entry.find('div', class_='e-content')
StatusPrepend = Entry.find('div', class_='status__prepend')
- StatusPrepend = StatusPrepend.get_text().strip(StripWS)[len(Username):] if StatusPrepend else ''
- StatusPrepend = ' ' + StatusPrepend.strip(StripWS) if StatusPrepend else ''
+ StatusPrepend = StatusPrepend.get_text().strip()[len(Username):] if StatusPrepend else ''
+ StatusPrepend = ' ' + StatusPrepend.strip() if StatusPrepend else ''
if not IncludeRetoots and StatusPrepend:
continue
if not StatusPrepend and IncludeReplies and Entry.find('i', class_='fa-reply-all'):
StatusPrepend = ' replied'
- Title = Content.get_text().strip(StripWS)
+ Title = Content.get_text().strip()
Title = f"{Usertag}{StatusPrepend}: {Title[:32]}..."
for Emoji in Entry.find_all('img', class_='custom-emoji'): # Custom emojis in text
Emoji['style'] = 'max-height:1em;'
@@ -90,7 +88,7 @@ def HandleFeed(URLs, IncludeRetoots, IncludeReplies, LocalSave, SendMail, MailTo
if Attachments:
for Attachment in Attachments:
Href, Alt = '', ''
- Attachment = str(Attachment).strip(StripWS).replace("'",'"').split('"')
+ Attachment = str(Attachment).strip().replace("'",'"').split('"')
for i,e in enumerate(Attachment):
if e.endswith('