Structure of the App
- Flask web app
- Grabber – fetches video IDs from a specified YouTube Playlist and saves them as JSON files
- Loader – loads video IDs and the ID of the device that added the playlist into the database
Functionality
The app needs to be able to ingest playlist URLs and work with them at regular intervals.
- When someone enters a new playlist
- Run Grabber
- Run Loader
- When someone returns to the app
- Run Grabber
- Run Loader
- At intervals
- Run Grabber
- Run Loader
Possibilities
- Celery – http://docs.celeryproject.org/en/latest/getting-started/first-steps-with-celery.html
- Sched – https://docs.python.org/3/library/sched.html
- Zappa – would have to integrate Grabber and Loader with the Flask WSGI app
- Schedule – https://pypi.org/project/schedule/
Things to consider
- Running concurrently – as the app gets more widely used, waiting for one user’s videos to be included before another’s can start (running serially) will be inconvenient.
- How long does it take? If it’s too long I may need to store when videos were last checked for and only bring in those added since then.
- Running Grabber and Loader at intervals is relatively unimportant, it’s utility would be for when a parent is actively adding videos to a playlist while the child is using it.
- Should Grabber and Loader be added to the main app as functions?
-
Do I need to refactor the app into separate files? I’m reluctant to do that as it’s actually working now.