Skip to content
This repository has been archived by the owner on Jul 5, 2024. It is now read-only.

Commit

Permalink
add error wrapper for redgifs token
Browse files Browse the repository at this point in the history
  • Loading branch information
Jules-WinnfieldX committed Jan 1, 2024
1 parent 65756f2 commit 91ffad8
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 80 deletions.
2 changes: 1 addition & 1 deletion cyberdrop_dl/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "5.1.28"
__version__ = "5.1.29"
16 changes: 9 additions & 7 deletions cyberdrop_dl/scraper/crawlers/redgifs_crawler.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,13 @@ async def fetch(self, scrape_item: ScrapeItem) -> None:
task_id = await self.scraping_progress.add_task(scrape_item.url)

if not self.token:
await self.manage_token()
await self.manage_token(self.redgifs_api / "v2/auth/temporary")

if "users" in scrape_item.url.parts:
await self.user(scrape_item)
else:
await self.post(scrape_item)
if self.token:
if "users" in scrape_item.url.parts:
await self.user(scrape_item)
else:
await self.post(scrape_item)

await self.scraping_progress.remove_task(task_id)

Expand Down Expand Up @@ -89,9 +90,10 @@ async def post(self, scrape_item: ScrapeItem) -> None:

"""~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"""

async def manage_token(self) -> None:
@error_handling_wrapper
async def manage_token(self, token_url: URL) -> None:
"""Gets/Sets the redgifs token and header"""
async with self.request_limiter:
json_obj = await self.client.get_json(self.domain, self.redgifs_api / "v2/auth/temporary")
json_obj = await self.client.get_json(self.domain, )
self.token = json_obj["token"]
self.headers = {"Authorization": f"Bearer {self.token}"}
Loading

0 comments on commit 91ffad8

Please sign in to comment.