def run(self):
try:<EOL><INDENT>answer = urlopen(self.url + "<STR_LIT>").read().decode()<EOL><DEDENT>except (HTTPError, URLError) as error:<EOL><INDENT>self.output = {<EOL>"<STR_LIT>": str(error.reason),<EOL>"<STR_LIT>": "<STR_LIT>"<EOL>}<EOL>return<EOL><DEDENT>answer = json.loads(answer)<EOL>if not answer.get("<STR_LIT:status>", True):<EOL><INDENT>self.output = {<EOL>"<STR_LIT>": answer["<STR_LIT:error>"],<EOL>"<STR_LIT>": "<STR_LIT>"<EOL>}<EOL>return<EOL><DEDENT>queue = answer["<STR_LIT>"]<EOL>self.status = queue["<STR_LIT:status>"]<EOL>if self.is_paused():<EOL><INDENT>color = self.color_paused<EOL><DEDENT>elif self.is_downloading():<EOL><INDENT>color = self.color_downloading<EOL><DEDENT>else:<EOL><INDENT>color = self.color<EOL><DEDENT>if self.is_downloading():<EOL><INDENT>full_text = self.format.format(**queue)<EOL><DEDENT>else:<EOL><INDENT>full_text = self.format_paused.format(**queue)<EOL><DEDENT>self.output = {<EOL>"<STR_LIT>": full_text,<EOL>"<STR_LIT>": color<EOL>}<EOL>
Connect to SABnzbd and get the data.