Skip to content

jb2311/espn-ffb

 
 

Repository files navigation

espn-ffb

espn-ffb is a project to query fantasy football data from ESPN's API and persist it in your own database. There is a very basic web component with a few views built using Flask that allows you to self-host your own fantasy football league page.

Until all raw SQL is converted to ORM, this will only work with PostgreSQL, but you can modify the queries in query.py to work with other databases supported by SQLAlchemy.

Sample views:

Setup

Two modes are supported:

  • Run with Docker (easiest)
  • Run locally (requires PostgreSQL instance)

Pre-requisites:

Run with Docker

Run locally

Config:

Edit config.py with your own:

  • Database credentials in DevConfig and ProdConfig.
  • LEAGUE_ID
  • swid (private leagues)
  • espn_s2 (private leagues)

To find your swid and espn_s2 in Chrome, go to DevTools > Application > Cookies > https://fantasy.espn.com.

Run with Docker

Set up .env file

cp .env.sample .env

Edit .env and replace POSTGRES_PASSWORD with your preferred password.

Run

docker-compose up -d

Open browser to http://localhost:5000.

Set up database

To set up the database the first time, you can run the following command:

docker-compose run espn-ffb sh ./setup.sh

Update

docker-compose run espn-ffb sh ./update.sh

If you are running with Docker, stop here.

Run locally

Requirements:

pip3 install -r requirements.txt

Set up database:

python3 -m espn_ffb.setup -e {dev|prod}

Run:

# run with python3
python3 -m espn_ffb.app -e {dev|prod}

# run with uwsgi
uwsgi --http 0.0.0.0:5000 --ini conf/espn-ffb-{dev|prod}.ini

Open browser to http://localhost:5000.

Update:

python3 -m espn_ffb.db.update -e {dev|prod}

Deploy as Debian package

Build:

./gradlew clean build buildDeb -PbuildNumber=local

Install:

sudo dpkg -i build/distributions/espn-ffb*.deb

The .deb package includes two .service files:

  • espn-ffb.service: Starts espn-ffb Flask app
  • espn-ffb-update.service: Updates espn-ffb database

Recaps:

Sample recap templates as an example of how to structure written recaps.

Generate a new blank recap template:

python3 -m espn_ffb.scripts.generate_recap -e {dev|prod} -y {year} -w {week}

Contributors

  • yorch - Thank you for the Docker support!

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 36.1%
  • Python 34.1%
  • CSS 18.3%
  • HTML 10.4%
  • Kotlin 0.7%
  • Dockerfile 0.3%
  • Shell 0.1%