|
|
|
@ -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:
|
|
|
|
|
|
|
|
|
|
i = poll_options
|
|
|
|
|
while (i > 0):
|
|
|
|
|
poll_substring = """<input disabled="disabled" type="radio" />"""
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
poll_options = title.count(poll_substring)
|
|
|
|
|
|
|
|
|
|
if is_poll:
|
|
|
|
|
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('</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)
|
|
|
|
|
|
|
|
|
|