HFBoards

Go Back   HFBoards > General Hockey Discussion > By The Numbers
Mobile Hockey's Future Become a Sponsor Site Rules Support Forum vBookie Page 2
By The Numbers Hockey Analytics... the Final Frontier. Explore strange new worlds, to seek out new algorithms, to boldly go where no one has gone before.

NHL.com + Sochi 2014 Data URLs in JSON and JSONP

Reply
 
Thread Tools
Old
02-01-2014, 09:54 PM
  #1
Step7750
HFBoards Sponsor
 
Step7750's Avatar
 
Join Date: Jan 2014
Location: Calgary, Alberta
Country: Canada
Posts: 42
vCash: 500
NHL.com + Sochi 2014 Data URLs in JSON and JSONP

After going through the network traffic of NHL's services, I have compiled a list of URLs that the NHL uses to obtain stats for certain players, teams, standings, etc... Best of all, all of this data is free and does not require any sort of API Key or anything of that nature.

This data came from the network traffic of NHL.com on a PC, NHL Gamecenter App on an iPhone, and TSN's iPhone App. There is no HTML/Web scraping involved


To make the data more readable, please use www.jsonlint.com to parse it.

JSON/JSONP Data > HTML Scraping

All URLs are subject to change but based upon the previous URLs, the NHL will post the new URL when you call the old one


Team Roster:


http://nhlwc.cdnak.neulion.com/fs1/n...lubroster.json

Change the team name (ex. ANA) to the wanted team; returns most current roster

Team Schedule Per Month

http://nhlwc.cdnak.neulion.com/fs1/n...bschedule.json

Change CGY to the wanted team abbreviation, 2014 to the wanted year and 02 to the wanted month.

Player Stats for the Entire Specified Team:


ex. http://nhlwc.cdnak.neulion.com/fs1/n...statsline.json

From the Gamecenter App - Simple Structure, change the season and team as wanted

Playoff Player Stats for the Entire Specified Team:


http://nhlwc.cdnak.neulion.com/fs1/n...statsline.json

Simple Structure, change the season and team as wanted, the 3 stands for Playoffs

Stats for an Individual Player:


You can either loop through the club roster and "player stats line" URL's above or get it from TSN:

http://www.tsn.ca/mobile/bbcard.aspx...=Sidney+Crosby

XML Data!

Just change the player name as desired.

Stats for Games:


There are a couple of URL's for this data, the most common that NHL.com uses are:

Structure: "http://live.nhle.com/GameData/" + Year (ex 20132014) + "/" + Gameid (ex 2013020821) + "/gc/" + Data Wanted (gcsb, gcbx etc...) + ".jsonp"


http://live.nhle.com/GameData/201320.../gc/gcsb.jsonp

