Add --use-smashgg-prefix option

Since most local results don't use player-set prefixes from smash.gg but
rather sponsor infos from the playerskins DB, it's easier to toggle off
the download of those prefixes from smash.gg by default.
master
Lertsenem 2020-09-02 09:07:36 +02:00
parent 9fd12d7a90
commit 4c6408bd61
2 changed files with 17 additions and 2 deletions

View File

@ -104,6 +104,7 @@ def main():
default = ROOTDIR / "templates",
help = "The local result templates directory",
)
top8_parser.add_argument(
"--template", "-T",
default = "rebootlyon2020",
@ -115,6 +116,7 @@ def main():
default = [],
help = "Template-specific options",
)
top8_parser.add_argument(
"--lkrz-file", "-f",
type = pathlib.Path,
@ -129,6 +131,7 @@ def main():
help = "The SVG or PNG local result file to output to ; if it's " \
"not specified, it will use the tournament slug as name",
)
top8_parser.add_argument(
"--name-seo-delimiter",
default = None,
@ -138,6 +141,12 @@ def main():
"Lyon', only the 'Cornismash #42' is the tournament name, "\
"the rest is here to help find the tournament).",
)
top8_parser.add_argument(
"--use-smashgg-prefixes", "-P",
action = "store_true",
help = "Use the prefixes (sponsor, team, etc) set by players on " \
"smash.gg for the tournament",
)
# -------------------------------------------------------------------------
parser.add_argument( "--verbose", "-v",
@ -254,6 +263,7 @@ def main():
# Get infos from smash.gg and write the config file
tournament, top_players = getTournamentTop(
id_or_slug = args.tournament,
get_prefixes = args.use_smashgg_prefixes,
top = 8,
token = args.token,
proxy = args.proxy,
@ -322,6 +332,7 @@ def main():
# -----------------------------------------------------------------------------
def getTournamentTop(
id_or_slug,
get_prefixes = True,
top=8,
token = "",
proxy = None,
@ -450,10 +461,14 @@ def getTournamentTop(
except TypeError:
twitterHandle = None
if get_prefixes:
prefix = participant_data["prefix"]
else:
prefix = ""
player = smashgg.Player(
id = standing["entrant"]["id"],
prefix = participant_data["prefix"],
prefix = prefix,
gamerTag = participant_data["gamerTag"],
placement = standing["placement"],
seeding = seeding,

View File

@ -44,7 +44,7 @@ class Player():
self.seeding = int(seeding)
self.twitterHandle = ( "" if twitterHandle is None else twitterHandle )
# Prefix is superseeded by sponsors infos
# Prefix is superseeded by sponsors infos in DB
try:
self.prefix = PLAYERSKINS[self.gamerTag.lower()]["sponsor"]
except: