diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d344ba6 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +config.json diff --git a/example.gif b/example.gif index d73c757..b152121 100644 Binary files a/example.gif and b/example.gif differ diff --git a/readme.md b/readme.md index 4c05c0d..80840ff 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/`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: diff --git a/twitfix.py b/twitfix.py index f233058..f9f149c 100644 --- a/twitfix.py +++ b/twitfix.py @@ -3,19 +3,34 @@ import pymongo import youtube_dl import json import re +import os app = Flask(__name__) pathregex = re.compile("\\w{1,15}\\/status\\/\\d{19}") -link_cache_system = "json" # Select your prefered link cache system, "db" for mongoDB or "json" for locally writing a json file ( not great if using multiple workers ) +if not os.path.exists("config.json"): + with open("config.json", "w") as outfile: + default = {"config":{"link_cache":"json","database":"[url to mongo database goes here]","method":"youtube-dl"},"api":{"consumer_key":"[consumer key goes here]","consumer_secret":"[consumer secret goes here]","access_token_key":"[access token key goes here]","access_token_secret":"[access token secret goes here]"}} + json.dump(default, outfile, indent=4, sort_keys=True) + +f = open("config.json") +config = json.load(f) +f.close() + +link_cache_system = config['config']['link_cache'] # Select your prefered link cache system, "db" for mongoDB or "json" for locally writing a json file ( not great if using multiple workers ) if link_cache_system == "json": link_cache = {} + if not os.path.exists("config.json"): + with open("config.json", "w") as outfile: + deflinkcache = {"test":"test"} + json.dump(deflinkcache, outfile, indent=4, sort_keys=True) + f = open('links.json',) link_cache = json.load(f) f.close() elif link_cache_system == "db": - client = pymongo.MongoClient("PUT YOUR MONGODB URL HERE") + client = pymongo.MongoClient(config['config']['database'], connect=False) db = client.TwitFix @app.route('/')