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

View File

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