Creating Twitch Highlights and Posting Daily to Reddit with Python

Creating Twitch Highlights and Posting Daily to Reddit with Python

In this post, I will describe how to put this project on AWS ECS Fargate and automatically post the videos to Reddit every day. If you have a project that you would like to run on a schedule, feel free to look at this without looking at part 1.

In part 1 of this post, I described a Python project where we get trending videos from Twitch, edit them with moviepy and post them to Reddit.

In this post, I will describe how to put this project on AWS ECS Fargate and automatically post the videos to Reddit every day. If you have a project that you would like to run on a schedule, feel free to look at this without looking at part 1.

Pre-requisites

Outline

There are 3 steps to Part 2:

  • Running the code locally in a Docker container
  • Uploading the Docker container to ECS Fargate.
  • Creating Task Definitions to run on a schedule.

Part 1 — Docker

Docker is a containerisation service. It lets us define a computer as small as we need called an image, we can then put this image on the cloud and run tasks within the image as we need. Cloud services typically charge for how large the image you are storing is, Amazon Elastic Container Registry (ECR) for example, let’s you store 1GB of images for free a month and any larger they charge you.

A Docker image is defined with a Dockerfile. In the Dockerfile below we pull from the python:3 image so we do not need to install all the python packages, we then copy in the relevant files, set our working directory and declare our environmental variables.

FROM python:3
    ENV PYTHONUNBUFFERED 1

    COPY requirements.txt /code/requirements.txt
    RUN pip install -r /code/requirements.txt

    COPY get_videos.py /code/get_videos.py
    COPY edit_videos.py /code/edit_videos.py
    COPY upload_video.py /code/upload_video.py
    COPY main.py /code/main.py
    COPY env.list /code/env.list

    WORKDIR /code/

    ENV number_of_videos ""
    ENV key ""
    ENV mode ""
    ENV twitch_id ""
    ENV streamable_username ""
    ENV streamable_password ""
    ENV reddit_username ""
    ENV reddit_password ""
    ENV subreddit ""
    ENV reddit_id ""
    ENV reddit_secret ""

docker python aws-ecs aws moviepy

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

Creating Twitch Highlights and Posting Daily to Reddit with Python, Docker

In this tutorial, we will make a Python script to automatically post the top Twitch clips from a time period from either a game or a Twitch channel to a subreddit.

ICYMI: From Docker Straight to AWS Built-in

Learn from Docker experts to simplify and advance your app development and management with Docker. Stay up to date on Docker events and new version announcements!

Python Tricks Every Developer Should Know

In this tutorial, you’re going to learn a variety of Python tricks that you can use to write your Python code in a more readable and efficient way like a pro.

Docker Explained: Docker Architecture | Docker Registries

Following the second video about Docker basics, in this video, I explain Docker architecture and explain the different building blocks of the docker engine; docker client, API, Docker Daemon. I also explain what a docker registry is and I finish the video with a demo explaining and illustrating how to use Docker hub.

How to Remove all Duplicate Files on your Drive via Python

Today you're going to learn how to use Python programming in a way that can ultimately save a lot of space on your drive by removing all the duplicates. We gonna use Python OS remove( ) method to remove the duplicates on our drive. Well, that's simple you just call remove ( ) with a parameter of the name of the file you wanna remove done.