commit 0fdcda924e1479188fa668fa3d3610a2d581f519 Author: Robin Universe Date: Sat Jul 3 18:52:30 2021 -0500 Too Init To Quit diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 0000000..ee7d6a5 --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,14 @@ + DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE + Version 2, December 2004 + + Copyright (C) 2004 Sam Hocevar + + Everyone is permitted to copy and distribute verbatim or modified + copies of this license document, and changing it is allowed as long + as the name is changed. + + DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. You just DO WHAT THE FUCK YOU WANT TO. + diff --git a/__pycache__/app.cpython-38.pyc b/__pycache__/app.cpython-38.pyc new file mode 100644 index 0000000..f4e7459 Binary files /dev/null and b/__pycache__/app.cpython-38.pyc differ diff --git a/readme.md b/readme.md new file mode 100644 index 0000000..d331838 --- /dev/null +++ b/readme.md @@ -0,0 +1,31 @@ +# 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 + + + +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, then /twitfix/, and directly after, the full URL to the tweet you want to embed + + + +## How to run (server side) + +this is in a virtual environment, so first you should enter the virtual environment using `source env/bin/activate` and then you can start the server with `python3 twitfix.py` + + +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 + + + +this script uses the youtube-dl python module, along with flask + + + +This project is licensed under th **Do What The Fuck You Want Public License** + diff --git a/static/css/main.css b/static/css/main.css new file mode 100644 index 0000000..e9b423d --- /dev/null +++ b/static/css/main.css @@ -0,0 +1,4 @@ +body { + margin-right: 40%; + background: color 0; +} \ No newline at end of file diff --git a/templates/base.html b/templates/base.html new file mode 100644 index 0000000..31d6d63 --- /dev/null +++ b/templates/base.html @@ -0,0 +1,9 @@ + + + + {% block head %}{% endblock %} + + + {% block body %}{% endblock %} + + \ No newline at end of file diff --git a/templates/index.html b/templates/index.html new file mode 100644 index 0000000..e1804d6 --- /dev/null +++ b/templates/index.html @@ -0,0 +1,20 @@ +{% extends 'base.html' %} + +{% block head %} + + + + + + + + + + +{% endblock %} + +{% block body %} + +{% endblock %} \ No newline at end of file diff --git a/twitfix.py b/twitfix.py new file mode 100644 index 0000000..cf9347d --- /dev/null +++ b/twitfix.py @@ -0,0 +1,30 @@ +from flask import Flask, render_template, url_for, request, redirect +from datetime import datetime +import youtube_dl +import requests +import psutil +import os + +ydl = youtube_dl.YoutubeDL({'outtmpl': '%(id)s.%(ext)s'}) +app = Flask(__name__) + +@app.route('/twitfix/') +def twitfix(subpath): + if subpath.startswith('https://twitter.com'): + with ydl: + result = ydl.extract_info(subpath, download=False) + + return render_template('index.html', vidurl=result['url'], tweet=result['description'], pic=result['thumbnail'], user=result['uploader'], tweeturl=subpath) + else: + return "Please use a twitter link" + +@app.route('/info/') +def info(subpath): + with ydl: + result = ydl.extract_info(subpath, download=False) + + return result + +if __name__ == "__main__": + app.run(debug=False) + app.run(host='0.0.0.0', port=80)