mirror of
https://github.com/Paillat-dev/viralfactory.git
synced 2026-01-02 09:16:19 +00:00
Formatting & improving imports
This commit is contained in:
@@ -1,2 +1,2 @@
|
||||
from . import prompting
|
||||
from . import youtube_uploading
|
||||
from . import youtube_uploading
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import yaml
|
||||
import os
|
||||
from typing import TypedDict
|
||||
|
||||
import yaml
|
||||
|
||||
|
||||
class Prompt(TypedDict):
|
||||
system: str
|
||||
@@ -9,7 +10,7 @@ class Prompt(TypedDict):
|
||||
|
||||
|
||||
def get_prompt(
|
||||
name, *, location: str = "src/chore/prompts", by_file_location: str = None
|
||||
name, *, location: str = "src/chore/prompts", by_file_location: str = None
|
||||
) -> tuple[str, str]:
|
||||
if by_file_location:
|
||||
path = os.path.join(
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
from http import client
|
||||
import httplib2
|
||||
import random
|
||||
import time
|
||||
from http import client
|
||||
|
||||
import google.oauth2.credentials
|
||||
import httplib2
|
||||
from googleapiclient.discovery import build
|
||||
from googleapiclient.errors import HttpError
|
||||
from googleapiclient.http import MediaFileUpload
|
||||
@@ -34,6 +34,7 @@ API_VERSION = "v3"
|
||||
|
||||
VALID_PRIVACY_STATUSES = ("public", "private", "unlisted")
|
||||
|
||||
|
||||
def get_youtube(oauth_credentials: dict):
|
||||
oauth_credentials = google.oauth2.credentials.Credentials(
|
||||
token=oauth_credentials["token"],
|
||||
@@ -45,6 +46,7 @@ def get_youtube(oauth_credentials: dict):
|
||||
)
|
||||
return build(API_SERVICE_NAME, API_VERSION, credentials=oauth_credentials)
|
||||
|
||||
|
||||
def upload(oauth_credentials, options):
|
||||
youtube = get_youtube(oauth_credentials)
|
||||
tags = None
|
||||
@@ -106,7 +108,7 @@ def resumable_upload(request):
|
||||
if retry > MAX_RETRIES:
|
||||
exit("No longer attempting to retry.")
|
||||
|
||||
max_sleep = 2**retry
|
||||
max_sleep = 2 ** retry
|
||||
sleep_seconds = random.random() * max_sleep
|
||||
print("Sleeping %f seconds and then retrying..." % sleep_seconds)
|
||||
time.sleep(sleep_seconds)
|
||||
@@ -116,4 +118,4 @@ def upload_thumbnail(video_id, path, oauth_credentials):
|
||||
youtube = get_youtube(oauth_credentials)
|
||||
youtube.thumbnails().set( # type: ignore
|
||||
videoId=video_id, media_body=path
|
||||
).execute()
|
||||
).execute()
|
||||
|
||||
Reference in New Issue
Block a user