replace string parts with replacement values

This commit is contained in:
dekzter 2025-03-18 13:38:22 -04:00
parent a2f5eaa780
commit 133dc509aa

View file

@ -126,10 +126,20 @@ class StreamProfile(models.Model):
"{userAgent}": user_agent,
}
cmd = [self.command] + [replacements.get(part, part) for part in self.parameters.split()]
# Split the command and iterate through each part to apply replacements
cmd = [self.command] + [
self._replace_in_part(part, replacements) for part in self.parameters.split()
]
return cmd
def _replace_in_part(self, part, replacements):
# Iterate through the replacements and replace each part of the string
for key, value in replacements.items():
part = part.replace(key, value)
return part
DEFAULT_USER_AGENT_KEY= slugify("Default User-Agent")
DEFAULT_STREAM_PROFILE_KEY = slugify("Default Stream Profile")