Coder Social home page Coder Social logo

crflynn / chicken-dinner Goto Github PK

View Code? Open in Web Editor NEW
38.0 7.0 10.0 2.08 GB

Python PUBG API wrapper and CLI with replay visualizations

Home Page: http://chicken-dinner.readthedocs.io

License: MIT License

Python 99.54% Shell 0.20% Makefile 0.27%
pubg pubg-api pubg-replays chicken-dinner playerunknowns-battlegrounds cli

chicken-dinner's Introduction

Chicken Dinner

rtd pypi pyversions

Python PUBG JSON API Wrapper and (optional) playback visualizer.

Also includes basic CLI functionality for replays, leaderboards, stats, and updating assets.

Samples

Installation

To install chicken-dinner, use pip. This will install the core dependencies which provide functionality to the API wrapper and CLI.

pip install chicken-dinner

To use the playback visualizations you will need to install the library with extra dependencies for plotting (matplotlib and pillow). For this you can also use pip:

pip install chicken-dinner[visual]

To generate the animations you will also need ffmpeg installed on your machine. On Max OSX you can install ffmpeg using brew.

brew install ffmpeg

You can install ffmpeg on other systems from here.

Usage

Working with the low-level API class.

from chicken_dinner.pubgapi import PUBGCore

api_key = "your_api_key"
pubgcore = PUBGCore(api_key, "pc-na")
shroud = pubgcore.players("player_names", "shroud")
print(shroud)

# {'data': [{'type': 'player', 'id': 'account.d50f...

Working with the high-level API class.

from chicken_dinner.pubgapi import PUBG

api_key = "your_api_key"
pubg = PUBG(api_key, "pc-na")
shroud = pubg.players_from_names("shroud")[0]
shroud_season = shroud.get_current_season()
squad_fpp_stats = shroud_season.game_mode_stats("squad", "fpp")
print(squad_fpp_stats)

# {'assists': 136, 'boosts': 313, 'dbnos': 550, 'daily_kills':...

Visualizing telemetry data

from chicken_dinner.pubgapi import PUBG

api_key = "your_api_key"
pubg = PUBG(api_key, "pc-na")
shroud = pubg.players_from_names("shroud")[0]
recent_match_id = shroud.match_ids[0]
recent_match = pubg.match(recent_match_id)
recent_match_telemetry = recent_match.get_telemetry()
recent_match_telemetry.playback_animation("recent_match.html")

Recommended playback settings:

telemetry.playback_animation(
    "match.html",
    zoom=True,
    labels=True,
    label_players=[],
    highlight_winner=True,
    label_highlights=True,
    size=6,
    end_frames=60,
    use_hi_res=False,
    color_teams=True,
    interpolate=True,
    damage=True,
    interval=2,
    fps=30,
)

See the documentation for more details.

CLI

For CLI commands using the PUBG API, an API Key is required. You may provide the API key via an environment variable named PUBG_API_KEY or with the CLI option --api-key

export PUBG_API_KEY=your_pubg_api_key
chicken-dinner [command] --shard=steam ...

OR

chicken-dinner [command] --api-key=your_pubg_api_key --shard=steam ...

A shard is optional, but the default shard is steam.

Assets

To update local assets, including hi-res maps and asset dictionaries:

chicken-dinner assets

Leaderboards

Display the leaderboards for a game mode (shard default is steam):

chicken-dinner leaderboard --shard=steam solo-fpp

Player Stats

Display player stats for lifetime or the current season (shard default is steam):

# Get the lifetime stats for chocoTaco in solo-fpp
chicken-dinner stats --shard=steam --lifetime --group=solo --perspective=fpp chocoTaco

# Get the latest season stats for chocoTaco in solo-fpp
chicken-dinner stats -g solo -p fpp chocoTaco

Replays

Generate html5 replays for matches (shard default is steam):

# Generate a replay for the latest win of chocoTaco in specified path
chicken-dinner replay --latest --wins-only --size=6 --path=/path/to/my/replays chocoTaco

# Generate a replay for the latest game of chocoTaco
chicken-dinner replay -l chocoTaco

# Generate a replay for all of chocoTaco's wins in recent games
chicken-dinner replay -w chocoTaco

# Generate a replay for all of the recent games of chocoTaco
chicken-dinner replay chocoTaco

More Examples

Setup

Creating a PUBG instance.

from chicken_dinner.pubgapi import PUBG

api_key = "my_api_key"
pubg = PUBG(api_key=api_key, shard="steam")

Player Examples

Getting information for a player by their name.

# Creates a Players instance (iterable Player instances)
players = pubg.players_from_names("chocoTaco")

# Take the first Player instance from the iterable
chocotaco = players[0]

chocotaco.name
# chocoTaco

chocotaco.match_ids
# ['e0b3cb15-929f-4b42-8873-68a8f9998d2b', 'dd25cf69-77f1-4791-9b14-657e904d3534'...

chocotaco.id
# 'account.15cbf322a9bc45e88b0cd9f12ef4188e'

chocotaco.url
# 'https://api.playbattlegrounds.com/shards/steam/players/account.15cbf322a9bc45e88b0cd9f12ef4188e'

Or get the player instance from the id.

# Creates a Players instance (iterable Player instances)
players = pubg.players_from_ids("account.15cbf322a9bc45e88b0cd9f12ef4188e")

# Take the first Player instance from the iterable
chocotaco = players[0]

Get information about multiple players and matches that they participated together.

# Creates a Players instance (iterable of Player instances)
players = pubg.players_from_names(["shroud", "chocoTaco"])

players.ids
# ['account.d50fdc18fcad49c691d38466bed6f8fd', 'account.15cbf322a9bc45e88b0cd9f12ef4188e']

players.names_to_ids()
# {'shroud': 'account.d50fdc18fcad49c691d38466bed6f8fd', 'chocoTaco': 'account.15cbf322a9bc45e88b0cd9f12ef4188e'}

players.ids_to_names()
# {'account.d50fdc18fcad49c691d38466bed6f8fd': 'shroud', 'account.15cbf322a9bc45e88b0cd9f12ef4188e': 'chocoTaco'}

players.shared_matches()
# ['e0b3cb15-929f-4b42-8873-68a8f9998d2b', 'dd25cf69-77f1-4791-9b14-657e904d3534'...

shroud = players[0]
chocotaco = players[1]

Season Examples

Get an iterable of Seasons objects

seasons = pubg.seasons()

seasons.ids
# ['division.bro.official.2017-beta', 'division.bro.official.2017-pre1'...

# Get the current season
current_season = seasons.current()

Work with a Season instance

season = pubg.current_season()

season.id
# 'division.bro.official.pc-2018-04'

season.is_current()
# True

season.is_offseason()
# False

# Get a player-season for a specific player
chocotaco_season = season.get_player("account.15cbf322a9bc45e88b0cd9f12ef4188e")

Getting information about a player-season

# Using the factory instance directly
chocotaco_season = pubg.player_season("account.15cbf322a9bc45e88b0cd9f12ef4188e", "division.bro.official.pc-2018-04")

# Using a season
season = pubg.current_season()
chocotaco_season = season.get_player("account.15cbf322a9bc45e88b0cd9f12ef4188e")

# Using a player
chocotaco = pubg.players_from_names("chocoTaco")[0]
chocotaco_season = chocotaco.get_season("division.bro.official.pc-2018-04")

chocotaco_season.id
# {'player_id': 'account.15cbf322a9bc45e88b0cd9f12ef4188e', 'season_id': 'division.bro.official.pc-2018-04'}

chocotaco_season.player_id
# 'account.15cbf322a9bc45e88b0cd9f12ef4188e'

chocotaco_season.season_id
# 'division.bro.official.pc-2018-04'

chocotaco_season.match_ids("solo", "fpp")
# ['4b0c5898-7149-4bcc-8da7-df4cdc07fd80', 'b26880e5-916d-4be8-abd7-45d8dddb6df3'...

chocotaco_season.game_mode_stats("solo", "fpp")
# {'assists': 38, 'boosts': 498, 'dbnos': 0, 'daily_kills': 18, 'daily_wins': 0, 'damage_dealt': 95036.79...

Leaderboards

Leaderboards give the top 25 players for a particular game mode.

solo_fpp_leaderboard = pubg.leaderboard("solo-fpp")

solo_fpp_leaderboard.game_mode
# 'solo-fpp'

solo_fpp_leaderboard.ids
# ['account.cfb13f65d5d1452294efbe7e730f7b1c', 'account.9affa4ff8e5746bbb6a199f1a773c659'...

