Debloat HTML
This commit is contained in:
parent
c7c2d86ddb
commit
547d4e6ab1
18 changed files with 874 additions and 1284 deletions
|
|
@ -60,7 +60,7 @@ class Command(BaseCommand):
|
|||
help="Delay in seconds between retries for database operations (default: 0.5)",
|
||||
)
|
||||
|
||||
def handle(self, **options) -> None: # noqa: ANN003
|
||||
def handle(self, **options) -> None:
|
||||
"""Execute the command.
|
||||
|
||||
Args:
|
||||
|
|
@ -268,7 +268,7 @@ class Command(BaseCommand):
|
|||
id=campaign_data["id"],
|
||||
defaults={
|
||||
"name": campaign_data["name"],
|
||||
"description": campaign_data["description"],
|
||||
"description": campaign_data["description"].replace("\\n", "\n"),
|
||||
"details_url": campaign_data.get("detailsURL", ""),
|
||||
"account_link_url": campaign_data.get("accountLinkURL", ""),
|
||||
"image_url": campaign_data.get("imageURL", ""),
|
||||
|
|
|
|||
|
|
@ -74,17 +74,31 @@ class DropCampaign(models.Model):
|
|||
Examples:
|
||||
"Ravendawn - July 2" -> "July 2"
|
||||
"Party Animals Twitch Drop" -> "Twitch Drop"
|
||||
"Skull & Bones - Closed Beta" -> "Closed Beta" (& is replaced with "and")
|
||||
"""
|
||||
if not self.game or not self.game.display_name:
|
||||
return self.name
|
||||
|
||||
game_name = self.game.display_name
|
||||
# Try different variations of the game name
|
||||
game_variations = [self.game.display_name]
|
||||
|
||||
# Add & to "and" conversion
|
||||
if "&" in self.game.display_name:
|
||||
game_variations.append(self.game.display_name.replace("&", "and"))
|
||||
|
||||
# Add "and" to & conversion
|
||||
if "and" in self.game.display_name:
|
||||
game_variations.append(self.game.display_name.replace("and", "&"))
|
||||
|
||||
# Check each variation
|
||||
for game_name in game_variations:
|
||||
if not self.name.startswith(game_name):
|
||||
continue
|
||||
|
||||
# Remove game name if it's at the beginning of the campaign name
|
||||
if self.name.startswith(game_name):
|
||||
# Check if it's followed by a separator like " - "
|
||||
if self.name[len(game_name) :].startswith(" - "):
|
||||
return self.name[len(game_name) + 3 :].strip()
|
||||
|
||||
# Or just remove the game name if it's followed by a space
|
||||
if len(self.name) > len(game_name) and self.name[len(game_name)] == " ":
|
||||
return self.name[len(game_name) + 1 :].strip()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue