Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with the overview endpoint #126

Open
nat5142 opened this issue May 4, 2019 · 2 comments
Open

Issue with the overview endpoint #126

nat5142 opened this issue May 4, 2019 · 2 comments

Comments

@nat5142
Copy link

nat5142 commented May 4, 2019

Getting an error with responses from the overview function:

from mlbgame import games, box_score, overview

this = games(2019, 5, 1, home='Phillies')
game_id = this[0][0].game_id

ovr = overview(game_id)

produces:

    raw_box_score_root = etree.parse(raw_box_score).getroot()
  File "src/lxml/etree.pyx", line 3435, in lxml.etree.parse
  File "src/lxml/parser.pxi", line 1861, in lxml.etree._parseDocument
  File "src/lxml/parser.pxi", line 1881, in lxml.etree._parseFilelikeDocument
  File "src/lxml/parser.pxi", line 1776, in lxml.etree._parseDocFromFilelike
  File "src/lxml/parser.pxi", line 1187, in lxml.etree._BaseParser._parseDocFromFilelike
  File "src/lxml/parser.pxi", line 601, in lxml.etree._ParserContext._handleParseResultDoc
  File "src/lxml/parser.pxi", line 711, in lxml.etree._handleParseResult
  File "src/lxml/parser.pxi", line 640, in lxml.etree._raiseParseError
  File "http://gd2.mlb.com/components/game/mlb/year_2019/month_05/day_01/gid_2019_05_01_detmlb_phimlb_1/rawboxscore.xml", line 1
lxml.etree.XMLSyntaxError: Space required after the Public Identifier, line 1, column 55

I dug around a bit and imported mlbgame.data.get_overview to see what was up:

from mlbgame.data import get_overview
import lxml.etree as etree

ovr = get_overview(game_id)

print(ovr.url)
print(ovr.read())

Which produces this output:

http://gd2.mlb.com/components/game/mlb/year_2019/month_05/day_01/gid_2019_05_01_detmlb_phimlb_1/linescore.xml