solo_fpp_leaderboard.names
# ['HuYa-17152571', 'Huya_15007597_LS', 'Douyu-7250640', 'Douyu-4778209', 'DouYu-1673291'...

solo_fpp_leaderboard.ids_to_names()
# {'account.f897d4a4b22f45cb8a85008039f5069e': 'HuYaTv-19488958', 'account.8ca07daf6c084dea81aacc00616fde9c': 'Breukin224'...

solo_fpp_leaderboard.names_to_ids()
# {'HuYaTv-19488958': 'account.f897d4a4b22f45cb8a85008039f5069e', 'Breukin224': 'account.8ca07daf6c084dea81aacc00616fde9c'...

# Info about a player at particular rank
solo_fpp_leaderboard.name(1)
# 'HuYa-17152571'

solo_fpp_leaderboard.id(1)
# 'account.cfb13f65d5d1452294efbe7e730f7b1c'

solo_fpp_leaderboard.stats(1)
# {'rank_points': 6344, 'wins': 82, 'games': 1591, 'win_ratio': 0.0515399128, 'average_damage': 247, 'kills': 3218...

# Get a player object for a player at rank 1
player = solo_fpp_leaderboard.get_player(1)

Samples

Get randomly sampled match ids.

samples = pubg.samples()

samples.match_ids
# ['98192d81-8700-4e28-981d-00b14dfbb3c9', '7ce51ef0-6f73-4974-9bb6-532dec58355d'...

API Status

Get the current API status

status = pubg.status()

status.id
# 'pubg-api'

# Refreshes the API status
status.refresh()

Matches

Get match information

match = pubg.match("e0b3cb15-929f-4b42-8873-68a8f9998d2b")

match.asset_id
# '44b787fd-c153-11e9-8b6c-0a586467d436'

match.created_at
# '2019-08-18T00:29:00Z'

match.duration
# 1686

match.game_mode
# 'duo-fpp'

match.id
# 'e0b3cb15-929f-4b42-8873-68a8f9998d2b'

match.is_custom
# False

match.map_id
# 'Baltic_Main'

match.map_name
# 'Erangel (Remastered)'

match.rosters_player_names
# {'9354f12b-8e79-4ca2-9465-6bdfa6b4bca9': ['Vealzor', 'Colin630'], 'c2eb2ecf-96d5-42c3-b0cb-49d734a716a6': ['KillaCon', 'FriendlyOrc']...

match.telemetry_url
# 'https://telemetry-cdn.playbattlegrounds.com/bluehole-pubg/steam/2019/08/18/00/58/44b787fd-c153-11e9-8b6c-0a586467d436-telemetry.json'

match.url
# 'https://api.playbattlegrounds.com/shards/steam/matches/e0b3cb15-929f-4b42-8873-68a8f9998d2b'

Get rosters and associated participants

# Get rosters
rosters = match.rosters

# Get single roster
roster = rosters[0]

roster.player_ids
# ['account.7046d72ec24e45a7b0282d390dea91e5', 'account.9a154840c7db4f7f88def5198b9393b6']

roster.player_names
# ['Vealzor', 'Colin630']

roster.stats
# {'rank': 44, 'team_id': 12, 'won': 'false'}

roster.won
# False

# Participant from a roster
roster_participants = roster.participants
participant = roster_participant[0]

participant.name
# 'Vealzor'

participant.player_id
# 'account.7046d72ec24e45a7b0282d390dea91e5'

participant.stats
# {'dbnos': 1, 'assists': 0, 'boosts': 0, 'damage_dealt': 113.032738...

participant.teammates_player_ids
# ['account.9a154840c7db4f7f88def5198b9393b6']

participant.teammates_player_names
# ['Colin630']

participant.won
# False

# Get Participant instances for teammates
teammates = participant.teammates

Get all Participants from Match

match_participants = match.participants

Telemetry

Get a Telemetry instance from a particular match

# Using the PUBG instance
url = 'https://telemetry-cdn.playbattlegrounds.com/bluehole-pubg/steam/2019/08/18/00/58/44b787fd-c153-11e9-8b6c-0a586467d436-telemetry.json'
telemetry = pubg.telemetry(url)

# Using a Match instance
match = pubg.match("e0b3cb15-929f-4b42-8873-68a8f9998d2b")
telemetry = match.get_telemetry()

# All available event types
telemetry.event_types()
# ['log_armor_destroy', 'log_care_package_land', 'log_care_package_spawn', 'log_game_state_periodic', 'log_heal'...

