Fix slug generation method

This commit is contained in:
DevilXD committed 2023-10-19 22:09:29 +02:00
1 parent f990aeea38
commit 1d26988721
2 files changed
+9 -1

No files matched your search

+2
View File
@@ -1698,10 +1698,12 @@ class Twitch:
},
})
)
if "game" in response["data"]:
return [
Channel.from_directory(self, stream_channel_data["node"], drops_enabled=True)
for stream_channel_data in response["data"]["game"]["streams"]["edges"]
]
return []
async def claim_points(self, channel_id: str | int, claim_id: str) -> None:
await self.gql_request(
+7 -1
View File
@@ -409,4 +409,10 @@ class Game:
"""
Converts the game name into a slug, useable for the GQL API.
"""
return re.sub(r'(?![- ])\W', '', self.name.lower().replace(' ', '-'))
# remove specific characters
slug_text = re.sub(r'\'', '', self.name.lower())
# remove non alpha-numeric characters
slug_text = re.sub(r'\W+', '-', slug_text)
# strip and collapse dashes
slug_text = re.sub(r'-{2,}', '-', slug_text.strip('-'))
return slug_text