Giter Club home page Giter Club logo

engineervix / ten-lists Goto Github PK

View Code? Open in Web Editor NEW
3.0 3.0 2.0 2.09 MB

This project provides both a CLI and a webapp, which generate a playlist of 10 Bible Chapters (represented by 10 mp3 files) to be listened to on any given day, according to Professor Grant Horner's 10 lists Bible-Reading System.

Home Page: https://ten.dumela.cc

License: GNU General Public License v3.0

Python 41.10% Shell 3.33% JavaScript 6.06% CSS 13.14% HTML 33.54% Dockerfile 2.78% Procfile 0.04%
bible-reading mp3-files bible-playlist-generator bible-chapters eyed3 python flask-api cli

ten-lists's Introduction

ten-lists

This project provides both a CLI (using click) and a webapp (using flask), which generate a playlist of 10 Bible Chapters (represented by 10 mp3 files) to be listened to on any given day x, according to Professor Grant Horner's Bible-Reading System. The audio Bible is as downloaded from the Faith Comes by Hearing® website.

You can see the webapp in action here

python3.8 CircleCI Coverage Status Maintainability Codacy Badge Code style: black DeepSource Commitizen friendly Conventional Changelog Conventional Commits

Developer setup 💻

Requirements

Essential

Start by ensuring that you have Docker and Docker Compose:

# check that you have docker on your machine
docker -v
# check that you have docker-compose on your machine
docker-compose -v

If you don't have Docker and Docker Compose, then click the respective links above for installation instructions for your platform.

Extra

Good to have if you'd like to hack on the project. Not required if you just wanna run it, in which case Docker and Docker Compose will suffice.

  • A Python 3.8 virtual environment. You can use any tool of your choice to manage multiple Python versions on your machine.
    • Activate your python virtual environment and pip install --upgrade pip
    • Install dependencies: pip install -r requirements.txt.
    • Setup pre-commit by running pre-commit install followed by pre-commit install --hook-type commit-msg. Optionally run pre-commit run --all-files to make sure your pre-commit setup is okay.
  • Node.js v14
    • Install the Node.js dependencies via npm install

Installation

Upon cloning this repository (or forking + cloning your fork), navigate to the cloned project directory.

Then create the required environment variables file (.env) by making a copy of the provided sample file .env.sample and renaming it to .dev.env:

cp -v .env.sample .env

NOTE: If you're not using a docker-based deployment approach, then, for production, the file should be .prod.env, for staging .stage.dev

You should be able to run the project without updating anything. If you wanna update the mail settings (which you probably don't really need immediately) -- you could use a service like mailtrap.io for development. If you choose Mailtrap, then the variables to update are TENLISTS_EMAIL_USER_DEV and TENLISTS_EMAIL_PWD_DEV. The other settings are for use in production (SERVER_NAME and SENTRY_DSN).

Build the images and spin up the containers:

COMPOSE_PROJECT_NAME=tenlists docker-compose up -d --build

When you run the above for the first time, it may take a while, depending on your internet connection speed.

Once the build is complete, you can check the logs for the web container via

docker-compose logs web

If everything is ok, you should see something like this:

tenlists-web-1  | tenlists :: ready
tenlists-web-1  |  * Serving Flask app "tenlists.webapp.ten_lists" (lazy loading)
tenlists-web-1  |  * Environment: development
tenlists-web-1  |  * Debug mode: on
tenlists-web-1  |  * Running on http://0.0.0.0:5000/ (Press CTRL+C to quit)
tenlists-web-1  |  * Restarting with stat
tenlists-web-1  |  * Debugger is active!
tenlists-web-1  |  * Debugger PIN: 719-114-836

You can also check the logs for the node container via

docker-compose logs node

If all's well, you should see something like this:

tenlists-node-1  |
tenlists-node-1  | > [email protected] start /usr/src/app
tenlists-node-1  | > grunt
tenlists-node-1  |
tenlists-node-1  | Running "clean:dist" (clean) task
tenlists-node-1  | >> 4 paths cleaned.
tenlists-node-1  |
tenlists-node-1  | Running "newer:copy" (newer) task
tenlists-node-1  |
tenlists-node-1  | Running "newer:copy:fa" (newer) task
tenlists-node-1  |
tenlists-node-1  | Running "copy:fa" (copy) task
tenlists-node-1  | Copied 8 files
tenlists-node-1  |
tenlists-node-1  | Running "newer-postrun:copy:fa:1:/usr/src/app/node_modules/grunt-newer/.cache" (newer-postrun) task
tenlists-node-1  |
tenlists-node-1  | Running "newer:copy:bootstrap" (newer) task
tenlists-node-1  |
tenlists-node-1  | Running "copy:bootstrap" (copy) task
tenlists-node-1  | Copied 10 files
tenlists-node-1  |
tenlists-node-1  | Running "newer-postrun:copy:bootstrap:2:/usr/src/app/node_modules/grunt-newer/.cache" (newer-postrun) task
tenlists-node-1  |
tenlists-node-1  | Running "newer:copy:jquery" (newer) task
tenlists-node-1  |
tenlists-node-1  | Running "copy:jquery" (copy) task
tenlists-node-1  | Copied 4 files
tenlists-node-1  |
tenlists-node-1  | Running "newer-postrun:copy:jquery:3:/usr/src/app/node_modules/grunt-newer/.cache" (newer-postrun) task
tenlists-node-1  |
tenlists-node-1  | Running "newer:copy:moment" (newer) task
tenlists-node-1  |
tenlists-node-1  | Running "copy:moment" (copy) task
tenlists-node-1  | Copied 5 files
tenlists-node-1  |
tenlists-node-1  | Running "newer-postrun:copy:moment:4:/usr/src/app/node_modules/grunt-newer/.cache" (newer-postrun) task
tenlists-node-1  |
tenlists-node-1  | Running "newer:cssmin" (newer) task
tenlists-node-1  |
tenlists-node-1  | Running "newer:cssmin:dist" (newer) task
tenlists-node-1  | No newer files to process.
tenlists-node-1  |
tenlists-node-1  | Running "newer:uglify" (newer) task
tenlists-node-1  |
tenlists-node-1  | Running "newer:uglify:dist" (newer) task
tenlists-node-1  | No newer files to process.
tenlists-node-1  |
tenlists-node-1  | Running "browserSync:dev" (browserSync) task
tenlists-node-1  | [Browsersync] Proxying: http://web:5000
tenlists-node-1  | [Browsersync] Access URLs:
tenlists-node-1  |  -----------------------------------
tenlists-node-1  |        Local: http://localhost:3000
tenlists-node-1  |     External: http://151.26.0.3:3000
tenlists-node-1  |  -----------------------------------
tenlists-node-1  |           UI: http://localhost:3001
tenlists-node-1  |  UI External: http://localhost:3001
tenlists-node-1  |  -----------------------------------
tenlists-node-1  | [Browsersync] Watching files...
tenlists-node-1  |
tenlists-node-1  | Running "watch" task
tenlists-node-1  | Waiting...
tenlists-node-1  | [Browsersync] Reloading Browsers...
tenlists-node-1  | [Browsersync] Reloading Browsers...

You can access the dev server at http://127.0.0.1:5000.

You need the MP3 files

Now, at this stage, you probably won't get much from the now running app, because you actually need the MP3 files to work with! So, especially for the CLI tool, you have to download the Audio Bible from the Faith Comes by Hearing® website. The 2001 ESV dramatized Bible (size is over 2Gb) formed the basis for this project's code, including the expected filenames. If the file naming convention has changed, then there's a chance everything will break. Anyway, I hope that won't be the case ...

For the web app, we previously would create a directory ENGESVC2DA in tenlists/webapp/ten_lists/static/ and place your downloaded MP3 files in there. See this line in tenlists/webapp/ten_lists/main/routes.py.

However, the code has been rewritten in such a way as to use a cloud service (s3, MinIO, Backblaze, Cloudinary, etc.) for the files. This should hopefuly simplify both on-boarding and deployment, especially that at the time of writing this the webapp is deployed using Dokku. You'll therefore have to upload these files to your preferred cloud provider, and set the environment variable TENLISTS_MP3_CLOUD_STORAGE_BASE_URL (see that .env.sample file for details).

Concerning the CLI tool

This project started off initially as a CLI tool to generate these mp3 files on my computer and play them on a USB stick or copy them over to my phone. However, the scope later changed to have a web application that can allow me to listen from anywhere. So lately the focus has been more on the webapp than the CLI.

Notwithstanding, if you wanna use the CLI, you need to firstly ensure that you have a folder containing the required MP3 files, as described above. If you don't specify the folder when running the CLI tool, it'll assumes that there's a directory ENGESVC2DA in the project root. Once you've sorted this out, then you can run the CLI tool with the --help option so that you see how to use it:

If you have a setup a python virtual environment and installed the python dependencies as described earlier in this README

python tenlists/cli/__main__.py --help

So, for example 1, if I have my Bible folder ENGESVC2DA in the project root, and I run python tenlists/cli/__main__.py -d 87, I'll see the following in the console

python tenlists/cli/__main__.py -d 87
 _           _                __
|_)o|_ | _  |_)| _.  |o __|_ /__ _ ._  _ .__._|_ _ ._
|_)||_)|(/_ |  |(_|\/||_> |_ \_|(/_| |(/_|(_| |_(_)|
                   /

Welcome to the Bible Playlist Generator

Creating a playlist for day 87 ...
✓ playlist for day 87 successfully created.
✓ Copying of the Bible Chapters into the day087 directory was successful.
✓ ID3 tag info for the generated files in this directory has been updated.
✓ The files have been renamed in a sequential order.

-----Soli Deo Gloria-----

What has happended here? Well,

  • I ran a command to generate a playlist for day 87 of the Bible Reading Plan
  • The CLI tool has generated an M3U Playlist, day087.m3u in the project root
  • The CLI tool has created a folder, day087, in the project root -- containing the 10 MP3 files in the above playlist

Example 2; if I want to use tenlists/webapp/ten_lists/static/ENGESVC2DA/ as my folder, then I'll go ahead and

python tenlists/cli/__main__.py -d 87 -f tenlists/webapp/ten_lists/static/ENGESVC2DA/

And I'll see the same results!

If you're using Docker

docker-compose exec web python tenlists/cli/__main__.py --help

Everything remains the same as the case where you're not using Docker.

Tests

docker-compose exec web pytest

WARNING: Running this test will delete the directory `tenlists/webapp/ten_lists/static/ENGESVC2DA/, so please ensure that you have a copy of your MP3 files somewhere. This shouldn't be the case though, and I intend to fix it soon, as you can see it's top on the TODO list. Feel free to submit a PR if this hasn't been fixed!

Deployment

You can deploy this project using your preferred choice of deployment (Docker, Heroku, Linux Server, etc.). However, I have set it up to be ready "out of the box" for deployment to a VPS using Dokku.

If you're gonna use Dokku, feel free to use @engineervix/pre-dokku-server-setup to setup an Ubuntu Server on your VPS prior to installation of Dokku. You can have a look at this gist for more details of how to deploy an application to Dokku. Other excellent resources:

Notes

  • This project will be most useful to you if you use Professor Grant Horner's Bible-Reading System as the basis for your Bible Reading Plan.
  • The Audio Bible version used is the 2001 ESV dramatized Bible (complete), as freely downloaded from http://www.bible.is/audiodownloader. (The size is over 2Gb)

TODO

  • Fix test to avoid overwriting tenlists/webapp/ten_lists/static/ENGESVC2DA/ and deleting its contents
  • Use a CDN for the media files
  • write a Dokku deploy script
  • Use Invoke to encapsulate some tasks. For instance, docker-compose exec web python tenlists/cli/__main__.py --help is too long to type!
  • Address #1. configparser might come in handy here.
  • Package this project. This is a must read.
  • Improve Code Quality
  • Rather than using plain text files, find a better way of storing the Bible Chapters (JSON file, SQLite database, TinyDB, etc)
  • Create a GUI frontend or web service to cater for non-tech users in order to not only cater for non-tech users but also to listen on-the-go. See the webapp directory for the source code. Also see the package.json file.

Credits

ten-lists's People

Contributors

codacy-badger avatar dependabot-preview[bot] avatar dependabot[bot] avatar engineervix avatar pyup-bot avatar renovate-bot avatar renovate[bot] avatar snyk-bot avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

jkweiler afcarl

ten-lists's Issues

Action Required: Fix Renovate Configuration

There is an error with this repository's Renovate configuration that needs to be fixed. As a precaution, Renovate will stop PRs until it is resolved.

Location: .github/renovate.json
Error type: The renovate configuration file contains some invalid settings
Message: packageRules: You have included an unsupported manager in a package rule. Your list: circleci,docker. Supported managers are: (ansible, ansible-galaxy, argocd, azure-pipelines, batect, batect-wrapper, bazel, buildkite, bundler, cake, cargo, cdnurl, circleci, cloudbuild, cocoapods, composer, deps-edn, docker-compose, dockerfile, droneci, git-submodules, github-actions, gitlabci, gitlabci-include, gomod, gradle, gradle-lite, gradle-wrapper, helm-requirements, helm-values, helmfile, helmv3, homebrew, html, jenkins, kubernetes, kustomize, leiningen, maven, meteor, mix, nodenv, npm, nuget, nvm, pip-compile, pip_requirements, pip_setup, pipenv, poetry, pre-commit, pub, pyenv, regex, ruby-version, sbt, setup-cfg, swift, terraform, terraform-version, terragrunt, terragrunt-version, travis).

Improve coding standards

  • Use isort and related tools
  • Static type checking with mypy
  • Update pre-commit configuration with relevant hooks
  • Add linting job to CI and run pre-commit as part of CI
  • Use Invoke to manage tasks (the manage.py file should possibly be removed from the repo root and replaced with tasks.py)
  • Setup conventional-changelog
  • Setup test automation with tox

Week tracker

Hi Victor,
Thank you for this tool. I have been wanting to use Prof. Grant Horner's system for a while now, but do not have the hours needed to read ten chapters every day. Listening to it seems a great way to implement it for now, until life slows down and I can start reading more.

Would you consider adding a method to track the last week or day number in a file? Then, that could be used to generate the next week worth of M3U files, if no start number is provided in the command input?

Thanks for your consideration!

Initial Update

The bot created this issue to inform you that pyup.io has been set up on this repo.
Once you have closed it, the bot will open pull requests for updates as soon as they are available.

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Rate-Limited

These updates are currently rate-limited. Click on a checkbox below to force their creation now.

  • build(deps): update dependency colorama to v0.4.6
  • build(deps): update dependency eyed3 to v0.9.7
  • build(deps): update dependency flask-moment to v1.0.5
  • build(deps): update dependency flask-restful to v0.3.10
  • build(deps-dev): update dependency invoke to v1.7.3
  • chore(deps): update dependency grunt-contrib-clean to v2.0.1
  • fix(deps): update dependency bootstrap to v4.6.2
  • fix(deps): update dependency bootswatch to v4.6.2
  • build(deps): update dependency flask-debugtoolbar to v0.14.1
  • build(deps): update dependency flask-httpauth to v4.8.0
  • build(deps): update dependency flask-login to v0.6.3
  • build(deps): update dependency flask-talisman to v1.1.0
  • build(deps): update dependency pytest-flask to v1.3.0
  • build(deps-dev): update dependency autopep8 to v1.7.0
  • build(deps-dev): update dependency bpython to v0.24
  • build(deps-dev): update dependency commitizen to v2.42.1
  • build(deps-dev): update dependency gtts to v2.5.1
  • build(deps-dev): update dependency isort to v5.13.2
  • build(deps-dev): update dependency markupsafe to v2.1.5
  • chore(deps): update dependency clean-css to v5.3.3
  • chore(deps): update dependency commitizen to v4.3.0
  • chore(deps): update node.js to v14.21.3
  • chore(deps): update python docker tag to v3.12
  • fix(deps): update dependency jquery to v3.7.1
  • chore(deps): update actions/checkout action to v4
  • chore(deps): update dependency autopep8 to v2
  • chore(deps): update dependency commitizen to v3
  • chore(deps): update dependency doc8 to v1
  • chore(deps): update dependency faker to v24
  • chore(deps): update dependency flake8 to v7
  • chore(deps): update dependency flask-bcrypt to v1
  • chore(deps): update dependency flask-wtf to v1
  • chore(deps): update dependency grunt-contrib-cssmin to v5
  • chore(deps): update dependency invoke to v2
  • chore(deps): update dependency pre-commit to v3
  • chore(deps): update dependency pyfiglet to v1
  • chore(deps): update dependency pytest-cov to v5
  • chore(deps): update dependency python-dotenv to v1
  • chore(deps): update dependency termcolor to v2
  • chore(deps): update dependency ubuntu to v22
  • chore(deps): update node.js to v20
  • chore(deps): update softprops/action-gh-release action to v2
  • 🔐 Create all rate-limited PRs at once 🔐

Edited/Blocked

These updates have been manually edited so Renovate will no longer make changes. To discard all commits and start over, click on a checkbox.

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

circleci
.circleci/config.yml
  • cimg/python 3.8-node
  • cimg/python 3.8-node
  • cimg/python 3.8-node
docker-compose
docker-compose.yml
dockerfile
Dockerfile
  • python 3.8-slim-bullseye
docker/flask/Dockerfile
  • python 3.8-slim-bullseye
docker/node/Dockerfile
  • node 14.20.0-bullseye
github-actions
.github/workflows/greetings.yml
  • actions/first-interaction v1
.github/workflows/release.yml
  • actions/checkout v3
  • actions/checkout v3
  • actions/checkout v3
  • actions/checkout v3
  • actions/checkout v3
  • softprops/action-gh-release v1
  • python 3.8-slim-bullseye
  • ubuntu 20.04
  • python 3.8-slim-bullseye
  • ubuntu 20.04
  • python 3.8-slim-bullseye
  • ubuntu 20.04
  • python 3.8-slim-bullseye
  • ubuntu 20.04
  • ubuntu 20.04
npm
package.json
  • balloon-css ^1.2.0
  • bootstrap ^4.6.0
  • bootswatch ^4.3.1
  • font-awesome ^4.7.0
  • holderjs ^2.9.9
  • jquery ^3.6.0
  • moment ^2.29.1
  • clean-css ^5.1.5
  • commitizen ^4.2.5
  • cross-env ^7.0.3
  • cz-conventional-changelog ^3.3.0
  • grunt ^1.4.1
  • grunt-browser-sync ^2.2.0
  • grunt-contrib-clean ^2.0.0
  • grunt-contrib-copy ^1.0.0
  • grunt-contrib-cssmin ^4.0.0
  • grunt-contrib-htmlmin ^3.1.0
  • grunt-contrib-watch ^1.1.0
  • grunt-json-minification ^0.2.1
  • grunt-newer ^1.3.0
  • popper.js ^1.16.1
  • standard-version ^9.5.0
  • time-grunt ^2.0.0
  • node >= 14 <15
  • npm >= 6.13.4
  • node 14.20.1
pep621
pyproject.toml
pip_requirements
requirements.txt
  • colorama ==0.4.4
  • eyed3 ==0.9.6
  • flask ==1.1.4
  • flask-bcrypt ==0.7.1
  • flask-debugtoolbar ==0.11.0
  • flask-httpauth ==4.4.0
  • flask-login ==0.5.0
  • flask-mail ==0.9.1
  • flask-moment ==1.0.2
  • flask-restful ==0.3.9
  • flask-script ==2.0.6
  • flask-talisman ==1.0.0
  • flask-wtf ==0.15.1
  • markupsafe ==2.0.1
  • termcolor ==1.1.0
  • python-dotenv ==0.19.0
  • pyfiglet ==0.8.post1
  • autopep8 ==1.5.7
  • black ==21.12b0
  • bpython ==0.23
  • commitizen ==2.35.0
  • doc8 ==0.9.0
  • flake8 ==3.9.2
  • invoke ==1.7.1
  • isort ==5.9.3
  • pep8 ==1.7.1
  • pre-commit ==2.14.0
  • faker ==8.11.0
  • gtts ==2.2.3
  • tqdm ==4.62.0
  • pytest-cov ==2.12.1
  • pytest-flask ==1.2.0
  • gunicorn ==20.1.0
  • sentry-sdk ==1.3.1

  • Check this box to trigger a request for Renovate to run again on this repository

eyed3 requirement

It looks like there is also a prerequisite to install the eyeD3 module. I have tested with eyeD3-0.6.18 in Python2.7, but I was getting an error that the module doesn't exist:

$ python ./scripture_playlist_gen.py 1
Traceback (most recent call last):
File "./scripture_playlist_gen.py", line 24, in
import eyed3
ImportError: No module named eyed3

Eventually, I realized the module has an uppercase 'D' in the name, so I edited the python script to use that. Now I'm getting an error about an invalid attribute:

$ python ./scripture_playlist_gen.py 1
The playlist for day 1 has been created successfully.
Copying of the Bible Chapters into the day001 directory was successful.
Traceback (most recent call last):
File "./scripture_playlist_gen.py", line 437, in
audiofile = eyeD3.load(f)
AttributeError: 'module' object has no attribute 'load'

Can you tell me what version of eyeD3 you tested with?

can't open file 'Scripture.py': [Errno 2] No such file or directory

Hi again, Victor.

Now that the Python script is executing successfully, I tested the make_one_week_playlist.sh script in Cygwin. There is a typo on line 41 of the current version where it's attempting to call 'Scripture.py' instead of 'scripture_playlist_gen.py'. This results in the error:

C:\asdf\Installed\python27\python.exe: can't open file 'Scripture.py': [Errno 2] No such file or directory

After correcting that call, the shell script now runs properly. Adding the date to the playlist name and directory name is a nice feature, btw.

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.