diff --git a/mastotuit.py b/mastotuit.py index 094a710..955cfa7 100644 --- a/mastotuit.py +++ b/mastotuit.py @@ -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', '') - - 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 + is_poll = False if "input disable" not in entry.summary else True if is_poll: + poll_substring = """""" + + poll_options = title.count(poll_substring) + + remaining_str = title + + i = poll_options + while (i > 0): + + last_option_index = remaining_str.rfind(poll_substring) + + if i == poll_options: + + option_str = remaining_str[last_option_index+42:].strip().replace('

','') + + else: + + option_str = remaining_str[last_option_index+42:].strip().replace('
','') + + 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) diff --git a/requirements.txt b/requirements.txt index d06604c..b78b217 100644 --- a/requirements.txt +++ b/requirements.txt @@ -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