Added advanced oEmbeds that allow for better video embeds with descriptions

This commit is contained in:
Robin Universe 2021-07-09 05:32:04 -05:00
parent d3e151904c
commit f0377f66a9
4 changed files with 51 additions and 14 deletions

View File

@ -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/<twitter video url>
https://fxtwitter.com/`<twitter video url>`
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/<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

View File

@ -2,19 +2,34 @@
{% block head %}
<meta content='text/html; charset=UTF-8' http-equiv='Content-Type' />
<meta name="twitter:card" content="player" />
<meta name="twitter:title" content="{{ user }}" />
<meta name="twitter:image" content="{{ pic }}" />
<meta name="twitter:player" content="{{ vidurl }}" />
<meta name="twitter:player:width" content="720" />
<meta name="twitter:player:height" content="480" />
<meta name="twitter:player:stream" content="{{ vidurl }}" />
<meta name="twitter:player:stream:content_type" content="video/mp4" />
<meta property="og:site_name" content="TwitFix">
<meta name="twitter:card" content="player" />
<meta name="twitter:title" content="{{ user }}" />
<meta name="twitter:image" content="{{ pic }}" />
<meta name="twitter:player" content="{{ vidurl }}" />
<!--<meta name="twitter:description" content="{{ desc }}" />!-->
<meta name="twitter:player:width" content="720" />
<meta name="twitter:player:height" content="480" />
<meta name="twitter:player:stream" content="{{ vidurl }}" />
<meta name="twitter:player:stream:content_type" content="video/mp4" />
<meta property="og:url" content="{{ vidlink }}" />
<meta property="og:video" content="{{ vidurl }}" />
<meta property="og:video:secure_url" content="{{ vidurl }}" />
<meta property="og:video:type" content="video/mp4" />
<meta property="og:video:width" content="720" />
<meta property="og:video:height" content="480" />
<meta property="og:title" content="{{ user }}" />
<!--<meta property="og:description" content="{{ desc }}" />!-->
<meta property="og:image" content="{{ pic }}" />
<!--!-->
<link rel="alternate" href="https://fxtwitter.com/oembed.json?desc={{ user }}&user={{ desc }}&link={{ link }}" type="application/json+oembed" title="{{ user }}">
<meta http-equiv = "refresh" content = "0; url = {{ vidlink }}" />
{% endblock %}
{% block body %}
<video width="100%" controls>
<source src="{{ vidurl }}" type="video/mp4">
</video>
Redirecting you to the tweet...
{% endblock %}

View File

@ -4,7 +4,7 @@ module = wsgi:app
master = true
processes = 5
socket = 80
socket = twitfix.sock
chmod-socket = 660
vacuum = true

View File

@ -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('/<path:subpath>')
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')