b'<?xml version="1.0" ?>\n<!--NOTICE: This file is no longer actively supported. Please use the MLB Stats API (http://statsapi.mlb.com/docs/) as an alternative.  Copyright 2019 MLB Advanced Media, L.P.  Use of any content on this page acknowledges agreement to the terms posted here http://gdx.mlb.com/components/copyright.txt-->\n<game ampm="PM" aw_lg_ampm="PM" away_ampm="PM" away_code="det" away_division="C" away_file_code="det" away_league_id="103" away_loss="15" away_name_abbrev="DET" away_preview_link="/mlb/gameday/index.jsp?gid=2019_05_01_detmlb_phimlb_1&amp;mode=preview&amp;c_id=mlb" away_recap_link="/mlb/gameday/index.jsp?gid=2019_05_01_detmlb_phimlb_1&amp;mode=recap&amp;c_id=mlb" away_sport_code="mlb" away_team_city="Detroit" away_team_errors="0" away_team_hits="12" away_team_id="116" away_team_link="/clubs/index.jsp?cid=t116" away_team_name="Tigers" away_team_runs="3" away_time="7:05" away_time_zone="ET" away_win="13" balls="1" day="WED" description="" double_header_sw="N" first_pitch_et="" game_data_directory="/components/game/mlb/year_2019/month_05/day_01/gid_2019_05_01_detmlb_phimlb_1" game_nbr="1" game_pk="567076" game_type="R" gameday_link="2019_05_01_detmlb_phimlb_1" gameday_sw="P" highlights_available="Y" hm_lg_ampm="PM" home_ampm="PM" home_code="phi" home_division="E" home_file_code="phi" home_league_id="104" home_loss="13" home_name_abbrev="PHI" home_preview_link="/mlb/gameday/index.jsp?gid=2019_05_01_detmlb_phimlb_1&amp;mode=preview&amp;c_id=mlb" home_recap_link="/mlb/gameday/index.jsp?gid=2019_05_01_detmlb_phimlb_1&amp;mode=recap&amp;c_id=mlb" home_sport_code="mlb" home_team_city="Philadelphia" home_team_errors="0" home_team_hits="15" home_team_id="143" home_team_link="/clubs/index.jsp?cid=t143" home_team_name="Phillies" home_team_runs="7" home_time="7:05" home_time_zone="ET" home_win="17" id="2019/05/01/detmlb-phimlb-1" ind="F" inning="9" inning_break_length="" inning_state="Top" is_no_hitter="N" is_perfect_game="N" league="AN" location="Philadelphia, PA" note="" original_date="2019/05/01" outs="3" pbp_last="Ronny Rodriguez strikes out swinging." preview="/mlb/gameday/index.jsp?gid=2019_05_01_detmlb_phimlb_1&amp;mode=preview&amp;c_id=mlb" reason="" runner_on_base_status="0" scheduled_innings="9" status="Final" strikes="3" tbd_flag="N" tiebreaker_sw="N" time="7:05" time_aw_lg="7:05" time_date="2019/05/01 7:05" time_date_aw_lg="2019/05/01 7:05" time_date_hm_lg="2019/05/01 7:05" time_hm_lg="7:05" time_zone="ET" time_zone_aw_lg="-4" time_zone_hm_lg="-4" top_inning="Y" tz_aw_lg_gen="ET" tz_hm_lg_gen="ET" venue="Citizens Bank Park" venue_id="2681" venue_w_chan_loc="USPA1276" wrapup_link="/mlb/gameday/index.jsp?gid=2019_05_01_detmlb_phimlb_1&amp;mode=wrap&amp;c_id=mlb" xmlns:xs="http://www.w3.org/2001/XMLSchema">\n  <linescore away_inning_runs="0" home_inning_runs="0" inning="1"/>\n  <linescore away_inning_runs="0" home_inning_runs="1" inning="2"/>\n  <linescore away_inning_runs="0" home_inning_runs="0" inning="3"/>\n  <linescore away_inning_runs="0" home_inning_runs="0" inning="4"/>\n  <linescore away_inning_runs="0" home_inning_runs="0" inning="5"/>\n  <linescore away_inning_runs="1" home_inning_runs="0" inning="6"/>\n  <linescore away_inning_runs="1" home_inning_runs="4" inning="7"/>\n  <linescore away_inning_runs="1" home_inning_runs="2" inning="8"/>\n  <linescore away_inning_runs="0" home_inning_runs="" inning="9"/>\n  <home_runs>\n    <player first="Rhys" hr="1" id="656555" inning="8" last="Hoskins" name_display_roster="Hoskins" number="17" runners="0" std_hr="9" team_code="phi"/>\n    <player first="Jordy" hr="1" id="474568" inning="8" last="Mercer" name_display_roster="Mercer" number="7" runners="0" std_hr="1" team_code="det"/>\n  </home_runs>\n  <winning_pitcher era="5.11" first="Seranthony" first_name="Seranthony" id="622554" last="Dominguez" last_name="Dominguez" losses="0" name_display_roster="Dominguez" s_era="" s_losses="" s_wins="" wins="2"/>\n  <losing_pitcher era="3.97" first="Buck" first_name="Buck" id="571656" last="Farmer" last_name="Farmer" losses="2" name_display_roster="Farmer" s_era="" s_losses="" s_wins="" wins="1"/>\n  <save_pitcher era="" first="" first_name="" id="" last="" last_name="" losses="" name_display_roster="" s_era="" s_losses="" s_wins="" saves="" wins=""/>\n  <game_media>\n    <media calendar_event_id="14-567076-2019-05-01" enhanced="N" free="NO" has_milbtv="false" has_mlbtv="true" media_state="media_dead" start="2019-05-01T23:05:00Z" thumbnail="http://mediadownloads.mlb.com/mlbam/preview/detphi_567076_th_7_preview.jpg" title="DET @ PHI" type="game"/>\n  </game_media>\n</game>\n'

Thought the notice at the beginning should be brought to your attention

@panzarino
Copy link
Owner

I think the library has been having a lot of issues recently because of the new Stats API. Since the new API is JSON, it is a lot easier to work with in python than XML (the reason I created this library), and I would suggest using that directly.

@jso8910
Copy link

jso8910 commented May 20, 2021

How do I use the new API? It requires an account and I don't know how to get said account

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants