evancohen / smart-mirror

The fairest of them all. A DIY voice controlled smart mirror with IoT integration.
http://smart-mirror.io
2.79k stars 695 forks source link

Sports Scores pulled from the Yahoo API #86

Closed kryptics closed 7 years ago

kryptics commented 8 years ago

Evan suggested looking at the weather js - i guess the idea would be to show the current sports scores like in the yahoo sports site maybe across the bottom of the screen, and they would up date automatically. You could just enter the names of sports teams into the config and it would show you scores. (it doesn't have to be yahoo, but at the moment i think thats the only free one, maybe google has one too) screen shot 2016-02-16 at 8 37 55 pm

dardub commented 8 years ago

I took a look at the yahoo api. But it's for fantasy league and I didn't see any sports scores in the documentation. I looked around for other options but I could not find any free sports stats, and they were actually kind of expensive. It looked like some people are just scraping websites to get the data. Anyway, if anyone knows any free apis for sports stats, please let me know!

kryptics commented 8 years ago

@dardub @evancohen will this work??? https://github.com/metral/scores minus the led of course - but can this be implemented into the code some how?

dardub commented 8 years ago

@kryptics There is a url in there for nbc sports api, though it looks like that service isn't available anymore.. That project hasn't had a commit in 2 years.

kryptics commented 8 years ago

@dardub ah chucks - what to the drawing board! thanks!

kryptics commented 8 years ago

someone just sent me this... what the hell does that mean? lol

$url = 'http://scores.nbcsports.msnbc.com/ticker/data/gamesMSNBC.js.asp?sport=MLB&period=20130413';

$data = file_get_contents($url); $records = json_decode($data);

$xmlDocument = implode("\n", $records->games); $xmlObjects = simplexml_load_string('<?xml version=\'1.0\'?> '. $xmlDocument . '');

foreach($xmlObjects AS $xml){ // get all attributes foreach($xml->attributes() AS $attribute=>$value){ echo $attribute . ' = '.$value ."\n"; // i.e: gamecode = 330413105 }

// visiting team: 
$visitingTeam='visiting-team';
print_r($xml->$visitingTeam);

// get visiting team attributes, like display_name, etc
foreach($xml->$visitingTeam->attributes() AS $attribute => $value){
    echo $attribute . ' = '.$value ."\n"; 
}

}

kurtdb commented 8 years ago

What it means is that they are scraping the results from the NBC-site. You should first read the disclaimer of their site to see if that's legal at all.

Next to that, the code is PHP, so we would have to convert it to Javascript. Looks like it's just a lot of XML parsing, but we won't know until we try.

kryptics commented 8 years ago

I see, i figure this is for personal use anyways... no?

kurtdb commented 8 years ago

The problem is that the software is open-source. There are numerous cases where companies send cease and desist letters to github because someone tried to integrate their API without respecting the disclaimer or the policy. I'ld rather keep a defensive policy and first ask before doing something.

It seems that other people also tried to achieve this and the same question was raised: https://gist.github.com/criccomini/3805436.

kryptics commented 8 years ago

ah good point

MikeMuratore commented 8 years ago

https://developer.fantasydata.com/?developer-portal I looked around for a second and found this. it allows a 1000 calls per month for free

evancohen commented 8 years ago

That would only let you refresh the data, on average, every 45 min - not enough to really keep up with any games, just to know the results...

kryptics commented 8 years ago

Still digging... might this help us? http://sportsdatabase.com/api

kurtdb commented 8 years ago

It looks like they send back historic data?

kryptics commented 8 years ago

Still hacking away i think this is my last try lol - i realize with out API you can't get the scores... BUT! with Google Cards you can - is there anyway we can incorporate google cards to the repo? there ya go for the minds of the smart mirror... @jeffrhap

justbill2020 commented 7 years ago

Migrated to http://feathub.com/evancohen/smart-mirror/+34

Issue will be closed and tracked on feathub moving forward. Please refer to feathub for all future comments on this suggestion.