def __parse_ssr(self, ssr_base64: str): ssr = ssr_base64.split('#')[0] ssr = base64.decode(ssr) if isinstance(ssr, bytes): return ssr_list = ssr.split(':') password_and_params = ssr_list[5].split('/?') self._server = ssr_list[0] self._port = int(ssr_list[1]) self._protocol = ssr_list[2] self._method = ssr_list[3] self._obfs = ssr_list[4] self._password = base64.decode(password_and_params[0]) params_dict = dict() for param in password_and_params[1].split('&'): param_list = param.split('=') params_dict[param_list[0]] = base64.decode(param_list[1]) params_dict_keys = params_dict.keys() for key in ['proto_param', 'obfs_param', 'remarks', 'group']: tmp_key = key.replace('_', '') if tmp_key in params_dict_keys: setattr(self, '_{}'.format(key), params_dict[tmp_key])
def __parse_ss(self, ss_base64: str): ss = ss_base64.split('#') if len(ss) > 1: self._remarks = urllib.parse.unquote(ss[1]) ss = base64.decode(ss[0]) if isinstance(ss, bytes): return # use split and join, in case of the password contains "@"/":" str_list = ss.split('@') server_and_port = str_list[-1].split(':') method_and_pass = '******'.join(str_list[0:-1]).split(':') self._server = server_and_port[0] self._port = int(server_and_port[1]) self._method = method_and_pass[0] self._password = '******'.join(method_and_pass[1:])
def get_urls_by_base64(text_base64: str): text = base64.decode(text_base64) if isinstance(text, str): return list_fn.remove_and_unique(text.split('\n')) return list()