Giter Site home page Giter Site logo

fit-creator's Introduction

Python (and C#) project for scraping ZWIFT workouts and converting them to FIT Garmin workouts

1. Installation

Using vscode devcontainers

Ctrl+Shift+P > Open Folder in container

Manual

  1. Install any C# executable and add dotnet/Dynastream.FIT.Portable.dll dependency
  2. Install fit_creator python package e.g. using pip with
    pip install .
    

2. Basic usage

Just shell-execute

run.sh

It does three steps:

  1. Download all available html workout pages from whatsonzwift.com/workouts and saves them in data/html/zwift directory (somewhat time consuming - the internet is the bottleneck).
  2. Scrapes relevant info from each download page and saves workouts in .wkt format in data/workouts/wkt directory. (for all workouts, fast)
  3. Converts workouts from Build Me Up plan from data/workouts/wkt/Build_Me_Up from .wkt to .fit format and saves them in data/workouts/fit directory. This is veeeery time consuming. The work is done via dotnet run and it's C# code executed there - that's why I do this only for one (my favourite) plan. You can just run the last python command in run.sh with your favourite plan in place of Build_Me_Up.

Time: (downloading excluded)
real 2m44.838s
user 2m59.810s
sys 0m11.321s

3. Interesting stuff

I wrote my own serialization decorator.

@serializable
@dataclass
class Workout:
    name: str
    steps: list[WorkoutStep | WorkoutStepRepeat]
    created: datetime = datetime.now()

It solves the problem of flat deserializations performed by @dataclasses_json and maybe other libraries, as they don't seem to keep any information about the origin class. Therefore one can infer if a particular item in steps is WorkoutStep or WorkoutStepRepeat. The decorator adds 4 methods serialize, deserialize, load and save to your dataclass object and is easily extensible to support other data types.

fit-creator's People

Contributors

quczer avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.