Move logout h
into the State model
This commit is contained in:
@@ -284,13 +284,14 @@ class Client(object):
|
|||||||
else:
|
else:
|
||||||
fb_dtsg = re.search(r'name="fb_dtsg" value="(.*?)"', r.text).group(1)
|
fb_dtsg = re.search(r'name="fb_dtsg" value="(.*?)"', r.text).group(1)
|
||||||
|
|
||||||
fb_h_element = soup.find("input", {"name": "h"})
|
logout_h = None
|
||||||
if fb_h_element:
|
logout_h_element = soup.find("input", {"name": "h"})
|
||||||
self._fb_h = fb_h_element["value"]
|
if logout_h_element:
|
||||||
|
logout_h = logout_h_element["value"]
|
||||||
|
|
||||||
revision = int(r.text.split('"client_revision":', 1)[1].split(",", 1)[0])
|
revision = int(r.text.split('"client_revision":', 1)[1].split(",", 1)[0])
|
||||||
|
|
||||||
self._state = State(fb_dtsg=fb_dtsg, revision=revision)
|
self._state = State(fb_dtsg=fb_dtsg, revision=revision, logout_h=logout_h)
|
||||||
|
|
||||||
def _login(self, email, password):
|
def _login(self, email, password):
|
||||||
soup = bs(self._get("https://m.facebook.com/").text, "html.parser")
|
soup = bs(self._get("https://m.facebook.com/").text, "html.parser")
|
||||||
@@ -468,16 +469,15 @@ class Client(object):
|
|||||||
:return: True if the action was successful
|
:return: True if the action was successful
|
||||||
:rtype: bool
|
:rtype: bool
|
||||||
"""
|
"""
|
||||||
if not hasattr(self, "_fb_h"):
|
logout_h = self._state.logout_h
|
||||||
|
if not logout_h:
|
||||||
h_r = self._post("/bluebar/modern_settings_menu/", {"pmid": "4"})
|
h_r = self._post("/bluebar/modern_settings_menu/", {"pmid": "4"})
|
||||||
self._fb_h = re.search(r'name=\\"h\\" value=\\"(.*?)\\"', h_r.text).group(1)
|
logout_h = re.search(r'name=\\"h\\" value=\\"(.*?)\\"', h_r.text).group(1)
|
||||||
|
|
||||||
data = {"ref": "mb", "h": self._fb_h}
|
data = {"ref": "mb", "h": logout_h}
|
||||||
|
|
||||||
r = self._get("/logout.php", data)
|
r = self._get("/logout.php", data)
|
||||||
|
|
||||||
self._resetValues()
|
self._resetValues()
|
||||||
|
|
||||||
return r.ok
|
return r.ok
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
@@ -13,6 +13,11 @@ class State(object):
|
|||||||
fb_dtsg = attr.ib(None)
|
fb_dtsg = attr.ib(None)
|
||||||
_revision = attr.ib(None)
|
_revision = attr.ib(None)
|
||||||
_counter = attr.ib(0)
|
_counter = attr.ib(0)
|
||||||
|
_logout_h = attr.ib(None)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def logout_h(self):
|
||||||
|
return self._logout_h
|
||||||
|
|
||||||
def get_params(self):
|
def get_params(self):
|
||||||
if self.fb_dtsg is None:
|
if self.fb_dtsg is None:
|
||||||
|
Reference in New Issue
Block a user