From b71331a102a3ab48490d0dec337bcd89de1b43b2 Mon Sep 17 00:00:00 2001 From: ErrorNoInternet Date: Wed, 5 Feb 2025 17:23:51 -0500 Subject: [PATCH] refactor: fix casing andn add type hints --- arguments.py | 2 +- extra.py | 2 +- sponsorblock.py | 12 ++++++------ 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/arguments.py b/arguments.py index 7d19968..1760028 100644 --- a/arguments.py +++ b/arguments.py @@ -34,7 +34,7 @@ class ArgumentParser: await utils.reply(message, f"`{e}`") -def range_type(string, min=0, max=100): +def range_type(string: str, min=0, max=100): try: value = int(string) except ValueError: diff --git a/extra.py b/extra.py index dd3e76f..b15b748 100644 --- a/extra.py +++ b/extra.py @@ -81,7 +81,7 @@ def messages_per_second(limit=500): ) -async def auto_count(channel_id): +async def auto_count(channel_id: int): if (channel := await client.fetch_channel(channel_id)) and isinstance( channel, disnake.TextChannel ): diff --git a/sponsorblock.py b/sponsorblock.py index b095538..6a4e409 100644 --- a/sponsorblock.py +++ b/sponsorblock.py @@ -10,11 +10,11 @@ CATEGORY_NAMES = { } -async def get_segments(videoId: str): - if videoId in sponsorblock_cache: - return sponsorblock_cache[videoId] +async def get_segments(video_id: str): + if video_id in sponsorblock_cache: + return sponsorblock_cache[video_id] - hashPrefix = hashlib.sha256(videoId.encode()).hexdigest()[:4] + hashPrefix = hashlib.sha256(video_id.encode()).hexdigest()[:4] session = aiohttp.ClientSession() response = await session.get( f"https://sponsor.ajay.app/api/skipSegments/{hashPrefix}", @@ -22,8 +22,8 @@ async def get_segments(videoId: str): ) if response.status == 200 and ( results := list( - filter(lambda v: videoId == v["videoID"], await response.json()) + filter(lambda v: video_id == v["videoID"], await response.json()) ) ): - sponsorblock_cache[videoId] = results[0] + sponsorblock_cache[video_id] = results[0] return results[0]