From f0377f66a927b9b8011ef1019251a7f926e661cd Mon Sep 17 00:00:00 2001 From: Robin Universe Date: Fri, 9 Jul 2021 05:32:04 -0500 Subject: [PATCH] Added advanced oEmbeds that allow for better video embeds with descriptions --- readme.md | 6 ++++-- templates/index.html | 37 ++++++++++++++++++++++++++----------- twitfix.ini | 2 +- twitfix.py | 20 ++++++++++++++++++++ 4 files changed, 51 insertions(+), 14 deletions(-) diff --git a/readme.md b/readme.md index 4dc0541..4c05c0d 100644 --- a/readme.md +++ b/readme.md @@ -10,7 +10,7 @@ just put the url to the server, and directly after, the full URL to the tweet yo **I now have a copy of this running on a Linode server, you can use it via the following url** -https://fxtwitter.com/ +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: @@ -24,7 +24,7 @@ this script uses the youtube-dl python module, along with flask and pymongo, so 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 +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** @@ -35,3 +35,5 @@ This project is licensed under the **Do What The Fuck You Want Public License** Using the `/info/` endpoint will return a json that contains all video info that youtube-dl can grab about any given video Using `/other/` 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 diff --git a/templates/index.html b/templates/index.html index d93399e..a09dd2c 100644 --- a/templates/index.html +++ b/templates/index.html @@ -2,19 +2,34 @@ {% block head %} - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + {% endblock %} {% block body %} - +Redirecting you to the tweet... {% endblock %} \ No newline at end of file diff --git a/twitfix.ini b/twitfix.ini index 9812e2e..199a452 100644 --- a/twitfix.ini +++ b/twitfix.ini @@ -4,7 +4,7 @@ module = wsgi:app master = true processes = 5 -socket = 80 +socket = twitfix.sock chmod-socket = 660 vacuum = true diff --git a/twitfix.py b/twitfix.py index d3af460..06e1244 100644 --- a/twitfix.py +++ b/twitfix.py @@ -22,6 +22,13 @@ elif link_cache_system == "db": def default(): return render_template('default.html', message="TwitFix is an attempt to fix twitter video embeds in discord! created by Robin Universe :) 💖 ") +@app.route('/oembed.json') +def oembedend(): + desc = request.args.get("desc", None) + user = request.args.get("user", None) + link = request.args.get("link", None) + return oEmbedGen(desc,user,link) + @app.route('/') def twitfix(subpath): @@ -116,5 +123,18 @@ def vidInfo(url, tweet="", desc="", thumb="", uploader=""): # Return a dict of v } return vnf +def oEmbedGen(description, user, vidlink): + out = { + "type":"video", + "version":"1.0", + "provider_name":"TwitFix", + "provider_url":"https://github.com/robinuniverse/twitfix", + "title":description, + "author_name":user, + "author_url":vidlink + } + + return out + if __name__ == "__main__": app.run(host='0.0.0.0')