BetterTwitFix/configHandler.py
Dylan 7ff1031627 Squashed commit of the following:
commit 4fe0af4e6a4a15ee4796a857e79ad0fe9b72c0f1
Author: Dylan <dylanpdx@gmail.com>
Date:   Wed Dec 28 18:09:25 2022 +0000

    Misc. changes to MP4 Looping function

commit 42ef8845c38c5a74e56da3c5f035d5a6c091c86a
Author: Dylan <dylanpdx@gmail.com>
Date:   Tue Dec 27 20:00:22 2022 +0000

    Abandoning raw gif conversion for now; looping vid instead

commit b61938b340a02ac8cfab02048b7e9deaf87edbf5
Author: Dylan <dylanpdx@gmail.com>
Date:   Tue Dec 27 19:38:58 2022 +0000

    More work on WIP gif generation

commit 3bc6e7e0da1ce6ae905c80bbbaaa55a68050de52
Author: Dylan <dylanpdx@gmail.com>
Date:   Mon Dec 26 14:46:46 2022 +0000

    Experimental gif conversion
2022-12-28 18:22:11 +00:00

45 lines
2.0 KiB
Python

import json
import os
if ('RUNNING_TESTS' in os.environ):
config= {"config":{"link_cache":"ram","database":"","table":"","color":"","appname": "vxTwitter","repo": "https://github.com/dylanpdx/BetterTwitFix","url": "https://vxtwitter.com","combination_method": "local","gifConvertAPI":""}}
elif ('RUNNING_SERVERLESS' in os.environ and os.environ['RUNNING_SERVERLESS'] == '1'): # pragma: no cover
config = {
"config":{
"link_cache":os.environ["VXTWITTER_LINK_CACHE"],
"database":os.environ["VXTWITTER_DATABASE"],
"table":os.environ["VXTWITTER_CACHE_TABLE"],
"color":os.environ["VXTWITTER_COLOR"],
"appname": os.environ["VXTWITTER_APP_NAME"],
"repo": os.environ["VXTWITTER_REPO"],
"url": os.environ["VXTWITTER_URL"],
"combination_method": os.environ["VXTWITTER_COMBINATION_METHOD"], # can either be 'local' or a URL to a server handling requests in the same format
"gifConvertAPI":os.environ["VXTWITTER_GIF_CONVERT_API"]
}
}
else:
# Read config from config.json. If it does not exist, create new.
if not os.path.exists("config.json"):
with open("config.json", "w") as outfile:
default_config = {
"config":{
"link_cache":"json",
"database":"[url to mongo database goes here]",
"table":"TwiFix",
"color":"#43B581",
"appname": "vxTwitter",
"repo": "https://github.com/dylanpdx/BetterTwitFix",
"url": "https://vxtwitter.com",
"combination_method": "local", # can either be 'local' or a URL to a server handling requests in the same format
"gifConvertAPI":""
}
}
json.dump(default_config, outfile, indent=4, sort_keys=True)
config = default_config
else:
f = open("config.json")
config = json.load(f)
f.close()