Fix Twitter video embeds in Discord

Overview

TwitFix

very basic flask server that fixes twitter embeds in discord by using youtube-dl to grab the direct link to the MP4 file and embeds the link to it in a custom page, with link caching

This does work! but I'm new to flask, so it can probably be improved a great deal.

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/

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

How to run (server side)

this script uses the youtube-dl python module, along with flask and pymongo, so install those with pip (you can use pip install -r requirements.txt) and start the server with python twitfix.py ( will need sudo if you leave it at port 80 )

By default I have the port set to 80, just cause that's what was convenient for me, but it can easily be changed, either using an environment variable, or changing the bottom line of the script itself

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 by going into the script and change link_cache_system from json to "db", and inserting you mongoDB address, as having many workers writing to the same json file doesn't really work

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

Other stuff

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

Comments
  • Extract modules: Configuration, Statistics, Link Cache, Storage

    Extract modules: Configuration, Statistics, Link Cache, Storage

    Hi. I apologize if this seems sudden and out of the blue, or like a lot of work. I was hoping that I might offer my services in a bit of an uplift.

    In preparation for containerization a little bit of cleanup is required.

    • Configuration module is extracted which allows previous configuration but also adds the possibility to configure via environment variables.
    • Statistics module is extracted to separate the non-functional JSON variant from the MongoDB which is current.
    • Link Cache module is extracted providing the previous JSON behavior, as well as MongoDB, configurable by configuration.
    • Storage Module is extracted to handle the current media folder for downloading. In addition the storage location is now configurable.

    Next steps:

    • Use a Python packaging tool for Virtual Environments. I suggest Poetry
    • Creating a Dockerfile and emulating existing deployment via a docker-compose file.
    • Implementation of alternative cache, storage, statistics modules.
    • Creating a deployment script which allows serverless deployment using the docker container.
      • I've focused on the area I know best, which is the Google Cloud Platform
      • Cloud Run handles the service.
      • Firestore as database.
      • Cloud Storage as media store. (with possibility for automatic expiry)

    (jk. I've got all of the above ready.)

    Future:

    • This should scale up quite significantly without too much overhead, it might even work just fine under googles free tier.
    • There is potential for hangups during media downloads, one proposal is to use Task Queue to run a download-to-storage module while letting the request either complete or await completion.
    opened by StormyDragon 2
  • Naming conventions of some variables do not match that defined in the python spec

    Naming conventions of some variables do not match that defined in the python spec

    The naming conventions for variables, functions, methods and objects are laid out in this document.

    The names of the variables and functions have been changed to match that of the python spec.

    opened by nbtm-sh 2
  • Add Revolt's user agent

    Add Revolt's user agent

    See https://revolt.chat/ The source code that uses this user agent is here: https://github.com/revoltchat/january/blob/b0fab877838a71f90c18fc5301b8461d0e3c58e5/src/util/request.rs#L10

    You can test this without registering to Revolt by making a GET request to its API (no authentication required), i.e.:

    https://jan.revolt.chat/embed?url=https://fxtwitter.com/dm4catbot/status/1413797797187440640
    
    opened by Jackenmen 1
  • Added fallback links in case automatic forwarding is blocked.

    Added fallback links in case automatic forwarding is blocked.

    When I tried to open a link, I had to manually change the URL from fxtwitter.com back to twitter.com in order to be redirected to the orignal tweet. So here's a small suggestion to help others who are experiencing the same problem.

    opened by abbeysside 1
  • Fix tweet text content appearing in telegram and some other stuff

    Fix tweet text content appearing in telegram and some other stuff

    • Fix video quality sorting (i didnt quite understand what a dict was)
    • Fix screen_name naming consistency
      • screen_name seems to be blank in prod (fxtwitter.com) but works fine in dev env
    • Fix img accessed before declaration
    • Hopefully tweet text content shows now in telegram
    • Add flask_cors dependency
    • Remove unnecesary react-helmet garbage
    opened by adryd325 0
  • Shorten link and remove 500 errors

    Shorten link and remove 500 errors

    By comparing against a regex we can detect if the link is in the proper format, and allow for excluding https://twitter.com/" in the url. this allows for swapping outtwitter.comfortwtfix.me` in place, and having the link instantly work.

    Also removed some unused imports that were causing issue as they were not in the requires.txt

    opened by cbondurant 0
  • Improve support for photo links

    Improve support for photo links

    This implements the change I suggested at https://github.com/robinuniverse/TwitFix/issues/44#issuecomment-1065567675

    Additionally cleans up the matching a bit, tweaks the readme, fixes a missing entry in requirements.txt, and simplifies local testing a little.

    I haven't fully tested this end-to-end, as I don't have twitter API access set up, but everything seems to behave as expected in the logs.

    opened by rcombs 2
Owner
Robin Universe
she/her ☆ falling with style
Robin Universe
An EmbedBuilder in Python for discord.py embeds. Pip Module.

Discord.py-MaxEmbeds An EmbedBuilder for Discord bots in Python. You need discord.py to use this module. Installation Step 1 First you have to install

Max Tischberger 6 Jan 13, 2022
Bot that embeds a random hysterical meme from Reddit into your text channel as an embedded message, using an API call.

Discord_Meme_Bot ?? Bot that embeds a random hysterical meme from Reddit into your text channel as an embedded message, using an API call. Add the bot

null 2 Jan 16, 2022
Actively maintained, pure Python wrapper for the Twitter API. Supports both normal and streaming Twitter APIs.

Twython Twython is a Python library providing an easy way to access Twitter data. Supports Python 3. It's been battle tested by companies, educational

Ryan McGrath 1.9k Jan 2, 2023
Quickly and efficiently delete your entire tweet history with the help of your Twitter archive without worrying about the pointless 3200 tweet limit imposed by Twitter.

Twitter Nuke Quickly and efficiently delete your entire tweet history with the help of your Twitter archive without worrying about the puny and pointl

Mayur Bhoi 73 Dec 12, 2022
Twitter bot that finds new friends in Twitter.

PythonTwitterBot Twitter Bot Thats Find New Friends pip install textblob pip install tweepy pip install googletrans check requirements.txt file Env

IbukiYoshida 4 Aug 11, 2021
A twitter multi-tool for OSINT on twitter accounts.

>TwitterCheckr A twitter multi-tool for OSINT on twitter accounts. Infomation TwitterCheckr also known as TCheckr is multi-tool for OSINT on twitter a

IRIS 16 Dec 23, 2022
twitter bot tha uses tweepy library class to connect to TWITTER API

TWITTER-BOT-tweepy- twitter bot that uses tweepy library class to connect to TWITTER API replies to mentions automatically and follows the tweet.autho

Muziwandile Nkomo 2 Jan 8, 2022
Twitter-bot - A Simple Twitter bot with python

twitterbot To use this bot, You will require API Key and Access Key. Signup at h

Bentil Shadrack 8 Nov 18, 2022
Twitter-redesign - Twitter Redesign With Django

Twitter Redesign A project that tests Django and React knowledge through a twitt

Mark Jumba 1 Jun 1, 2022
use python script to fix vmp dump api in ida

FixVmpDump use python script to fix vmp dump api in ida. support x86 and x64. details in my blog: https://blog.csdn.net/yan_star/article/details/11279

null 97 Nov 2, 2022
A site devoted to celebrating to matching books with readers and readers with books. Inspired by the Readers' Advisory process in library science, Literati, and Stitch Fix.

Welcome to Readers' Advisory Greetings, fellow book enthusiasts! Visit Readers' Advisory! Menu Technologies Key Features Database Schema Front End Rou

jane martin 6 Dec 12, 2021
Seems Like Everyone Is Posting This, Thought I Should Too, Tokens Get Locked Upon Creation And Im Not Going To Fix For Several Reasons

Member-Booster Seems Like Everyone Is Posting This, Thought I Should Too, Tokens Get Locked Upon Creation And Im Not Going To Fix For Several Reasons

Mintyz 1 Dec 28, 2021
📢 Video Chat Stream Telegram Bot. Can ⏳ Stream Live Videos, Radios, YouTube Videos & Telegram Video Files On Your Video Chat Of Channels & Groups !

Telegram Video Chat Bot (Beta) ?? Video Chat Stream Telegram Bot ?? Can Stream Live Videos, Radios, YouTube Videos & Telegram Video Files On Your Vide

brut✘⁶⁹ // ユスフ 15 Dec 24, 2022
Video Stream is a telegram bot project that's allow you to play video on telegram group video chat

Video Stream is a telegram bot project that's allow you to play video on telegram group video chat ?? Get SESSION_NAME from below: Pyrogram ## ✨ Featu

null 1 Nov 10, 2021
Video Stream: an Advanced Telegram Bot that's allow you to play Video & Music on Telegram Group Video Chat

Video Stream is an Advanced Telegram Bot that's allow you to play Video & Music on Telegram Group Video Chat ?? Get SESSION_NAME from below: Pyrogram

Jonathan 6 Feb 8, 2022
Video Bot: an Advanced Telegram Bot that's allow you to play Video & Music on Telegram Group Video Chat

Video Bot is an Advanced Telegram Bot that's allow you to play Video & Music on

null 5 Jan 26, 2022
Video Stream: an Advanced Telegram Bot that's allow you to play Video & Music on Telegram Group Video Chat

Video Stream is an Advanced Telegram Bot that's allow you to play Video & Music

SHU KURENAI TEAM 4 Nov 5, 2022
Twitter bot to know the number of dislikes of a YouTube video

YT_dislikes is a twitter bot that allows you to know the number of dislikes (and likes) of a YouTube video. Now it is not possible to see the number o

null 1 Jan 8, 2022
This is a Python package to create a snowflake identifier similar to Discord's or Twitter's.

snowflake2 Based on falcondai and fenhl's Python snowflake tool, but with documentation and simliarities to Discord. Installation instructions Install

Learnloot 2 Mar 19, 2022