Giter Club home page Giter Club logo

podcast-service's Introduction

Podcasts Service

Backend Service which can be used for creation a custom podcasts (sets of episodes) based on fetched public media resources.
This project provides a backend (API service) and is positioned as an updated version of podcast application.

GitHub Pipenv locked Python version Code style: black

Content

Project Description

Target

This application can be used for creation your podcasts.
If you have any sounds (or youtube videos as example) which you want to listen later, you can create podcast (via web interface) and attach your tracks to it
Created podcast (with prepared episodes) will have a direct link (to RSS feed), which can be used for adding your podcast to same podcast application (Add by URL)
Adding and downloading each new episodes will refresh RSS-feed and your APP will be able to get them.

Tech Stack

  • python 3.11
  • Starlette
  • RQ (background tasks)
  • yt-dlp (download audio tracks from external media platforms)
  • redis (key-value storage + RQ)
  • ffmpeg (audio postprocessing)

Tech details

Technically project contains from 3 parts:

Starlette API service (run on APP_PORT from your env):
  • AUTH service (JWT-based)
  • PODCAST service (CRUD API for podcasts/episodes)
  • Some tools and engines for fetching episodes from external resources (youtube as for now)
Media storage (S3):
  • episodes
  • generated RSS feeds
Background application: RQ
  • download sounds from requested resource
  • perform sound and prepare mp3 files with ffmpeg
  • generate RSS feed file (xml) with episodes (by specification https://cyber.harvard.edu/rss/rss.html)

Install Project

Prepare virtual environment

cd "<PATH_TO_PROJECT>"
cp .env.template .env
# update variables to actual (redis, postgres, etc.)

Prepare extra resources (postgres | redis)

export $(cat .env | grep -v ^# | xargs)
docker run --name postgres-etc -e POSTGRES_PASSWORD=${DATABASE_PASSWORD} -d postgres:10.11
docker run --name redis-etc -d redis

Create database

export $(cat .env | grep -v ^# | xargs)
PGPASSWORD=${DATABASE_PASSWORD} psql -U${DATABASE_USER} -h${DATABASE_HOST} -p${DATABASE_PORT} -c "create database ${DATABASE_NAME};"

Apply migrations

cd "<PATH_TO_PROJECT>" && make migrations_upgrade

Run Project

  • Run via docker-containers (like in production mode)
cd "<PATH_TO_PROJECT>" && docker-compose up --build
  • Run in develop-mode
# install pipenv https://pypi.org/project/pipenv/
cd "<PATH_TO_PROJECT>"
pipenv install --dev
make run_web
# or 
make run_rq

Useful commands

  • work with migrations
make migrations_create_auto   # auto-creation
make migrations_create_manual # manual-creation
make migrations_upgrade       # apply all migrations
make migrations_downgrade     # unapply with param `revision=1231`
make migrations_history       # show applied migrations
  • Run tests
cd "<PATH_TO_PROJECT>"/src && pytest 
  • Apply formatting (black) and lint code (pylint)
make lint

Environment Variables

REQUIRED Variables

argument description example
APP_HOST App default host running (used by docker compose) 127.0.0.1
APP_PORT App default port running (used by docker compose) 9000
APP_SERVICE Run service (web/celery/test) via entrypoint.sh web
SECRET_KEY Django secret key (security) abc3412j345j1f2d3f
SITE_URL URL address to the UI-part of the podcast APP https://podcast.site.com
SERVICE_URL URL address to the BE-part of the podcast APP https://podcast-service.site.com
DB_HOST PostgreSQL database host 127.0.0.1
DB_PORT PostgreSQL database port 5432
DB_NAME PostgreSQL database name podcast
DB_USERNAME PostgreSQL database username podcast
DB_PASSWORD PostgreSQL database password podcast_asf2342
S3_STORAGE_URL URL to S3-like file storage https://s3.storage.endpoint.net
S3_ACCESS_KEY_ID Public key to S3 storage
S3_SECRET_ACCESS_KEY Secret key to S3 storage
S3_REGION_NAME S3 region
S3_BUCKET_NAME S3 bucket podcast-media
S3_BUCKET_AUDIO_PATH S3 dir for episodes audio
S3_BUCKET_IMAGES_PATH S3 dir for images (episode,podcast covers) images
S3_BUCKET_RSS_PATH S3 dir for generated RSS feeds rss

OPTIONAL Variables

argument description default
JWT_EXPIRES_IN Default time for token's lifespan 300 (sec)
APP_DEBUG Run app in debug mode False
LOG_LEVEL Allows to set current logging level DEBUG
SENTRY_DSN Sentry dsn (if not set, error logs won't be sent)
REDIS_HOST Redis host localhost
REDIS_PORT Redis port 6379
REDIS_DB Redis db 0
REDIS_PROGRESS_PUBSUB_CH Subscribe channel name for progress events channel:episodes-progress
DB_NAME_TEST Custom name for DB name for tests DB_NAME + _test
SENDGRID_API_KEY Is needed for sending Email (invite, passw., etc)
EMAIL_FROM Is needed for sending Email
DB_ECHO Sending all db queries to stdout False
DB_ECHO Sending all db queries to stdout False

License

This product is released under the MIT license. See LICENSE for details.

podcast-service's People

Contributors

dmitryburnaev avatar dependabot[bot] avatar

Watchers

James Cloos 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.