# All specific events
care_package_lands = telemetry.filter_by("log_care_package_land")

telemetry.map_id()
# 'Baltic_Main'

telemetry.map_name()
# 'Erangel (Remastered)'

telemetry.num_players()
# 100

telemetry.num_teams()
# 50

telemetry.platform
# 'pc'

# Generates an HTML5 animation with ffmpeg
telemetry.playback_animation("match.html")

# Many more functions related to positions, circles, damages. Refer to docs

Telemetry events and objects are generic class wrappers. They are constructed when the Telemetry instance is created. This makes them telemetry version-agnostic, but requires some work to inspect their contents and structure. The TelemetryEvent and TelemetryObject classes also transform the payload keys to snake_case.

TelemetryEvents are containers for event key-values and structures which contain a hierarchy of TelemetryObjects.

Telemetry Events

# Get all TelemetryEvents as a list
events = telemetry.events

# Get one of the events
event = events[0]

event.event_type
# log_match_definition

event.timestamp
# '2019-08-18T00:29:00.0807375Z'

event.to_dict()
# {'_D': '2019-08-18T00:29:00.0807375Z', '_T': 'LogMatchDefinition', 'match_id': 'match.bro.official.pc-2018-04.steam.duo-fpp.na.2019.08.18.00.e0b3cb15-929f-4b42-8873-68a8f9998d2b', 'ping_quality': 'low', 'season_state': 'progress'}

print(event.dumps())
# {
#     "_D": "2019-08-18T00:29:00.0807375Z",
#     "_T": "LogMatchDefinition",
#     "match_id": "match.bro.official.pc-2018-04.steam.duo-fpp.na.2019.08.18.00.e0b3cb15-929f-4b42-8873-68a8f9998d2b",
#     "ping_quality": "low",
#     "season_state": "progress"
# }

# Each event key can be grabbed as an attribute or key
event.ping_quality
# low

event["ping_quality"]
# low

TelemetryObjects refer to entities such as players, items, locations, vehicles, etc. Each TelemetryObject contains a reference attribute which is the key in the parent TelemetryEvent or TelemetryObject that refers to this TelemetryObject.

Telemetry Objects

# All available event types
telemetry.event_types()
# ['log_armor_destroy', 'log_care_package_land', 'log_care_package_spawn', 'log_game_state_periodic', 'log_heal'...

kill_events = telemetry.filter_by("log_player_kill")
kill = kill_events[0]

kill.keys()
# ['attack_id', 'killer', 'victim', 'assistant', 'dbno_id', 'damage_reason'...

killer = kill.killer
killer.keys()
# ['reference', 'name', 'team_id', 'health', 'location', 'ranking', 'account_id', 'is_in_blue_zone', 'is_in_red_zone', 'zone']

killer.name
# 'WigglyPotato'

victim = kill.victim
victim.keys()
# ['reference', 'name', 'team_id', 'health', 'location', 'ranking', 'account_id', 'is_in_blue_zone', 'is_in_red_zone', 'zone']

victim.name
# 'qnle'

victim.to_dict()
# {'account_id': 'account.d9c2d8dc8c03412eadfa3e59c8f3c16a', 'health': 0, 'is_in_blue_zone': False, 'is_in_red_zone': False...

for k, v in victim.items():
    print(k, v)
# reference victim
# name qnle
# team_id 43
# health 0
# location TelemetryObject location object
# ranking 0
# account_id account.d9c2d8dc8c03412eadfa3e59c8f3c16a
# is_in_blue_zone False
# is_in_red_zone False
# zone ['georgopol']

chicken-dinner's People

Contributors

az7139 avatar cemuuser8 avatar crflynn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

chicken-dinner's Issues

How to make the replay video longer

Now a replay video file is one minute long,I want a 5 minutes replay MP4 vedio.

The parmeter 'interval' couln't be decimal fraction,when it is 1,the vedio length is about 1minute.

On the side,for support the old telemetry file,I submitted a little modification.

Error with retrieving list index

I have been looking at the documentation, and wanted to try this out.

So, I have copied both examples provided using my own API Key and the player name "DanucD" as a test:

from chicken_dinner.pubgapi import PUBG

