diff --git a/open_workout_coach/__init__.py b/open_workout_coach/__init__.py new file mode 100644 index 0000000..0c6b80a --- /dev/null +++ b/open_workout_coach/__init__.py @@ -0,0 +1,6 @@ +from . import ( + load_exercises, + map_yaml_to_database, + create_open_workout_database, + exercise_config +) \ No newline at end of file diff --git a/open_workout_coach/__main__.py b/open_workout_coach/__main__.py new file mode 100644 index 0000000..dcde924 --- /dev/null +++ b/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() diff --git a/open_workout_coach/cli.py b/open_workout_coach/cli.py new file mode 100644 index 0000000..e69de29 diff --git a/create_open_workout_database.py b/open_workout_coach/create_open_workout_database.py similarity index 100% rename from create_open_workout_database.py rename to open_workout_coach/create_open_workout_database.py diff --git a/exercise_config.py b/open_workout_coach/exercise_config.py similarity index 100% rename from exercise_config.py rename to open_workout_coach/exercise_config.py diff --git a/load_exercises.py b/open_workout_coach/load_exercises.py similarity index 98% rename from load_exercises.py rename to open_workout_coach/load_exercises.py index 1c5ae66..a598be3 100644 --- a/load_exercises.py +++ b/open_workout_coach/load_exercises.py @@ -13,6 +13,7 @@ def get_video(url): return output_dir +@lru_cache(5) def create_gif_from_video_and_timestamps(video_path, start, end): video = mpy.VideoFileClip(video_path) clip: mpy.VideoFileClip = video.subclip(start, end) diff --git a/map_yaml_to_database.py b/open_workout_coach/map_yaml_to_database.py similarity index 91% rename from map_yaml_to_database.py rename to open_workout_coach/map_yaml_to_database.py index 33b08c7..078eca1 100644 --- a/map_yaml_to_database.py +++ b/open_workout_coach/map_yaml_to_database.py @@ -3,8 +3,7 @@ import tempfile import zipfile import os -from load_exercises import load_file_and_media_links -from create_open_workout_database import create_workout_session, create_item, create_workout_database +from open_workout_coach.create_open_workout_database import create_workout_session, create_item, create_workout_database ITEM_KEY_MEDIA_TYPE_MAP = { @@ -110,12 +109,3 @@ def process_config_into_workout_file(config, output_file = None): db_file=db, 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) - diff --git a/requirements.txt b/requirements.txt index eeea973..29d5b0d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,6 @@ pyyaml pytube moviepy -imageio \ No newline at end of file +imageio +ffmpeg-python +click