Skip to content

Commit

Permalink
facebook: remove redundant not_available_right_now
Browse files Browse the repository at this point in the history
  • Loading branch information
naisanzaa committed Nov 9, 2024
1 parent 99860c7 commit 61c1351
Showing 1 changed file with 8 additions and 23 deletions.
31 changes: 8 additions & 23 deletions automon/integrations/facebook/groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ def __init__(self, url: str = None):
self._visible = None
self._blocked_by_login = None
self._browser_not_supported = None
self._not_available_right_now = None

def blocked_by_login(self):
try:
Expand Down Expand Up @@ -108,8 +107,15 @@ def content_unavailable(self):
"""This content isn't available right now"""

try:
self._content_unavailable = self._browser.wait_for_xpath(self._xpath_content_unavailable, timeout=5)
self._content_unavailable = self._browser.wait_for_anything(
match="This content isn't available right now",
value='span',
value_attr='text',
by=self._browser.by.TAG_NAME,
exact_match=True
)
if self._content_unavailable:
self._content_unavailable = self._content_unavailable[0]
self._content_unavailable = self._content_unavailable.text
logger.debug(self._content_unavailable)
return self._content_unavailable
Expand Down Expand Up @@ -248,24 +254,6 @@ def must_login(self):
message, session, stacktrace = self.error_parsing(error)
logger.error(f'{self.url} :: {message=} :: {session=} :: {stacktrace=}')

def not_available_right_now(self):
try:
self._not_available_right_now = self._browser.wait_for_anything(
match="This content isn't available right now",
value='span',
value_attr='text',
by=self._browser.by.TAG_NAME,
exact_match=True
)
if self._not_available_right_now:
self._not_available_right_now = self._not_available_right_now[0]
self._not_available_right_now = self._not_available_right_now.text
logger.debug(self._not_available_right_now)
return self._not_available_right_now
except Exception as error:
message, session, stacktrace = self.error_parsing(error)
logger.error(f'{self.url} :: {message=} :: {session=} :: {stacktrace=}')

def posts_monthly(self):

try:
Expand Down Expand Up @@ -566,7 +554,6 @@ def reset_cache(self):
self._visible = None
self._blocked_by_login = None
self._browser_not_supported = None
self._not_available_right_now = None

def reset_rate_counter(self):
self.RATE_COUNTER = []
Expand Down Expand Up @@ -659,7 +646,6 @@ def to_dict(self):
visible=self._visible or self.visible(),
blocked_by_login=self._blocked_by_login or self.blocked_by_login(),
browser_not_supported=self._browser_not_supported or self.browser_not_supported(),
not_available_right_now=self._not_available_right_now or self.not_available_right_now(),
)

def to_empty(self):
Expand All @@ -681,7 +667,6 @@ def to_empty(self):
visible=None,
blocked_by_login=None,
browser_not_supported=None,
not_available_right_now=self._not_available_right_now or self.not_available_right_now(),
)

def quit(self):
Expand Down

0 comments on commit 61c1351

Please sign in to comment.