- Updates way quicker than the data for the specified day (http://live.nhle.com/GameData/GCScor...13-01-31.jsonp) and contains Team ID's, Player's currently on the ice (gives their jersey numbers), Shots and goals for each team separated by the total or by period, current game time (in seconds in the sr listing), most recent event/play.


http://live.nhle.com/GameData/201320.../gc/gcbx.jsonp

- Recommended for in depth recent in-game plays and player stats. Contains recent events (it does not contain all of the events!), goal summary (goal scorer, assists, time, id, teams involved, type of play (you can find the alphabetical equivalents that correspond to the numbers on a script the NHL has which will be discussed below), penalty summary, and the only way to obtain the game stats for each player in the game according to their jersey number (the NHL.com Player ID is not necessary).

- For each player it includes their Assists, Goals, PIM, Plus Minus, Shots, and Time On Ice for that game


PlayByPlay.jsonp is not used by the NHL.com at this current time but contains all of the plays of the game, and goal info; I don't know whether NHL.com will continue to update it in the future.

"League Leaders" Overview Stats

http://nhlwc.cdnak.neulion.com/fs1/n...ueleaders.json

"League Leaders" In Points

http://nhlwc.cdnak.neulion.com/fs1/n...ueleaders.json

"League Leaders" In Goals

http://nhlwc.cdnak.neulion.com/fs1/n...ueleaders.json

"League Leaders" In Assists

http://nhlwc.cdnak.neulion.com/fs1/n...ueleaders.json

"League Leaders" In Plus/Minus

http://nhlwc.cdnak.neulion.com/fs1/n...ueleaders.json

"League Leaders" In Wins

http://nhlwc.cdnak.neulion.com/fs1/n...ueleaders.json

"League Leaders" In GAA

http://nhlwc.cdnak.neulion.com/fs1/n...ueleaders.json

"League Leaders" In Save Percentage

http://nhlwc.cdnak.neulion.com/fs1/n...ueleaders.json

"League Leaders" In Shutouts

http://nhlwc.cdnak.neulion.com/fs1/n...ueleaders.json

Team Standings:


http://app.cgy.nhl.yinzcam.com/V2/Stats/Standings

XML Data!

NHL Game Center requires an "auth" code in order to obtain team standings, this URL is extracted from the same data and doesn't require authentication.

or TSN's Standings:

http://www.tsn.ca/datafiles/XML/NHL/standings.xml

Also XML

NHL News:


http://nhlwc.cdnak.neulion.com/fs1/n...ne/1/news.json

Player Mug Pictures


You need the id of the player in order to access this which can be obtained from their team roster:

URL: http://3.cdn.nhle.com/photos/mugs/thumb/8476822.jpg

Self explanatory, just change the ending to the desired player id.

Default Image: http://3.cdn.nhle.com/photos/mugs/thumb/default.jpg

UPDATE: Thanks to aksun for the following info:

I found transparent high-quality player pictures from TSN site.

Example picture

API workaround:

Code:
GET http://tsnimages.tsn.ca/ImageProvider/PlayerHeadshot?seoId=[name]
So it's pretty easy to use it, just change the [name] to your player's name. There is a couple of things to keep in mind while using this system.
  • Latin alphabets only
  • replace spaces with hyphens(-)
  • replace aphostrophes(') and dots(.) with nothing

PHP for replacing work:

PHP Code:
$name str_replace(array(" ""'""."), array("-"""""), $originalName); 
NHL Game Calendar


http://www.nhl.com/gamecenter/en/aja...th=4&year=2011

Games on the Specified Day


http://live.nhle.com/GameData/GCScor...13-02-01.jsonp

This gives a good outlook on the games happening that day and also provides the Game ID's.

Thanks to meetc for the following info!

The returned JSON object can contain the following fields, some of them are not present prior to the start of the game.

PHP Code:
field                  datatype      descriptipon 
ata                    char
(3)       Away team acronym3 letter short name 
atc                    text          Before
blank During"progress" After"winner" if away team wins 
atcommon               text          away team common name 
atn                    text          away team city name 
ats                    int           away team score 
atsog                  int           Before
null During and Afteraway team shots on goal 
bs                     time
/text     Beforestart time (unsure if local or ESTDuring05:10 2ndeg After"FINAL""FINAL OT" etc 
bsc                    text          Before
blank During"progress" After"final" 
canationalbroadcasts   text          Canadian TV broadcasterscomma separated list 
gcl                    Bool          gamecenter live
gcll                   bool          gamecenter live
gs                     int           game status1=secheduled3in progress5=finished 
hta                    char
(3)       home team acronym 
htc                    text          Before
blank During"progress" After"winner" if home team wins 
htcommon               text          home team common name 
htn                    text          home team city name 
hts                    int           home team score 
htsog                  int           Before
null During and Afterhome team shots on goal 
id                     int           game ID 
rl                     Bool          true after game completed 
usnationalbroadcasts   text          US tv broadcasters
comma separated list 



Game ID Explained:


For its web services, each game in the NHL is assigned a GameID which is needed in order to obtain/maintain data for that game. Here are a couple examples of GameIDs and their structure:

Thanks to meetc for the following info!

First 4 digits indicate the year which the season begins
Digits 5,6 indicate the part of the season. 01 is pre-season, 02 is regular season, 03 is playoffs, 09 was used for the Sochi Olympics for the Mens Hockey
Digits 7-10 are the game number for that part of the season. In pre-season and regular season, these are mostly sequential based on the date and time the game starts.
In the playoffs digit 7 is always 0, digit 8 is the round of games (eg 1 preliminary, 2 quarters, 3 conference, 4 finals), digit 9 is a team matchup for that round, and digit 10 is the game number in that series.

NOTE: For Neulion's Video Highlight service (which the NHL uses to manage NHL Game Center), you use the significant digits of the Game Code specified above. So if the game code is 0815, then in the video highlight URL, it will be 815.


Neulion Highlights


This does not require the Game Center Live subscription!

NHL.com requires you to have NHL GameCenter Live in order to view highlights, but the video is just an MP4 so you can easily track it down.





UPDATE: 3/31/2014

Well, you can now find the highlight video URL really easily.

http://live.nhle.com/GameData/201320.../gc/gcgm.jsonp

Replace 2013021122 with the specified game id and 20132014 with the year of that game.

This will return the highlight id's for each video, once you have the id, go to:

http://video.nhl.com/videocenter/ser...-h&format=json

Replace 2013021122-60-h with the your highlight id.

It will look something like this:

Quote:
[**
"id":"2013021122-60-h",
"name":"Corey Crawford Save on Beau Bennett (02:00/1st)",
"trackName":"Corey Crawford Save on Beau Bennett (02:00/1st)",
"description":"Home broadcast - Chicago Blackhawks at Pittsburgh Penguins - March 30, 2014",
"image":"www/thumbs/2014/03/30/591215_es.jpg",
"bigImage":"www/thumbs/2014/03/30/591215_eb.jpg",
"publishPoint":"http://e1.cdnak.neulion.com/nhl/vod/2014/03/30/1122/2_1122_chi_pit_1314_h_discrete_PIT60_save_1_1600.m p4?eid=590676&pid=591215&gid=3000&pt=1",
"formats":"0",
"shareable":true,

"releaseDate":"2014-03-30T19:30:00.000",
"runtime":"0:14","duration":"14"
}]
Which includes everything you'll need to obtain the video source and info!







Ex. Highlight Video URL: http://e1.cdnak.neulion.com/nhl/vod/...oal_1_1600.mp4


The URL can be accessed without any credentials, let me explain the structure for the URL to view any highlight from a game.

Base URL: http://e1.cdnak.neulion.com/nhl/vod/

/2014/ - Year of the game
/01/ - Month of the game
/30/ - Day of the game
/815/ - Game code (last 3 digits of the gameid)
2_ - It is a static value, always 2
815_ - Game code (last 3 digits of the gameid)
sjs_ - Away team (San Jose Sharks)
cgy_ - Home team (Calgary Flames)
1314_ - Game season (2013 - 2014)
h_discrete_ - Static value
CGY - Home team (Calgary Flames)
475_ - Highlight ID (You can obtain this from PlayByPlay.jsonp, gcbx.jsonp, gcsb.jsonp etc...)
goal_ - Type of highlight (Goal, save, hit etc...)
1_ - I don't really know what this value stands for, it is either 1 or 2
1600 - Bitrate of the highlight (This is the only bitrate available)




Sochi 2014 Olympic Stats:





Medals for each country:


http://mapi.sochi2014.com/v1/en/olympic/medal/rating


Ice Hockey Schedule:


http://mapi.sochi2014.com/v1/en/olympic/results/IHSNR

Ice Hockey Olympic News:


http://mapi.sochi2014.com/v1/en/olym...ze=24&sport=IH

Olympic Games Schedule for Specified Day:


http://mapi.sochi2014.com/v1/en/olym...ate=2014-02-06

Just change the date parameter YYYY/MM/DD


Last edited by Step7750: 12-06-2014 at 01:01 PM. Reason: Fixed/Added Some Info
Step7750 is offline   Reply With Quote
Old
02-02-2014, 10:38 AM
  #2
Doctor No
Mod Supervisor
Retired?
 
Doctor No's Avatar
 
Join Date: Sep 2005
Posts: 24,295
vCash: 500
Very interesting stuff!

For hockeygoalies.org, I've always pulled all of my data by hand, just because I've seen enough errors in the data to cause me doubt.

I'd still love to learn more about how to automate the process.

Doctor No is offline   Reply With Quote
Old
02-02-2014, 07:30 PM
  #3
Step7750
HFBoards Sponsor
 
Step7750's Avatar
 
Join Date: Jan 2014
Location: Calgary, Alberta
Country: Canada
Posts: 42
vCash: 500
Quote:
Originally Posted by Chalupa Batman View Post
Very interesting stuff!

For hockeygoalies.org, I've always pulled all of my data by hand, just because I've seen enough errors in the data to cause me doubt.

I'd still love to learn more about how to automate the process.
Wow, I give you massive credit for doing that all manually.

You could create a PHP Server Side script that runs once a day/week/hour etc.. that checks the roster of the teams that played that day (or every single team roster) and get the stats of the goalies. You would then put that data into a MySQL database that your web page would gather info from when a user visits it.

You would have to tweak your website though since in order to extract data from MySQL, you would have to use a server side language like PHP which would then "echo" the tables with the stats.

PHP Example:




This PHP script generates a live scoreboard image based upon the parameters "gameid" and "date" on the url. It finds the team names, score, shots, plays, and logos, generates it and presents it to the user every single time the page is reloaded. Unlike HTML, it is impossible to see the source code of PHP since it runs server side. PHP files can also generate HTML documents pretty easily so it shouldn't be too much of a task.

ex.

Code:
<html> 
 <title>Calgary Flames Goalie Stats</title>
 <body>
 <h1>CALGARY FLAMES GOALTENDING HISTORY: YEAR-BY-YEAR</h1>

 <?php
 // PHP Code:
 // Extract the data from your database and generate the appropriate tables with the data
 ?>
 
 </body>
 </html>

To avoid the website reloading when going to a new page, you can use an AJAX call to post and receive the data from a PHP script. Efficiency

Ex. http://stackoverflow.com/questions/1...all-php-script (or) http://www.w3schools.com/php/php_ajax_database.asp

PHP is a pretty simple language, here is W3 Schools tutorial: http://www.w3schools.com/php/default.asp

This forum (vBulletin) is based off of MySQL and PHP

There are some other ways to do this, but a MySQL database would be your best bet.


Last edited by Step7750: 02-02-2014 at 07:40 PM.
Step7750 is offline   Reply With Quote
Old
02-02-2014, 10:42 PM
  #4
Kane One
HFB Partner
 
Kane One's Avatar
 
Join Date: Feb 2010
Location: Brooklyn, New NY
Country: United States
Posts: 29,088
vCash: 800
Yep, PHP + MySQL is the only way to go.

__________________
Kane One is online now   Reply With Quote
Old
02-02-2014, 10:50 PM
  #5
Doctor No
Mod Supervisor
Retired?
 
Doctor No's Avatar
 
Join Date: Sep 2005
Posts: 24,295
vCash: 500
I do PHP/MySQL on my database side of things. Part of the downside of creating my site in 1994 was that I continued to update the page incrementally, so by the time I went to "databaseize" it, it took me more than two years.

I still need a lot of practice pulling things down from other websites, though. That's next on the old Doug's new trick list.

Doctor No is offline   Reply With Quote
Old
02-03-2014, 10:31 AM
  #6
hatterson
Global Moderator
 
hatterson's Avatar
 
Join Date: Apr 2010
Location: North Tonawanda, NY
Country: United States
Posts: 11,775
vCash: 500
Send a message via Skype™ to hatterson
Personally I'd roll SQL Server and asp.net MVC/Razor/C# but to each their own

__________________
Come join us on the By The Numbers forum. Take a look at our introduction post if you're new. If you have any questions, feel free to PM me.
hatterson is online now   Reply With Quote
Old
02-07-2014, 06:03 PM
  #7
Fever
Rookie User
 
Join Date: Feb 2014
Posts: 1
vCash: 500
Me also PHP/MySQL..

Does anyone know much about this JSON data from NHL? Is it for their own GameCenter Live website and their apps?

They dont provide any documentation or anything ... I was just looking for a game result json feed but I guess if you use the gamecenter json you can iterate through and get the results that way.

Edit... Just saw this in the first post:
http://live.nhle.com/GameData/GCScor...13-02-01.jsonp

This is awesome!!


I have a really good use for this data once I figure it out!


Last edited by Fever: 02-07-2014 at 06:08 PM.
Fever is offline   Reply With Quote
Old
02-08-2014, 12:18 AM
  #8
Step7750
HFBoards Sponsor
 
Step7750's Avatar
 
Join Date: Jan 2014
Location: Calgary, Alberta
Country: Canada
Posts: 42
vCash: 500
Quote:
Originally Posted by Fever View Post
Me also PHP/MySQL..

Does anyone know much about this JSON data from NHL? Is it for their own GameCenter Live website and their apps?

They dont provide any documentation or anything ... I was just looking for a game result json feed but I guess if you use the gamecenter json you can iterate through and get the results that way.

Edit... Just saw this in the first post:
http://live.nhle.com/GameData/GCScor...13-02-01.jsonp

This is awesome!!


I have a really good use for this data once I figure it out!
This is the raw data for their NHL GameCenter Website/App services, there is no documentation (unless you worked on the infrastructure) but if you don't understand what a certain attribute means, feel free to ask; shouldn't take too long for me to analyze.

Remember that the URL you linked above is in JSONP and thus needs the "loadScoreboard(***DATA***)" to be removed in order to parse it as JSON.

You use PHP, so here is how you convert the JSONP to JSON:

PHP Code:
$dayscores "http://live.nhle.com/GameData/GCScoreboard/" $gamedate ".jsonp";
$rawscores file_get_contents($dayscores);
// Convert JSONP to JSON
$rawscores preg_replace('/.+?(**.+}).+/','$1',$rawscores);
$rawscores json_decode($rawscorestrue); 
To get more data for a specific game as well as more up to the second updated stats, use gcsb.jsonp or some of the other URLs listed.

PHP Code:
$scoresraw "http://live.nhle.com/GameData/20132014/" $gameid "/gc/gcsb.jsonp";
$gamestats file_get_contents($scoresraw);
$gamestats preg_replace('/.+?(**.+}).+/','$1',$gamestats);
$gamestats json_decode($gamestatstrue); 


Last edited by Step7750: 02-08-2014 at 12:56 AM. Reason: Added Info
Step7750 is offline   Reply With Quote
Old
06-30-2014, 11:23 AM
  #9
meetc
Registered User
 
Join Date: Jun 2014
Posts: 1
vCash: 500
Thanks a lot for all these data sources, I'm using a few of them for a project I'm working on. I have a few updates for the descriptions of the data sources.

Game ID Explained:

First 4 digits indicate the year which the season begins
Digits 5,6 indicate the part of the season. 01 is pre-season, 02 is regular season, 03 is playoffs, 09 was used for the Sochi Olympics for the Mens Hockey
Digits 7-10 are the game number for that part of the season. In pre-season and regular season, these are mostly sequential based on the date and time the game starts.
In the playoffs digit 7 is always 0, digit 8 is the round of games (eg 1 preliminary, 2 quarters, 3 conference, 4 finals), digit 9 is a team matchup for that round, and digit 10 is the game number in that series.


Games on the Specified Day:
GCScoreboard/yyyy-mm-dd.jsonp

JSON object can contain the following fields, some of them are not present prior to the start of the game.

PHP Code:
field                  datatype      descriptipon
ata                    char
(3)       Away team acronym3 letter short name
atc                    text          Before
blank During"progress" After"winner" if away team wins
atcommon               text          away team common name
atn                    text          away team city name
ats                    int           away team score
atsog                  int           Before
null During and Afteraway team shots on goal
bs                     time
/text     Beforestart time (unsure if local or ESTDuring05:10 2ndeg After"FINAL""FINAL OT" etc
bsc                    text          Before
blank During"progress" After"final"
canationalbroadcasts   text          Canadian TV broadcasterscomma separated list
gcl                    Bool          gamecenter live?
gcll                   bool          gamecenter live?
gs                     int           game status1=secheduled3in progress5=finished
hta                    char
(3)       home team acronym
htc                    text          Before
blank During"progress" After"winner" if home team wins
htcommon               text          home team common name
htn                    text          home team city name
hts                    int           home team score
htsog                  int           Before
null During and Afterhome team shots on goal
id                     int           game ID
rl                     Bool          true after game completed
usnationalbroadcasts   text          US tv broadcasters
comma separated list 

meetc is offline   Reply With Quote
Old
07-09-2014, 03:02 PM
  #10
Step7750
HFBoards Sponsor
 
Step7750's Avatar
 
Join Date: Jan 2014
Location: Calgary, Alberta
Country: Canada
Posts: 42
vCash: 500
Quote:
Originally Posted by meetc View Post
Thanks a lot for all these data sources, I'm using a few of them for a project I'm working on. I have a few updates for the descriptions of the data sources.

Game ID Explained:

First 4 digits indicate the year which the season begins
Digits 5,6 indicate the part of the season. 01 is pre-season, 02 is regular season, 03 is playoffs, 09 was used for the Sochi Olympics for the Mens Hockey
Digits 7-10 are the game number for that part of the season. In pre-season and regular season, these are mostly sequential based on the date and time the game starts.
In the playoffs digit 7 is always 0, digit 8 is the round of games (eg 1 preliminary, 2 quarters, 3 conference, 4 finals), digit 9 is a team matchup for that round, and digit 10 is the game number in that series.


Games on the Specified Day:
GCScoreboard/yyyy-mm-dd.jsonp

JSON object can contain the following fields, some of them are not present prior to the start of the game.

PHP Code:
field                  datatype      descriptipon
ata                    char
(3)       Away team acronym3 letter short name
atc                    text          Before
blank During"progress" After"winner" if away team wins
atcommon               text          away team common name
atn                    text          away team city name
ats                    int           away team score
atsog                  int           Before
null During and Afteraway team shots on goal
bs                     time
/text     Beforestart time (unsure if local or ESTDuring05:10 2ndeg After"FINAL""FINAL OT" etc
bsc                    text          Before
blank During"progress" After"final"
canationalbroadcasts   text          Canadian TV broadcasterscomma separated list
gcl                    Bool          gamecenter live?
gcll                   bool          gamecenter live?
gs                     int           game status1=secheduled3in progress5=finished
hta                    char
(3)       home team acronym
htc                    text          Before
blank During"progress" After"winner" if home team wins
htcommon               text          home team common name
htn                    text          home team city name
hts                    int           home team score
htsog                  int           Before
null During and Afterhome team shots on goal
id                     int           game ID
rl                     Bool          true after game completed
usnationalbroadcasts   text          US tv broadcasters
comma separated list 
Thanks for the info, I've added it to the first post!

All the best for your project

Step7750 is offline   Reply With Quote
Old
08-13-2014, 11:13 AM
  #11
Johne
Registered User
 
Join Date: Jul 2006
Location: Dallas, TX
Country: United States
Posts: 82
vCash: 500
I'm still trying to find standings in json. any help would be appreciated.

Johne is offline   Reply With Quote
Old
08-19-2014, 09:47 PM
  #12
Step7750
HFBoards Sponsor
 
Step7750's Avatar
 
Join Date: Jan 2014
Location: Calgary, Alberta
Country: Canada
Posts: 42
vCash: 500
Quote:
Originally Posted by Johne View Post
I'm still trying to find standings in json. any help would be appreciated.
Sorry for the late response, I've found the data in JSON from "The Score."

Standings: https://api.thescore.com/nhl/standings

Wild Card Standings: https://api.thescore.com/nhl/standings/wildcard

Step7750 is offline   Reply With Quote
Old
10-10-2014, 12:41 PM
  #13
aksun
Registered User
 
Join Date: Oct 2014
Location: Oulu, Finland
Country: Finland
Posts: 3
vCash: 500
I found transparent high-quality player pictures from TSN site.

Example picture

API workaround:

Code:
GET http://tsnimages.tsn.ca/ImageProvider/PlayerHeadshot?seoId=[name]
So it's pretty easy to use it, just change the [name] to your player's name. There is a couple of things to keep in mind while using this system.
  • Latin alphabets only
  • replace spaces with hyphens(-)
  • replace aphostrophes(') and dots(.) with nothing

PHP for replacing work:

PHP Code:
$name str_replace(array(" ""'""."), array("-"""""), $originalName); 
OP can edit this to the first post if he wants to.


Last edited by aksun: 10-18-2014 at 02:48 PM.
aksun is offline   Reply With Quote
Old
10-25-2014, 01:40 PM
  #14
Step7750
HFBoards Sponsor
 
Step7750's Avatar
 
Join Date: Jan 2014
Location: Calgary, Alberta
Country: Canada
Posts: 42
vCash: 500
Quote:
Originally Posted by aksun View Post
I found transparent high-quality player pictures from TSN site.

Example picture

API workaround:

Code:
GET http://tsnimages.tsn.ca/ImageProvider/PlayerHeadshot?seoId=[name]
So it's pretty easy to use it, just change the [name] to your player's name. There is a couple of things to keep in mind while using this system.
  • Latin alphabets only
  • replace spaces with hyphens(-)
  • replace aphostrophes(') and dots(.) with nothing

PHP for replacing work:

PHP Code:
$name str_replace(array(" ""'""."), array("-"""""), $originalName); 
OP can edit this to the first post if he wants to.
Great work, but I just don't understand why any reputable company would switch between alpha and numeric parameters for their calls since TSN also assigns ID's to each player.

I've added it to the OP.


Last edited by Step7750: 10-25-2014 at 01:49 PM.
Step7750 is offline   Reply With Quote
Old
10-30-2014, 11:13 AM
  #15
Ail
k.
 
Ail's Avatar
 
Join Date: Nov 2009
Location: Mysidia
Country: United States
Posts: 18,126
vCash: 500
Quote:
Originally Posted by aksun View Post
I found transparent high-quality player pictures from TSN site.

Example picture

API workaround:

Code:
GET http://tsnimages.tsn.ca/ImageProvider/PlayerHeadshot?seoId=[name]
So it's pretty easy to use it, just change the [name] to your player's name. There is a couple of things to keep in mind while using this system.
  • Latin alphabets only
  • replace spaces with hyphens(-)
  • replace aphostrophes(') and dots(.) with nothing

PHP for replacing work:

PHP Code:
$name str_replace(array(" ""'""."), array("-"""""), $originalName); 
OP can edit this to the first post if he wants to.
Oh, that is pretty cool. Thanks dude!

__________________

rip
Ail is offline   Reply With Quote
Old
11-04-2014, 03:40 PM
  #16
King Karl
Swagalicious
 
King Karl's Avatar
 
Join Date: Mar 2014
Location: Halifax, NS
Country: Canada
Posts: 466
vCash: 500
Quote:
Originally Posted by Step7750 View Post
Wow, I give you massive credit for doing that all manually.

You could create a PHP Server Side script that runs once a day/week/hour etc.. that checks the roster of the teams that played that day (or every single team roster) and get the stats of the goalies. You would then put that data into a MySQL database that your web page would gather info from when a user visits it.

You would have to tweak your website though since in order to extract data from MySQL, you would have to use a server side language like PHP which would then "echo" the tables with the stats.

PHP Example:




This PHP script generates a live scoreboard image based upon the parameters "gameid" and "date" on the url. It finds the team names, score, shots, plays, and logos, generates it and presents it to the user every single time the page is reloaded. Unlike HTML, it is impossible to see the source code of PHP since it runs server side. PHP files can also generate HTML documents pretty easily so it shouldn't be too much of a task.

ex.

Code:
<html> 
 <title>Calgary Flames Goalie Stats</title>
 <body>
 <h1>CALGARY FLAMES GOALTENDING HISTORY: YEAR-BY-YEAR</h1>

 <?php
 // PHP Code:
 // Extract the data from your database and generate the appropriate tables with the data
 ?>
 
 </body>
 </html>
Very cool stuff. Is there a way to have your tables in SQL automatically check for new stats and have them update themselves?

King Karl is offline   Reply With Quote
Old
11-05-2014, 12:22 PM
  #17
aksun
Registered User
 
Join Date: Oct 2014
Location: Oulu, Finland
Country: Finland
Posts: 3
vCash: 500
Quote:
Originally Posted by King Karl View Post
Very cool stuff. Is there a way to have your tables in SQL automatically check for new stats and have them update themselves?
I don't think that's possible. At least MySQL is not for that purpose(crawling data). But it's not hard to make a php script to update the table. Use cron jobs for the automatic script run.

good luck.

aksun is offline   Reply With Quote
Old
11-05-2014, 10:08 PM
  #18
King Karl
Swagalicious
 
King Karl's Avatar
 
Join Date: Mar 2014
Location: Halifax, NS
Country: Canada
Posts: 466
vCash: 500
Quote:
Originally Posted by aksun View Post
I don't think that's possible. At least MySQL is not for that purpose(crawling data). But it's not hard to make a php script to update the table. Use cron jobs for the automatic script run.

good luck.
Ah ok. I'm not overly familiar with PHP, but I've got a while to learn it. Any pointers you could give to a beginner about interacting between PHP and MySQL?

King Karl is offline   Reply With Quote
Old
11-06-2014, 02:28 AM
  #19
aksun
Registered User
 
Join Date: Oct 2014
Location: Oulu, Finland
Country: Finland
Posts: 3
vCash: 500
Quote:
Originally Posted by King Karl View Post
Ah ok. I'm not overly familiar with PHP, but I've got a while to learn it. Any pointers you could give to a beginner about interacting between PHP and MySQL?
You should use PDO for the MySQL link, it's best practise nowadays. Don't use mysql_* functions, they are deprecated in PHP.

aksun is offline   Reply With Quote
Old
11-09-2014, 11:41 AM
  #20
teris
Registered User
 
Join Date: Dec 2006
Country: Finland
Posts: 181
vCash: 500
First of all, many thanks for this thread everyone. Started two different projects thanks to the information here. Figured I should share my own findings as well so here goes.

Quote:
Originally Posted by Step7750 View Post
Thanks to meetc for the following info!

The returned JSON object can contain the following fields, some of them are not present prior to the start of the game.

PHP Code:
field                  datatype      descriptipon 
ata                    char
(3)       Away team acronym3 letter short name 
atc                    text          Before
blank During"progress" After"winner" if away team wins 
atcommon               text          away team common name 
atn                    text          away team city name 
ats                    int           away team score 
atsog                  int           Before
null During and Afteraway team shots on goal 
bs                     time
/text     Beforestart time (unsure if local or ESTDuring05:10 2ndeg After"FINAL""FINAL OT" etc 
bsc                    text          Before
blank During"progress" After"final" 
canationalbroadcasts   text          Canadian TV broadcasterscomma separated list 
gcl                    Bool          gamecenter live
gcll                   bool          gamecenter live
gs                     int           game status1=secheduled3in progress5=finished 
hta                    char
(3)       home team acronym 
htc                    text          Before
blank During"progress" After"winner" if home team wins 
htcommon               text          home team common name 
htn                    text          home team city name 
hts                    int           home team score 
htsog                  int           Before
null During and Afterhome team shots on goal 
id                     int           game ID 
rl                     Bool          true after game completed 
usnationalbroadcasts   text          US tv broadcasters
comma separated list 
Just to add to this here's what I received once right before the game was about to start with the relevant parts bolded:
Code:
{
      "atcommon": "DUCKS",
      "canationalbroadcasts": "",
      "ata": "ANA",
      "rl": false,
      "atsog": 0,
      "bs": "PREGAME",
      "htcommon": "AVALANCHE",
      "id": 2014020168,
      "atn": "ANAHEIM",
      "hts": "",
      "atc": "progress",
      "htn": "COLORADO",
      "usnationalbroadcasts": "",
      "gcl": true,
      "hta": "COL",
      "ats": "",
      "htc": "progress",
      "htsog": 0,
      "bsc": "progress",
      "gs": 2,
      "gcll": true
}
I would assume that "gs": 4 would mean post game broadcasting but I haven't witnessed it. I can confirm that it's US/Eastern time if "bs" has a start time. Secondly...

Quote:
Originally Posted by Step7750 View Post
Ex. Highlight Video URL: http://e1.cdnak.neulion.com/nhl/vod/...oal_1_1600.mp4


The URL can be accessed without any credentials, let me explain the structure for the URL to view any highlight from a game.

Base URL: http://e1.cdnak.neulion.com/nhl/vod/

/2014/ - Year of the game
/01/ - Month of the game
/30/ - Day of the game
/815/ - Game code (last 3 digits of the gameid)
2_ - It is a static value, always 2
815_ - Game code (last 3 digits of the gameid)
sjs_ - Away team (San Jose Sharks)
cgy_ - Home team (Calgary Flames)
1314_ - Game season (2013 - 2014)
h_discrete_ - Static value
CGY - Home team (Calgary Flames)
475_ - Highlight ID (You can obtain this from PlayByPlay.jsonp, gcbx.jsonp, gcsb.jsonp etc...)
goal_ - Type of highlight (Goal, save, hit etc...)
1_ - I don't really know what this value stands for, it is either 1 or 2
1600 - Bitrate of the highlight (This is the only bitrate available)
"h_discrete" is not actually static but two different variables. Replace "h" with "a" to get the away feed of the same highlight. It works most of the time including your example but sometimes only home or away is available. Next thing seems to be mostly for goals and home feeds but you can sometimes replace "discrete" with "ingame". It just gives you the same highlight but shorter with less buildup and no replays. There's also another base url. To demonstrate...

http://nhl.cdnllnwnl.neulion.net/u/n...oal_1_1600.mp4

http://nhl.cdnllnwnl.neulion.net/u/n...oal_1_1600.mp4

http://nhl.cdnllnwnl.neulion.net/u/n...oal_1_1600.mp4

teris is offline   Reply With Quote
Old
11-19-2014, 12:14 AM
  #21
Step7750
HFBoards Sponsor
 
Step7750's Avatar
 
Join Date: Jan 2014
Location: Calgary, Alberta
Country: Canada
Posts: 42
vCash: 500
Quote:
Originally Posted by teris View Post
"h_discrete" is not actually static but two different variables. Replace "h" with "a" to get the away feed of the same highlight.
Yeah, I saw this a long time ago when I was generating a tables that stored the URLs of every "highlight" for the past couple of years.

Also, it is hilarious that the full-length replays of each game do not require any credentials; so I just got the replays of every game for the past couple of years in a table by replicating the URL structure. At least the streams require credentials to view them.

Step7750 is offline   Reply With Quote
Old
11-19-2014, 10:04 AM
  #22
Doctor No
Mod Supervisor
Retired?
 
Doctor No's Avatar
 
Join Date: Sep 2005
Posts: 24,295
vCash: 500
I decided that this would be a valuable thread to sticky.

Doctor No is offline   Reply With Quote
Old
11-23-2014, 09:54 PM
  #23
King Karl
Swagalicious
 
King Karl's Avatar
 
Join Date: Mar 2014
Location: Halifax, NS
Country: Canada
Posts: 466
vCash: 500
Ok, so for a project, I'm looking to pull statistics from here, and the update an SQL database automatically with the information. I'd also like to do this for every team. How would I go about doing this? Most importantly though, is how would I take the information from that page and turn it into an SQL query, solely using PHP?
(I literally only started using PHP yesterday)


Last edited by King Karl: 11-23-2014 at 11:15 PM.
King Karl is offline   Reply With Quote
Old
11-25-2014, 07:53 PM
  #24
Step7750
HFBoards Sponsor
 
Step7750's Avatar
 
Join Date: Jan 2014
Location: Calgary, Alberta
Country: Canada
Posts: 42
vCash: 500
Quote:
Originally Posted by King Karl View Post
Ok, so for a project, I'm looking to pull statistics from here, and the update an SQL database automatically with the information. I'd also like to do this for every team. How would I go about doing this? Most importantly though, is how would I take the information from that page and turn it into an SQL query, solely using PHP?
(I literally only started using PHP yesterday)
Do know programming basics such as looping and recursion? If not, you should spend time in that area before you undertake any project.

Here are some tips:

- Loop through the url with an array consisting of the abbreviations:

"devils": "NJD",
"islanders": "NYI",
"rangers": "NYR",
"flyers": "PHI",
"penguins": "PIT",
"bruins": "BOS",
"sabres": "BUF",
"canadiens": "MTL",
"senators": "OTT",
"mapleleafs": "TOR",
"hurricanes": "CAR",
"panthers": "FLA",
"lightning": "TBL",
"capitals": "WSH",
"blackhawks": "CHI",
"redwings": "DET",
"predators": "NSH",
"blues": "STL",
"flames": "CGY",
"avalanche": "COL",
"oilers": "EDM",
"canucks": "VAN",
"ducks": "ANA",
"stars": "DAL",
"kings": "LAK",
"coyotes": "PHX",
"sharks": "SJS",
"bluejackets": "CBJ",
"wild": "MIN",
"jets": "WPG"

- While I don't particularly like W3Schools, try to figure out the structure of the Insert and Update statements for SQL (http://www.w3schools.com/sql/sql_insert.asp).

- You'll need to parse the json on the page using "json_decode" (http://php.net/manual/en/function.json-decode.php) and then loop through the given array to extract the needed info

- You may want a tool such as phpMyAdmin (http://www.phpmyadmin.net/home_page/index.php) to allow easier administration for the database(s)

Step7750 is offline   Reply With Quote
Old
11-26-2014, 02:56 PM
  #25
King Karl
Swagalicious
 
King Karl's Avatar
 
Join Date: Mar 2014
Location: Halifax, NS
Country: Canada
Posts: 466
vCash: 500
Quote:
Originally Posted by Step7750 View Post
Do know programming basics such as looping and recursion? If not, you should spend time in that area before you undertake any project.

Here are some tips:

- Loop through the url with an array consisting of the abbreviations:

"devils": "NJD",
"islanders": "NYI",
"rangers": "NYR",
"flyers": "PHI",
"penguins": "PIT",
"bruins": "BOS",
"sabres": "BUF",
"canadiens": "MTL",
"senators": "OTT",
"mapleleafs": "TOR",
"hurricanes": "CAR",
"panthers": "FLA",
"lightning": "TBL",
"capitals": "WSH",
"blackhawks": "CHI",
"redwings": "DET",
"predators": "NSH",
"blues": "STL",
"flames": "CGY",
"avalanche": "COL",
"oilers": "EDM",
"canucks": "VAN",
"ducks": "ANA",
"stars": "DAL",
"kings": "LAK",
"coyotes": "PHX",
"sharks": "SJS",
"bluejackets": "CBJ",
"wild": "MIN",
"jets": "WPG"

- While I don't particularly like W3Schools, try to figure out the structure of the Insert and Update statements for SQL (http://www.w3schools.com/sql/sql_insert.asp).

- You'll need to parse the json on the page using "json_decode" (http://php.net/manual/en/function.json-decode.php) and then loop through the given array to extract the needed info

- You may want a tool such as phpMyAdmin (http://www.phpmyadmin.net/home_page/index.php) to allow easier administration for the database(s)
Awesome. Thanks so much for your help. I'll post the finished product on here when it's done.

King Karl is offline   Reply With Quote
Reply

Forum Jump


Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



All times are GMT -5. The time now is 11:54 AM.

monitoring_string = "e4251c93e2ba248d29da988d93bf5144"
Contact Us - HFBoards - Archive - Privacy Statement - Terms of Use - Advertise - Top - AdChoices

vBulletin Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
HFBoards.com is a property of CraveOnline Media, LLC, an Evolve Media, LLC company. 2014 All Rights Reserved.