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

Feature: Sports Scores #342

Open
davepl opened this issue Jul 3, 2023 · 2 comments
Open

Feature: Sports Scores #342

davepl opened this issue Jul 3, 2023 · 2 comments

Comments

@davepl
Copy link
Contributor

davepl commented Jul 3, 2023

We need a sports score effect. It should use an API that is free and for which the user can sign up for their own key, so that everyone is not using the same API key, unless it's unlimited (even bettter!).

Scores should cycle through the specified teams or games at some interval. It would be nice if it showed current and change, used color to indicate up vs down, and so on. Look at other stock tickers to see what functionality is included (but don't overtly copy anyone's design!).

If they're similar enough, it would be nice to specify league, such as NFL, NBA, FIFA, and have it adapt, but if they're significantly different (like baseball might show current runners on base, outs, etc) they could either be separate effects or inherit from a base sports effect, etc.

@robertlipe
Copy link
Contributor

robertlipe commented Jul 4, 2023

Duplicate of #290

When I need a free API for something, I invariably land on lists from RapidAPI.com. (I used to use them for throw-away demos of graphing live data...) They front end a bazillion APIs, wrap them all in a generic API that makes them all consistent, provides sample code in every language that matters, then charges you if you hit their endpoints more than N (500?) times in a month. I can't remember if they mark up the fees from the real data providers or if they let you get a key from them, but since it's fundamental to their freemium model, they have it figured out.

So for this example, I'd let them do the homework to build the collection and skim
https://rapidapi.com/collection/sports-scores
as a place to start shopping. I also really liked their no nonsense doc.

Honestly, though, now that I think about it, a generic pile of records (https://rapidapi.com/categories) that you can display on Mesmerizer actually has a LOT going for it...It's been years and years since I've used them, but a Mesmerizer module that does the basic net fetch and parsing into an into an ordered map has a lot going for it. i don't know if it's worth taking to the next level to build an internal API/templating ("boilerplate", not C++ templates) so you could splash around text sizes, colors, labels, and contents, but that would be pretty cool.

Maybe a baseclass for RapidAPI that connected, fetched, refreshed, and handled API counts and depletion and "just" used a tiny superclass to splash the text up isn't so bad...

/grabs marker, approaches whiteboard...

class SportsBall : public RapidAPI
  int refresh_rate = 3600;
  Ctors, JSON jibberish for preserving state, but that didn't destroy flash
  
  virtual void OnCreated() override 
    read table of labels, draw in sizes, colors, etc.
    add any divider lines needed.
  virtual void OnRefreshed(int HTML code, std::map scores) override
   
    for (const &&s : scores, i++) {
      setCursor(10, i)
      setTextColor(something)
      g->print(s["name"])
      setcursor(20,i)
      g->print(s["score"])
    }

That's not totally terrible, though it looks kind of QuickBasic-y. Maybe there's some kind of a table for drawing

x, y, color, label
x, y, color, field.

from a constant array.

Then all these ideas become tiny little wrappers over HTTPClient and the various parsing stuff that we're all tired of writing. But it still requires writing C++ code and not just filling in a web form somewhere. It's still not a bad MVP. (ugh)

Thar may be gold in this hill somewhere...You just have to be really careful to not burn an API request on every display or something. Mesmerizer could eat 500 requests without a burp We don't make it too easy to use Mesmerizer for a DDOS attack. You probably want to NOT burn API calls in the dark, etc.

@rbergen
Copy link
Collaborator

rbergen commented Jul 4, 2023

This indeed seems to be a duplicate of #290. As that issue did not collect any responses yet, I'll keep this one open and close #290.

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

No branches or pull requests

3 participants