Git Product home page Git Product logo

twitfix's Introduction

TwitFix

Flask server that serves fixed twitter video embeds to desktop discord by using either the Twitter API or Youtube-DL to grab tweet video information. This also automatically embeds the first link in the text of non video tweets (API Only)

How to use (discord side)

just put the url to the server, and directly after, the full URL to the tweet you want to embed

This fork is running in a Google Cloud Run container

https://ayytwitter.com/[twitter video url] or [last half of twitter url] (everything past twitter.com/)

You can also simply type out 'ayy' directly before 'twitter.com' in any valid twitter video url, and that will convert it into a working TwitFix url, pretend for example that fx is just ayy, well, you get the gist:

example

Robin Universe's Other Projects:

Note: If you enjoy this service, please considering donating via Ko-Fi as the original creator

TwitFix-Bot - A discord bot for automatically converting normal twitter links posted by users into twitfix links

TwitFix-Extension - A browser extention that lets you right click twitter videos to copy a twitfix link to your clipboard

How to run

deploy/here

  • systemd
  • poetry

This deploy.sh script installs a user service which runs as long as the user is logged in. Useful for testing. You may also follow directions for making the service linger. The configuration for uwsgi lives in twitfix.ini this is the deployment method used by TwitFix originally.

I have included some files to give you a head start on setting this server up with uWSGI, though if you decide to use uWSGI I suggest you set up mongoDB link caching

deploy/local

  • docker
  • docker-compose

docker-compose up to launch everything; this is a blueprint using mongodb as the database and a dedicated volume as the download location.

deploy/gcp

  • terraform
  • gcloud
  • A project set up on google cloud platform.

This deployment script can be run with the following commands which will set up a dedicated Cloud Run service with the Firestore database keeping the links and Google Cloud Storage to host files, handled by a dedicated limited service account.

terraform init
terraform apply -var-file template.tfvars

Config

Configuration can be done through the environment by specifying the environment variable CONFIG_FROM with the value environment. Some sensible defaults have been added to the various deployment scripts.

CONFIG_FROM=environment
TWITFIX_CONFIG_FROM="environment"
TWITFIX_STORAGE_MODULE="local_storage"
TWITFIX_LINK_CACHE= "json"
TWITFIX_DB="..."
TWITFIX_DB_TABLE="..."
TWITFIX_DOWNLOAD_METHOD="youtube-dl"
TWITFIX_COLOR="#43B581"
TWITFIX_APP_NAME="TwitFix"
TWITFIX_REPO="https://github.com/stormydragon/twitfix"
TWITFIX_BASE_URL="https://localhost:8080"
TWITFIX_DOWNLOAD_BASE="/tmp"
TWITFIX_TWITTER_API_KEY="..."
TWITFIX_TWITTER_API_SECRET="..."
TWITFIX_TWITTER_ACCESS_TOKEN="..."
TWITFIX_TWITTER_ACCESS_SECRET="..."

Config (deprecated)

The older method of configuration relies on generating a config.json in the root directory the first time you run it, the options are:

API - This will be where you put the credentials for your twitter API if you use this method

database - This is where you put the URL to your mongoDB database if you are using one

link_cache - (Options: db, json)

  • db: Caches all links to a mongoDB database. This should be used it you are using uWSGI and are not just running the script on its own as one worker
  • json: This saves cached links to a local links.json file

method - ( Options: youtube-dl, api, hybrid )

  • youtube-dl: the original method for grabbing twitter video links, this uses a guest token provided via youtube-dl and should work well for individual instances, but may not scale up to a very large amount of usage

  • api: this directly uses the twitter API to grab tweet info, limited to 900 calls per 15m

  • hybrid: This will start off by using the twitter API to grab tweet info, but if the rate limit is reached or the api fails for any other reason it will switch over to youtube-dl to avoid downtime

color - Accepts a hex formatted color code, can change the embed color

appname - Can change the app name easily wherever it's shown

repo - used to change the repo url that some links redirect to

url - used to tell the user where to look for the oembed endpoint, make sure to set this to your public facing url

This project is licensed under the Do What The Fuck You Want Public License

twitfix's People

Contributors

abbeysside avatar adryd325 avatar cbondurant avatar daisyuniverse avatar doruksega avatar izofeu avatar jackenmen avatar qtlunya avatar stormydragon avatar yay295 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.