Giter VIP home page Giter VIP logo

blaseball-game-dump's Introduction

blaseball-game-dump

game-dump is a command line utility for dumping all events for a given game ID.

Installing

Install using pip:

# required:
pip install git+https://github.com/ch4zm/blaseball-core-game-data.git#egg=blaseball_core_game_data
# optional:
pip install git+https://github.com/ch4zm/blaseball-game-finder.git#egg=blaseball_game_finder
# install:
pip install git+https://github.com/ch4zm/blaseball-game-dump.git#egg=blaseball_game_dump

Usage

The command line utility that is installed is called game-dump.

Provide the game ID as the first and only argument:

game-dump 3ae0ced8-a816-488a-b0be-0491d20a28d9

Python API

If you prefer to use game-dump from Python instead of the command line, you can use the Python API by importing and calling the game_dump() command, passing in a list of string containing whatever flags you would use on the command line:

from game_dump.command import game_dump

game_id = "fca6f5d2-e645-4354-985e-3080983eecb4"
output = game_dump([game_id, "--text"])

The function call returns the output that would be printed to the console if the tool were run from the command line, as a string. You can obtain the results as JSON by using json.loads() to load JSON from a string:

from game_dump.command import game_dump
import json

game_id = "fca6f5d2-e645-4354-985e-3080983eecb4"
output = game_dump([game_id, "--json"])

Using game-dump with game-finder

This tool works best with the game-finder command line utility, which lets you find game IDs and filter by various criteria:

$ game-finder --season 4 --day 99 --team Tacos
3ae0ced8-a816-488a-b0be-0491d20a28d9

$ game-finder --season 4 --day 99 --team Tacos | xargs game-dump
========================================
Game ID: 3ae0ced8-a816-488a-b0be-0491d20a28d9
Unlimited Tacos @ Boston Flowers
Tacos 1 - 2 Flowers
----------------------------------------
{
    "id": 3589263,
    "perceived_at": "2020-08-29T07:00:03.393Z",
    "game_id": "3ae0ced8-a816-488a-b0be-0491d20a28d9",
    "event_type": "OUT",
    "event_index": 0,
    "inning": 0,
    "top_of_inning": true,
    "outs_before_play": 0,
    "batter_id": "27c68d7f-5e40-4afa-8b6f-9df47b79e7dd",
    "batter_team_id": "878c1bf6-0d21-4659-bfee-916c8314d69c",
    "pitcher_id": "24f6829e-7bb4-4e1e-8b59-a07514657e72",
    "pitcher_team_id": "3f8bbb15-61c0-4e3f-8e4a-907a5fb1565e",
    "home_score": 0,
    "away_score": 0,
    "home_strike_count": 3,
    "away_strike_count": 3,
    "batter_count": 0,
    "pitches": [
        "X"
    ],
    "total_strikes": 0,
    "total_balls": 0,
    "total_fouls": 0,
    "is_leadoff": true,
    "is_pinch_hit": false,
    "lineup_position": 0,
    "is_last_event_for_plate_appearance": true,
    "bases_hit": 0,
    "runs_batted_in": 0,
    "is_sacrifice_hit": false,
    "is_sacrifice_fly": false,
    "outs_on_play": 1,
    "is_double_play": false,
    "is_triple_play": false,
    "is_wild_pitch": false,
    "batted_ball_type": "GROUNDER",
    "is_bunt": false,
    "errors_on_play": 0,
    "batter_base_after_play": 0,
    "is_last_game_event": false,
    "event_text": [
        "Play ball!",
        "Top of 1, Unlimited Tacos batting.",
        "Basilio Mason batting for the Tacos.",
        "Basilio Mason hit a ground out to Margarito Nava."
    ],
    "additional_context": "",
    "season": 3,
    "day": 98,
    "parsing_error": false,
    "parsing_error_list": [],
    "fixed_error": false,
    "fixed_error_list": []
}
----------------------------------------
{
    "id": 3589264,
    "perceived_at": "2020-08-29T07:00:27.677Z",
    "game_id": "3ae0ced8-a816-488a-b0be-0491d20a28d9",
    "event_type": "STRIKEOUT",
    "event_index": 1,
    "inning": 0,
    "top_of_inning": true,
    "outs_before_play": 1,
    "batter_id": "63df8701-1871-4987-87d7-b55d4f1df2e9",
    "batter_team_id": "878c1bf6-0d21-4659-bfee-916c8314d69c",
    "pitcher_id": "24f6829e-7bb4-4e1e-8b59-a07514657e72",
    "pitcher_team_id": "3f8bbb15-61c0-4e3f-8e4a-907a5fb1565e",
    "home_score": 0,
    "away_score": 0,

    ...

See blaseball-game-finder.

blaseball-game-dump's People

Contributors

ch4zm avatar

Watchers

 avatar

blaseball-game-dump's Issues

import error before handling

Traceback (most recent call last):
  File "/private/tmp/vp/bin/game-dump", line 8, in <module>
    sys.exit(main())
  File "/private/tmp/vp/lib/python3.7/site-packages/game_dump/command.py", line 58, in main
    v = JsonView(options)
  File "/private/tmp/vp/lib/python3.7/site-packages/game_dump/view.py", line 36, in __init__
    gd = RawGameData(self.game_id)
  File "/private/tmp/vp/lib/python3.7/site-packages/game_dump/data.py", line 33, in __init__
    except JSONDecodeError:
NameError: name 'JSONDecodeError' is not defined

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.