added test for session renewal timout

This commit is contained in:
Askill 2024-03-07 12:15:07 +01:00
parent 78d2ecad37
commit 78e0a84aa4
11 changed files with 43 additions and 6 deletions

6
.gitignore vendored
View File

@ -159,3 +159,9 @@ cython_debug/
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/
.vscode/settings.json
test_data/Lemon Mocktail .ttf
app/test_data/output/*.png
*.ttf
app/secrets.json
app/secrets.json
CREDENTIALS_PICKLE_FILE

0
app/__init__.py Normal file
View File

View File

@ -37,7 +37,7 @@ def get_next_tn(dir_name):
current_tn = {"current":tn_name}
with open(current_path, "r") as outfile:
with open(current_path, "w") as outfile:
outfile.write(json.dumps(current_tn))
return tn_name

View File

@ -1,10 +1,13 @@
{
"installed": {
"client_id": "",
"project_id": "",
"client_secret": "",
"client_id": "442472996695-fl9sqjjojqn91o3o1fm2vv15hmmoecom.apps.googleusercontent.com",
"project_id": "avid-lacing-376214",
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://oauth2.googleapis.com/token",
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs"
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
"client_secret": "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",
"redirect_uris": [
"https://localhost/api/v1/oauth2callback"
]
}
}

13
app/test.py Normal file
View File

@ -0,0 +1,13 @@
import time
from youtube import *
from test_data.gen_test_data import gen_img
while True:
gen_img()
youtube = get_authenticated_service()
video_id = "x2JOWQu-4Jc"
tn_path = "C:/projects/yt_thumb_roller/app/test_data/output"
set_thumbnail(youtube, video_id, tn_path)
time.sleep(1800)

View File

View File

@ -0,0 +1,13 @@
import datetime
from PIL import Image, ImageDraw, ImageFont
def gen_img():
img = Image.open('./app/test_data/in.png')
draw = ImageDraw.Draw(img)
txt = str(datetime.datetime.now())
myFont = ImageFont.truetype('app/test_data/Lemon Mocktail .ttf', 35)
draw.text((10, 150), txt, fill =(255, 255, 255), font=myFont)
img.save(f'app/test_data/output/{txt.replace(" ", "_").replace(":", "-")[:-7]}.png')
print(txt)

BIN
app/test_data/in.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

@ -0,0 +1 @@
{"current": "C:/projects/yt_thumb_roller/app/test_data/output\\2024-03-07_11-21-48.png"}

View File

@ -0,0 +1 @@
pillow

View File

@ -12,7 +12,7 @@ def get_authenticated_service():
scopes = ["https://www.googleapis.com/auth/youtube.readonly", "https://www.googleapis.com/auth/youtube.upload"]
api_service_name = "youtube"
api_version = "v3"
client_secrets_file = "secrets.json"
client_secrets_file = "app/secrets.json"
if os.path.exists("CREDENTIALS_PICKLE_FILE"):
with open("CREDENTIALS_PICKLE_FILE", 'rb') as f:
credentials = pickle.load(f)