3 util functions for main so the ui looks nicer and also 1 bug fix for python 3.9 or above. :)

pull/1172/head
cooler 3 years ago
parent 7ad01ef51a
commit d03363a280

@ -1,8 +1,10 @@
#!/usr/bin/env python
import math
import os
import re
from subprocess import Popen
from os import name
from sys import platform
from prawcore import ResponseException
@ -24,6 +26,45 @@ from video_creation.voices import save_text_to_mp3
__VERSION__ = "2.4.1"
### 3 util functions. by github.com/notcooler ###
def getPlatform():
plt = "unknown"
if platform == "linux" or platform == "linux2":
plt = "lin"
elif platform == "win32":
plt = "win"
elif platform == "darwin":
plt = "mac"
return plt
def clear():
if getPlatform() == "win":
os.system('cls')
elif getPlatform() == "lin" or getPlatform() == "mac":
os.system('clear')
else:
pass
def setConsoleSize(*_x, **_y):
x = '23'
y = '78'
if _x != None and len(_x) != 0: x = str(_x[0])
if _y != None and len(_x) != 0: y = str(_x[1])
if getPlatform() == "win":
os.system(f'mode {y},{x}')
elif getPlatform() == "lin" or getPlatform() == "mac":
os.system(f'resize -s {x} {y}')
else:
pass
### end util functions ###
# Clear console #
clear()
# Set console size so the banner looks good. #
setConsoleSize(389, 20);
# Print Banner
print(
"""

@ -41,9 +41,8 @@ def get_subreddit_threads(POST_ID: str):
check_for_async=False,
)
except ResponseException as e:
match e.response.status_code:
case 401:
print("Invalid credentials - please check them in config.toml")
# match wasnt supported for python 3.9+ or above. So fixed it with a simple if stament.
if(e.response.status_code == 401): print("Invalid credentials - please check them in config.toml")
except:
print("Something went wrong...")

Loading…
Cancel
Save