Skip to content

Latest commit

 

History

History
101 lines (82 loc) · 10.3 KB

README.md

File metadata and controls

101 lines (82 loc) · 10.3 KB

Simple Media Converter

Table of Contents

Introduction

Have you ever been in a situation where you needed a quick and simple way to change the format of your files? Perhaps your friend has shared with you a funny video but your phone was unable to open it? Well, Simple Media Converter is just what you need!

Simple Media Converter is a telegram bot that allows users to upload files (videos, images and even telegram stickers!) to have them converted to the format they desire. With support for a wide variety of formats, this bot brings about a lot of convenience for those looking to just make a simple file conversion! In fact, convenience is what drove me to embark on this project and I hope to add more functionalities and conversion types to the bot in the near future. Should this appeal to you, then its usage is as simple as dropping your files to the bot today!

Features

Simple Media Converter currently accepts 3 types of input (videos, images and telegram stickers). Supported formats for each type can be found within the .env.template file. By default, all supported formats are included within the template, but you can always remove any of the formats as desired.

If you require support for additional formats that are not yet available in the application, feel free to open an issue or even better, make a pull request and help make the project better!

Technologies

Technologies used by Simple Media Converter are as below:

Done with:

Python

Project Repository

Setup

The following section will guide you through setting up your own Simple Media Converter (telegram account required).

  1. First, head over to BotFather and create your own telegram bot with the /newbot command. After choosing an appropriate name and telegram handle for your bot, note down the bot token provided to you.
  2. Next, cd to the directory of where you wish to store the project and clone this repository. An example is provided below:
    cd /home/user/exampleuser/projects/
    git clone https://github.com/tjtanjin/simple-media-converter.git
    
  3. Once the project has been cloned, cd into it and install required dependencies with the following command:
    python3 -m pip install --no-cache-dir -r requirements.txt
    
  4. Following which, create (or copy) a .env file at the root of the project using the provided .env.template. In order to run the bot, the bare minimum that needs to be done is for you to replace the BOT_TOKEN variable within the .env file with the token you received from BotFather.
  5. You can also feel free to modify the other variables as you deem fit. Clear descriptions for the variables have been included in the .env.template file.
  6. When you are done with configurations, create 2 directories at the root of the project named input_media and output_media. These folders will be used to temporarily hold media files during conversions:
    mkdir input_media
    mkdir output_media
    
  7. Finally, head to the root of the project and execute the following command to launch your bot:
    python3 main.py
    

Deployment

Docker

For deployment, Docker is the preferred approach, especially if you would like to avoid the hassle of manually installing dependencies. If you are unfamiliar with docker, it is recommended you go through a quick tutorial for it first. This section will not dive into the details of docker usage.

  1. First, if you have not done so, create a .env file from the provided .env.template and update the variables (at the very least, you need to input a valid BOT_TOKEN).
  2. If you using the project as it is (i.e. no intended code changes), then simply run ./deploy.sh simple-media-converter within the scripts folder and your deployment will be automatically done! Otherwise, if you wish to make code changes to the project, please read on.
  3. Once you are done with your code changes, you would have to build your own docker image with the following command (take note to replace the tag -t with that of your own):
    docker build -t tjtanjin/simple-media-converter .
    
  4. Upon obtaining your image, you may then start your container with the following command (remember to replace image name below if you built your own image):
    docker run -d --name smc --env-file .env tjtanjin/simple-media-converter:master
    
    Note: Notice that the .env file we configured in step 1 is being passed via the --env-file argument. This is true for the auto deployment in step 2 as well. Hence, ensure that you have setup your configuration properly before passing in the file.
  5. Finally, you may wish to update the deployment script to reference your own image/container if you would like to have an easier deployment workflow.

Manual

Alternatively, if you are unfamiliar with docker or would like a more manual approach, you may also follow the guide here to setup the bot 24/7. Note that you would have to go through the steps in the setup section to setup the project manually as well.

Team

Contributing

If you wish to make code contributions to the project, then please be advised to give the Developer Guide a read. Once you are ready, feel free to open a pull request and describe clearly the changes and what they are intended to do (enhancement, bug fixes etc).

Alternatively, you may contact me via discord or simply raise bugs or suggestions by opening an issue.

Others

For any questions regarding the implementation of the project, you may reach out on discord or drop an email to: cjtanjin@gmail.com.