Example 1
`api_key = "MY_API_KEY"
pubg = PUBG(api_key, "pc-eu")

me = pubg.players_from_names("DanucD")[0]
last_match_id = me.match_ids[0]

last_match = pubg.match(last_match_id)
last_match_telemetry = last_match.get_telemetry()

last_match_telemetry.playback_animation("last_match.html")`

Example 2
`from chicken_dinner.pubgapi import PUBG
from chicken_dinner.visual.playback import create_playback_animation

api_key = "MY_API_KEY"
pubg = PUBG(api_key, "pc-eu")

me = pubg.players_from_names("DanucD")[0]
last_match_id = me.match_ids[0]

last_match = pubg.match(last_match_id)
last_match_telemetry = last_match.get_telemetry()

create_playback_animation(last_match_telemetry, "last_match.html")`

After running either, I receive the below error:
Traceback (most recent call last):
File "C:/Users/Bradley/PycharmProjects/pythonProject1/main.py", line 9, in
last_match_id = me.match_ids[0]
IndexError: list index out of range

It is likely user error, but was not sure if something was updated elsewhere that may have impacted it.

Retrieving a player leads to type error

Issue

The function player(self, player_id, shard=None) in pubg.py mistakenly calls Player(self, player_id, shard) which does not match the signature of Player correctly:

def __init__(self, pubg, player_id, data=None, shard=None)

i. e. shard is passed as data which leads to a TypeError when accessing various different attributes of the resulting Player.

Example to Reproduce

Execute the following code in the python console:

from chicken_dinner import PUBG
PUBG(<yourAPIKey>, 'steam').player('account.decd7c11a6ff4cef91ab6be133fb0172').id

gives the error

Traceback (most recent call last):
File "", line 8, in
File "P:\Python\lib\site-packages\chicken_dinner\models\player.py", line 46, in id
return self.data["id"]
TypeError: string indices must be integers

Possible Solution

Replace the call Player(self, player_id, shard) with Player(self, player_id, shard=shard).

Playback Visualizations error

I've run an example code for playback visualizations. It didn't work properly.
Here is trace log and installed python package list.

Traceback (most recent call last):
  File "/home/discord/.local/lib/python3.6/site-packages/matplotlib/lines.py", line 196, in _mark_every_path
    return Path(verts[markevery], _slice_or_none(codes, markevery))
IndexError: index 1 is out of bounds for axis 0 with size 1

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "play.py", line 10, in <module>
    recent_match_telemetry.playback_animation("recent_match.html")
  File "/home/discord/.local/lib/python3.6/site-packages/chicken_dinner/models/telemetry/telemetry.py", line 539, in playback_animation
    return create_playback_animation(self, filename, **kwargs)
  File "/home/discord/.local/lib/python3.6/site-packages/chicken_dinner/visual/playback.py", line 526, in create_playback_animation
    init_func=init, blit=True,
  File "/home/discord/.local/lib/python3.6/site-packages/matplotlib/animation.py", line 1668, in __init__
    TimedAnimation.__init__(self, fig, **kwargs)
  File "/home/discord/.local/lib/python3.6/site-packages/matplotlib/animation.py", line 1432, in __init__
    *args, **kwargs)
  File "/home/discord/.local/lib/python3.6/site-packages/matplotlib/animation.py", line 987, in __init__
    self._setup_blit()
  File "/home/discord/.local/lib/python3.6/site-packages/matplotlib/animation.py", line 1272, in _setup_blit
    self._post_draw(None, self._blit)
  File "/home/discord/.local/lib/python3.6/site-packages/matplotlib/animation.py", line 1236, in _post_draw
    self._fig.canvas.draw_idle()
  File "/home/discord/.local/lib/python3.6/site-packages/matplotlib/backend_bases.py", line 1899, in draw_idle
    self.draw(*args, **kwargs)
  File "/home/discord/.local/lib/python3.6/site-packages/matplotlib/backends/backend_agg.py", line 402, in draw
    self.figure.draw(self.renderer)
  File "/home/discord/.local/lib/python3.6/site-packages/matplotlib/artist.py", line 50, in draw_wrapper
    return draw(artist, renderer, *args, **kwargs)
  File "/home/discord/.local/lib/python3.6/site-packages/matplotlib/figure.py", line 1652, in draw
    renderer, self, artists, self.suppressComposite)
  File "/home/discord/.local/lib/python3.6/site-packages/matplotlib/image.py", line 138, in _draw_list_compositing_images
    a.draw(renderer)
  File "/home/discord/.local/lib/python3.6/site-packages/matplotlib/artist.py", line 50, in draw_wrapper
    return draw(artist, renderer, *args, **kwargs)
  File "/home/discord/.local/lib/python3.6/site-packages/matplotlib/axes/_base.py", line 2604, in draw
    mimage._draw_list_compositing_images(renderer, self, artists)
  File "/home/discord/.local/lib/python3.6/site-packages/matplotlib/image.py", line 138, in _draw_list_compositing_images
    a.draw(renderer)
  File "/home/discord/.local/lib/python3.6/site-packages/matplotlib/artist.py", line 50, in draw_wrapper
    return draw(artist, renderer, *args, **kwargs)
  File "/home/discord/.local/lib/python3.6/site-packages/matplotlib/lines.py", line 817, in draw
    affine, self.axes.transAxes)
  File "/home/discord/.local/lib/python3.6/site-packages/matplotlib/lines.py", line 201, in _mark_every_path
    'markevery=%s' % (markevery,))
