Fix Twitter video embeds in Discord (and Telegram!)
Find a file
2021-12-02 19:13:43 -06:00
static/css Too Init To Quit 2021-07-03 18:52:30 -05:00
templates Update inline.html 2021-12-02 19:00:41 -06:00
.gitignore Delete __pycache__ and add it to .gitignore 2021-10-06 11:38:07 +02:00
example.gif Added config system, Updated readme, Fixed DB connections stalling with multiple uWSGI workers, Made it less prone to crashing if necessary files are not present 2021-07-11 15:48:17 -05:00
LICENSE.txt Too Init To Quit 2021-07-03 18:52:30 -05:00
links.json Added automatic link redirecting for t.co links in non video tweets when using the API 2021-07-14 19:15:06 -05:00
readme.md Added new monthly contributor and mentioned /latest/ 2021-12-02 19:13:43 -06:00
requirements.txt Refactored a majority of the code in preparation for twitter API implementation, not quite there yet, but it's at least as functional as it was before I started 2021-07-12 03:49:07 -05:00
twitfix.ini Added advanced oEmbeds that allow for better video embeds with descriptions 2021-07-09 05:32:04 -05:00
twitfix.py Several changes 2021-12-02 18:58:36 -06:00
twitfix.service Added a new link caching system, updated the readme, started ignoreing pycache 2021-07-07 22:17:23 -05:00
wsgi.py Added a new link caching system, updated the readme, started ignoreing pycache 2021-07-07 22:17:23 -05:00

TwitFix

Basic 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

I now have a copy of this running on a Linode server, you can use it via the following url

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

You can also simply type out 'fx' directly before 'twitter.com' in any valid twitter video url, and that will convert it into a working TwitFix url, for example:

example

Note: If you enjoy this service, please considering donating via Ko-Fi to help cover server costs

Monthly Contributors

TwitFix is run for free, period, I have no plans to monetize it directly in any way ( no ads, no premium accounts with more features ) so I rely on donations to keep TwitFix running, and I have created the option to donate on a monthly basis using my KoFi

Here's a a list of the people who help to keep this project alive

  1. [$3] First Contributor and Twitter Funnyman Chris Burwell ( @countchrisdo on Twitter )

  2. [$9] Previously highest Contributor, Suspciously wealthy furry, and a very loving friend Vectrobe ( @Vectrobe on Twitter )

  3. [$10] New highest monthly contributor, helloitscrash!

How to run (server side)

this script uses the youtube-dl python module, along with flask, twitter and pymongo, so install those with pip (you can use pip install -r requirements.txt) and start the server with python twitfix.py

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

Config

TwitFix generates a config.json in its 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

Other stuff

Going to https://fxtwitter.com/latest/ will present a page that shows the latest video that was added to the database, use with caution as results may be nsfw!

Using the /dir/<video-url> endpoint will return a redirect to the direct MP4 link, this can be useful for downloading a video

Using the /info/<video-url> endpoint will return a json that contains all video info that youtube-dl can grab about any given video

Using /other/<video-url> will attempt to run the twitter embed stuff on other websites videos - This is mostly experimental and doesn't really work for now

Advanced embeds are provided via a /oembed.json? endpoint - This is manually pointing at my server in /templates/index.html and should be changed from https://fxtwitter.com/ to whatever your domain is

We check for t.co links in non video tweets, and if one is found, we direct the discord useragent to embed that link directly, this means that twitter links containing youtube / vimeo links will automatically embed those as if you had just directly linked to that content