Add support for json url for playerskins DB
parent
b9e7ed45b7
commit
a454625207
|
@ -5,6 +5,7 @@ import html
|
||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
import pathlib
|
import pathlib
|
||||||
|
import requests
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
import appdirs
|
import appdirs
|
||||||
|
@ -87,10 +88,10 @@ def main():
|
||||||
)
|
)
|
||||||
top8_parser.add_argument(
|
top8_parser.add_argument(
|
||||||
"--playerskinsdb", "-PD",
|
"--playerskinsdb", "-PD",
|
||||||
type = pathlib.Path,
|
type = (lambda s: s if s.startswith("http") else pathlib.Path(s)),
|
||||||
default = ROOTDIR / "data" / "playerskinsdb.json",
|
default = ROOTDIR / "data" / "playerskinsdb.json",
|
||||||
help = "A JSON file matching player tags, characters and " \
|
help = "A JSON file path or urk matching player tags, characters,"\
|
||||||
"preferred skins",
|
" sponsors, and preferred skins",
|
||||||
)
|
)
|
||||||
top8_parser.add_argument(
|
top8_parser.add_argument(
|
||||||
"--cachedir", "-CD",
|
"--cachedir", "-CD",
|
||||||
|
@ -209,8 +210,11 @@ def main():
|
||||||
# Initialize PLAYERSKINS db
|
# Initialize PLAYERSKINS db
|
||||||
log.debug("loading playerskins db from '{}'" \
|
log.debug("loading playerskins db from '{}'" \
|
||||||
.format(args.playerskinsdb))
|
.format(args.playerskinsdb))
|
||||||
with args.playerskinsdb.open("r", encoding="utf8") as f:
|
try:
|
||||||
smashgg.PLAYERSKINS = json.load(f)
|
smashgg.PLAYERSKINS = requests.get(args.playerskinsdb).json()
|
||||||
|
except:
|
||||||
|
with args.playerskinsdb.open("r", encoding="utf8") as f:
|
||||||
|
smashgg.PLAYERSKINS = json.load(f)
|
||||||
|
|
||||||
#
|
#
|
||||||
tournament = None
|
tournament = None
|
||||||
|
|
Loading…
Reference in New Issue