ValueError: `markevery` is iterable but not a valid form of numpy fancy indexing; markevery=[1]
acme (0.25.1)
aiohttp (2.3.10)
asn1crypto (0.22.0)
async-timeout (2.0.0)
beautifulsoup4 (4.6.0)
bs4 (0.0.1)
certbot (0.25.0)
certbot-apache (0.25.0)
certifi (2018.8.24)
chardet (3.0.4)
chicken-dinner (0.5.0)
command-not-found (0.3)
ConfigArgParse (0.11.0)
configobj (5.0.6)
cryptography (1.9)
cycler (0.10.0)
discord (0.0.2)
discord.py (0.16.12)
distro-info (0.17)
furl (2.0.0)
future (0.15.2)
httplib2 (0.9.2)
idna (2.7)
idna-ssl (1.0.0)
josepy (1.0.1)
kiwisolver (1.0.1)
language-selector (0.1)
matplotlib (3.0.0)
mock (2.0.0)
multidict (4.1.0)
ndg-httpsclient (0.4.3)
numpy (1.15.2)
orderedmultidict (1.0)
parsedatetime (2.4)
pbr (2.0.0)
Pillow (5.3.0)
pip (9.0.1)
pubg-python (0.4.1)
pyasn1 (0.1.9)
pygobject (3.24.1)
pyOpenSSL (17.3.0)
pyparsing (2.2.2)
pyRFC3339 (1.0)
python-apt (1.4.0b3)
python-augeas (0.5.0)
python-dateutil (2.7.3)
python-debian (0.1.30)
pytz (2017.2)
PyYAML (3.12)
requests (2.19.1)
requests-toolbelt (0.8.0)
setuptools (40.4.3)
six (1.11.0)
ssh-import-id (5.7)
systemd-python (234)
ufw (0.35)
unattended-upgrades (0.1)
urllib3 (1.23)
websockets (4.0.1)
wheel (0.30.0)
yarl (1.1.0)
zope.component (4.3.0)
zope.event (4.2.0)
zope.hookable (4.0.4)
zope.interface (4.3.2)

match model -> game_mode attribute

In the match model, game_mode attribute.

What is the purpose of this: game_mode_to_gp? it appears to map from a string to the exact same string

Something is missing, acpfpp, which isn't documented on the API site as far as I can see. Plus I think I've run into some other random ones, but didn't think much of it. I'm assuming these are somehow different for custom matches or something.

This acpfpp can be found looking through badshroud previous match history ( at time of writing this it was the 69th previous match )

If I just take out using that map within the match model it no longer throws a KeyError and seems to work exactly as before, but also giving me this random game mode properly as well.

my output after:

badshroud had 106 recent matches:    ( showing 1 )
      PL  Map      Mode        KI  KN  AS  HS   Damage   Long  HL  BST  Alive For   Death     Game Started           
 69|  10  Sanhok   acpfpp       3   2   1   1   485.13    21m   2    2  09:26  53%  byplayer  08/03/2018 17:03:50

Before it would just throw an error, as acpfpp isn't a valid key within game_mode_to_gp

Default shard is always used, even when a different one is given.

I have been using your wrapper to play around with the API and I believe this is a bug.

say you do this:
api = PUBG(myApiKey, 'xbox-na')
players = api.players_from_names('shroud', 'pc-na')

it will fail to find shroud because it is still using 'xbox-na' shard for the url.

