This commit is contained in:
spla 2022-07-16 11:11:26 +02:00
pare 31a4b0a6e2
commit 432528e987
S'han modificat 2 arxius amb 31 adicions i 17 eliminacions

Veure arxiu

@ -37,30 +37,44 @@ def get_toot_text(title):
def get_poll(tuit_text):
poll_substring = '[ ]'
poll_options = tuit_text.count(poll_substring)
is_poll = False if poll_options == 0 else True
poll_options = 0
options_lst = []
remain_str = tuit_text.replace('\n', '')
is_poll = False if "input disable" not in entry.summary else True
if is_poll:
poll_substring = """<input disabled="disabled" type="radio" />"""
poll_options = title.count(poll_substring)
remaining_str = title
i = poll_options
while (i > 0):
last_option_index = remain_str.rfind('[ ]')
option_str = remain_str[last_option_index+3:].strip()
options_lst.append(option_str)
remain_str = remain_str[:last_option_index]
i-=1
last_option_index = remaining_str.rfind(poll_substring)
if is_poll:
if i == poll_options:
option_str = remaining_str[last_option_index+42:].strip().replace('</p>','')
else:
option_str = remaining_str[last_option_index+42:].strip().replace('<br />','')
options_lst.append(option_str)
remaining_str = remaining_str[:last_option_index]
i-=1
options_lst_copy = options_lst.copy()
options_lst_copy.reverse()
options_lst = options_lst_copy.copy()
tuit_text = remain_str
first_option_index = tuit_text.rfind(options_lst[0])
tuit_text = tuit_text[:first_option_index-1]
return (tuit_text, poll_options, options_lst, is_poll)

Veure arxiu

@ -1,7 +1,7 @@
wheel>=0.37.0
psycopg2>=2.9.1
psycopg2-binary
feedparser>=6.0.8
bs4>=4.10.0
bs4
Mastodon.py>=1.5.1
tweepy>=4.5.0
filetype>=1.0.8