Browse Source

Make package and cli

main
gabriel becker 1 year ago
parent
commit
5611f134e3
  1. 6
      open_workout_coach/__init__.py
  2. 27
      open_workout_coach/__main__.py
  3. 0
      open_workout_coach/cli.py
  4. 0
      open_workout_coach/create_open_workout_database.py
  5. 0
      open_workout_coach/exercise_config.py
  6. 1
      open_workout_coach/load_exercises.py
  7. 12
      open_workout_coach/map_yaml_to_database.py
  8. 2
      requirements.txt

6
open_workout_coach/__init__.py

@ -0,0 +1,6 @@
from . import (
load_exercises,
map_yaml_to_database,
create_open_workout_database,
exercise_config
)

27
open_workout_coach/__main__.py

@ -0,0 +1,27 @@
import click
from open_workout_coach.load_exercises import load_file_and_media_links
from open_workout_coach.map_yaml_to_database import process_config_into_workout_file
@click.group("cli")
def cli():
pass
@cli.command()
@click.argument('input_path', type=click.Path(exists=True))
@click.argument('output_path', type=click.Path(exists=False))
def create_plan(input_path, output_path):
"""
Creates a openworkout plan from the input yaml file.
"""
config = load_file_and_media_links(file_path=input_path)
process_config_into_workout_file(config=config, output_file=output_path)
FILE = 'data/input/samples/exercises.yaml'
if __name__ == '__main__':
cli()

0
open_workout_coach/cli.py

0
create_open_workout_database.py → open_workout_coach/create_open_workout_database.py

0
exercise_config.py → open_workout_coach/exercise_config.py

1
load_exercises.py → open_workout_coach/load_exercises.py

@ -13,6 +13,7 @@ def get_video(url):
return output_dir return output_dir
@lru_cache(5)
def create_gif_from_video_and_timestamps(video_path, start, end): def create_gif_from_video_and_timestamps(video_path, start, end):
video = mpy.VideoFileClip(video_path) video = mpy.VideoFileClip(video_path)
clip: mpy.VideoFileClip = video.subclip(start, end) clip: mpy.VideoFileClip = video.subclip(start, end)

12
map_yaml_to_database.py → open_workout_coach/map_yaml_to_database.py

@ -3,8 +3,7 @@ import tempfile
import zipfile import zipfile
import os import os
from load_exercises import load_file_and_media_links from open_workout_coach.create_open_workout_database import create_workout_session, create_item, create_workout_database
from create_open_workout_database import create_workout_session, create_item, create_workout_database
ITEM_KEY_MEDIA_TYPE_MAP = { ITEM_KEY_MEDIA_TYPE_MAP = {
@ -110,12 +109,3 @@ def process_config_into_workout_file(config, output_file = None):
db_file=db, db_file=db,
video_files=videos, video_files=videos,
) )
FILE = 'data/input/samples/exercises.yaml'
if __name__ == '__main__':
config = load_file_and_media_links(FILE)
process_config_into_workout_file(config)

2
requirements.txt

@ -2,3 +2,5 @@ pyyaml
pytube pytube
moviepy moviepy
imageio imageio
ffmpeg-python
click

Loading…
Cancel
Save