I've looked through the source code a bit and believe it has to do with this line:
url = SHARD_URL + self.shard + "/players"

within the coreapi players function. (and other endpoints as well)

it always uses the self.shard and not the passed in shard value. I feel like you are missing a single shard = shard or self.shard right before the _check_shard, and then using just shard instead while building the url.

 

Sorry if I knew how to create a pull request with the suggested fixes I would.

Thank you very much for providing your PUBG API wrapper.

Replays on Erangel cause key error

I think this is due to the new Erangel coming out just recently, but can't find where I would fix it. Attached is the error that is coming up:

Traceback (most recent call last):
  File "myFirst.py", line 27, in <module>
    fps=30,
  File "C:\Program Files\Python37\lib\site-packages\chicken_dinner\models\telemetry\telemetry.py", line 541, in playback_animation
    return create_playback_animation(self, filename, **kwargs)
  File "C:\Program Files\Python37\lib\site-packages\chicken_dinner\visual\playback.py", line 113, in create_playback_animation
    mapx, mapy = map_dimensions[map_id]
KeyError: 'Baltic_Main'

KeyError: 'x-ratelimit-reset'

Version 0.4.1

if __name__ == "__main__":
    api_key = "eyJ0eXAiOiJ................................."
    pubg = PUBG(api_key, "pc-tournament")
    player = "OMG_xiaorong"
    match_id = "f7a7428e-4d83-4ecd-9622-1fda00bf7201"
    match = pubg.match(match_id)
    if player in match.winner.player_names:# and match.map_name in ("Desert_Main", "Miramar"):
        print(match.map_name, match_id)
        match_telemetry = match.get_telemetry()
        match_telemetry.playback_animation(
            "secret.html",
            zoom=True,
            labels=True,
            label_players=[],
            # highlight_teams=["shroud"],
            highlight_winner=True,
            label_highlights=True,
            size=6,
            end_frames=60,
            use_hi_res=True,
            color_teams=True,
            interpolate=True,
            damage=True,
            interval=30,
            fps=30,
        )

xbox shard says invalid

I've narrowed this down to simple missing comma in your constants file.

"xbox"
# platform-region
"pc-as",

I didn't want to make a whole pull request for just this comma.

Telemetry xbox vs pc ( specifically 'blueZoneCustomOptions' )

Hey, sorry, me again.

I got around to playing with telemetry data, and it always fails for me with xbox matches. This time I'm not sure what the fix could possibly be, but like my last issue I did my best to trace down the problem.

It appears to be within Telemetry/events.py

on __init__ at this part:

    elif k == "blueZoneCustomOptions":  # serialized json
        if len(v) > 2:  # more than just '[]'
            setattr(self, camel_to_snake(k), TelemetryObject(json.loads(v), k))
         else:
             setattr(self, camel_to_snake(k), json.loads(v))
    else:
        setattr(self, camel_to_snake(k), v)

Specifically with TelemetryObject(json.loads(v), k) on the condition when if len(v) > 2 ( On Xbox it appears to always be filled, with every attribute set to 0? )

the json.loads(v) returns a list of dicts in this case instead of just a dict. Which then fails on the __init__ of the TelemetryObject since it calls items() which doesn't exist on a list.

Unfortunately every test I do using PC v is always equal to [] so it never gets to this point, so I am unsure if it is just an Xbox issue, or if a PC match with those values set would also cause problems as well.

 

As an unrelated find I made, which I can just create a pull request for if you'd like (now that I know how) is in:

Telemetry\telemetry.py

I added from chicken_dinner.constants import map_to_map_name since you use that mapping but it fails if I don't have this included.

How to draw a tournament record

I want to draw the pgi2018_tpp tournament record

But drawing the result is not a normal game video

pubg = PUBG(api_key, "pc-tournament")
player = "WTSG_vard"
match_id = "917ff3af-8317-4146-bba7-a13b33fdc237"
match = pubg.match(match_id)
print(match.map_name, match_id)
match_telemetry = match.get_telemetry()
match_telemetry.playback_animation(
    "secret.html",
    zoom=True,
    labels=True,
    highlight_teams=["WTSG_vard"],
    highlight_winner=False,
    label_highlights=True,
    size=10,
    end_frames=60,
    use_hi_res=True,
    color_teams=True,
    interpolate=True,
    damage=True,
    interval=1,
    fps=30,
)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.