Skip to content

Commit

Permalink
Fix exceptions on auth, use auth for ads endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
lxcode committed Oct 6, 2024
1 parent a651968 commit b2c747c
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions truthbrush/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,16 +96,19 @@ def _check_ratelimit(self, resp):
sleep(10)

def _get(self, url: str, params: dict = None) -> Any:
resp = self._make_session().get(
API_BASE_URL + url,
params=params,
proxies=proxies,
impersonate="chrome120",
headers={
"Authorization": "Bearer " + self.auth_id,
"User-Agent": USER_AGENT,
},
)
try:
resp = self._make_session().get(
API_BASE_URL + url,
params=params,
proxies=proxies,
impersonate="chrome123",
headers={
"Authorization": "Bearer " + self.auth_id,
"User-Agent": USER_AGENT,
},
)
except curl_cffi.curl.CurlError as e:
logger.error(f"Curl error: {e}")

# Will also sleep
self._check_ratelimit(resp)
Expand Down Expand Up @@ -306,6 +309,7 @@ def suggested_groups(self, maximum: int = 50) -> dict:
def ads(self, device: str = "desktop") -> dict:
"""Return a list of ads from Rumble's Ad Platform via Truth Social API."""

self.__check_login()
return self._get(f"/v3/truth/ads?device={device}")

def user_followers(
Expand Down

0 comments on commit b2c747c

Please sign in to comment.