diff --git a/main.py b/main.py
index 069b414..6bb7283 100755
--- a/main.py
+++ b/main.py
@@ -3,6 +3,7 @@ from settings import *
from mastodon import Mastodon
from os.path import exists
import tweepy
+from lxml.html import document_fromstring
def main():
if not exists(app_path):
Mastodon.create_app(
@@ -36,7 +37,33 @@ def main():
timeline = mastodon_api.account_statuses(mastodon_user,exclude_replies=True)
for toot in timeline:
if(toot.visibility == 'public' and toot.account.id == mastodon_user.id and not toot.reblog):
- print(toot)
+ tootfrm(toot.content)
#print(timeline)
+def tootfrm(content):
+ content = content.replace('
', "\n")
+ res = document_fromstring(content)
+ printit(res, "")
+ print(res.text_content())
+def printit(parent, body, block=" "):
+ for el in parent:
+ # print(block, el, el.text_content())
+ if 'u-url' in el.classes:
+ el.text = el.text_content() + "@grml.de"
+ el.find('.//span').text = ''
+ el.find('.//span').drop_tag()
+ # for classname in iter(el.classes):
+ # print(block + " " + classname)
+ body = printit(el, body, block + " ")
+ return body
+def test():
+ content = '
Python Test #ignore
@toot
https://twitter.com/mattxiv/status/1529181072931659777
#python #test