Minor changes

pull/2058/head
Mohamed Moataz 1 year ago
parent d89953cc89
commit 39e75f728a

@ -75,7 +75,7 @@ def main(POST_ID=None) -> None:
video_path = make_final_video(number_of_comments, length, reddit_object, bg_config, reel)
video_path = compress_video(video_path)
video_data, thumbnail_text = get_video_data(post_text)
video_data, thumbnail_text = get_video_data(post_text, bg_config)
print("Video title:", video_data['title'])
print("Video description:", video_data['description'])
print("Video tags:", video_data['tags'])
@ -89,7 +89,7 @@ def main(POST_ID=None) -> None:
print("Thumbnail generated successfully at:", thumbnail)
upload_video_to_youtube(video_path, video_data, thumbnail)
if settings.config["settings"]["debug"]["debug"]:
if not settings.config["settings"]["debug"]["debug"]:
shutil.rmtree(f"./assets/temp/{reddit_object['thread_id']}/")

@ -91,7 +91,7 @@ def get_subreddit_threads(POST_ID: str):
threads, subreddit, similarity_scores=similarity_scores
)
else:
threads = subreddit.hot(limit=25)
threads = subreddit.top(time_filter="all")
submission = get_subreddit_undone(threads, subreddit)
if submission is None:

@ -22,6 +22,8 @@ ai_similarity_keywords = {optional = true, type="str", example= 'Elon Musk, Twit
[settings]
allow_nsfw = { optional = false, type = "bool", default = false, example = false, options = [true, false, ], explanation = "Whether to allow NSFW content, True or False" }
theme = { optional = false, default = "dark", example = "light", options = ["dark", "light", "transparent", ], explanation = "Sets the Reddit theme, either LIGHT or DARK. For story mode you can also use a transparent background." }
text_font_filename = { optional = false, default = "Roboto-Bold.ttf", example = "Roboto-Bold.ttf", explanation = "The font to be used for the video text." }
text_font_size = { optional = false, default = 100, example = 100, explanation = "The size of the font to be used for the video text." }
times_to_run = { optional = false, default = 1, example = 2, explanation = "Used if you want to run multiple times. Set to an int e.g. 4 or 29 or 1", type = "int", nmin = 1, oob_error = "It's very hard to run something less than once." }
opacity = { optional = false, default = 0.9, example = 0.8, explanation = "Sets the opacity of the comments when overlayed over the background", type = "float", nmin = 0, nmax = 1, oob_error = "The opacity HAS to be between 0 and 1", input_error = "The opacity HAS to be a decimal number between 0 and 1" }
#transition = { optional = true, default = 0.2, example = 0.2, explanation = "Sets the transition time (in seconds) between the comments. Set to 0 if you want to disable it.", type = "float", nmin = 0, nmax = 2, oob_error = "The transition HAS to be between 0 and 2", input_error = "The opacity HAS to be a decimal number between 0 and 2" }
@ -38,8 +40,8 @@ reuse_images = { optional = false, type = "bool", default = false, example = fal
reuse_video = { optional = false, type = "bool", default = false, example = false, options = [true, false, ], explanation = "Use already generated video" }
[settings.background]
background_video = { optional = true, default = "mudrunner", example = "rocket-league", options = ["mudrunner", "granny-remake", ""], explanation = "Sets the background for the video based on game name" }
background_audio = { optional = true, default = "eerie", example = "chill-summer", options = ["eerie", "mysterious", "hybrid",""], explanation = "Sets the background audio for the video" }
background_video = { optional = true, default = "mudrunner", example = "granny-remake", explanation = "Sets the background for the video based on game name" }
background_audio = { optional = true, default = "eerie", example = "hybrid", explanation = "Sets the background audio for the video" }
background_audio_volume = { optional = true, type = "float", nmin = 0, nmax = 1, default = 0.15, example = 0.05, explanation="Sets the volume of the background audio. If you don't want background audio, set it to 0.", oob_error = "The volume HAS to be between 0 and 1", input_error = "The volume HAS to be a float number between 0 and 1"}
enable_extra_audio = { optional = true, type = "bool", default = false, example = false, explanation="Used if you want to render another video without background audio in a separate folder", input_error = "The value HAS to be true or false"}
background_thumbnail = { optional = true, type = "bool", default = false, example = false, options = [true, false,], explanation = "Generate a thumbnail for the video (put a thumbnail.png file in the assets/backgrounds directory.)" }

@ -1,18 +1,28 @@
{
"__comment": "Supported Backgrounds Audio. Can add/remove background audio here...",
"eerie":[
"https://www.youtube.com/watch?v=OozBNFEa4PM",
"eerie.mp3",
"Royalty Free Music"
"haunted_forest":[
"https://www.youtube.com/watch?v=Yb5XQ9i-gtI",
"haunted_forest.mp3",
"@RPGAmbientSounds"
],
"mysterious":[
"https://www.youtube.com/watch?v=lRwq7pfA4Gg",
"mysterious.mp3",
"Royalty Free Music"
"scary_forest":[
"https://www.youtube.com/watch?v=BzYPUjtEVqs",
"scary_forest.mp3",
"@GravitySound"
],
"hybrid":[
"https://www.youtube.com/watch?v=QbqkR5VNaU8",
"hybrid.mp3",
"Royalty Free Music"
"night_of_the_dead":[
"https://www.youtube.com/watch?v=tmlZeYnfw7g",
"night_of_the_dead.mp3",
"@MysticalSoundscapes"
],
"hades":[
"https://www.youtube.com/watch?v=fBR1Qp3njCM",
"hades.mp3",
"@restforthewicked6842"
],
"forest_at_night":[
"https://www.youtube.com/watch?v=3TNK916Pjto",
"forest_at_night.mp3",
"@HawaiiASMRNatureRelaxation"
]
}

@ -3,13 +3,13 @@
"mudrunner": [
"https://www.youtube.com/watch?v=YsfkZoXv4s8",
"mudrunner.mp4",
"joel",
"@joel.gameplays",
"center"
],
"granny-remake": [
"https://www.youtube.com/watch?v=Ynjc1EcRExk",
"granny.mp4",
"Dope Gameplays",
"@DopeGameplays",
"center"
]
}

@ -1,5 +1,6 @@
import os
import ffmpeg
import settings
def compress_video(video_full_path):
@ -8,6 +9,8 @@ def compress_video(video_full_path):
max_audio_bitrate = 256000
output_file_name = video_full_path[:-4] + '_compressed.mp4'
if settings.config["settings"]["debug"]["reuse_video"] and os.path.exists(output_file_name):
return output_file_name
probe = ffmpeg.probe(video_full_path)
# Video duration, in s.

@ -70,12 +70,17 @@ def imagemaker(theme, reddit_obj: dict, txtclr, padding=5, transparent=False, re
texts = process_post(reddit_obj["thread_post"], reel)
id = re.sub(r"[^\w\s-]", "", reddit_obj["thread_id"])
font_size = settings.config["settings"]["text_font_size"]
font_file = settings.config["settings"]["text_font_filename"]
if not os.path.exists(os.path.join("fonts", "Roboto-Bold.ttf")):
font_file = "Roboto-Bold.ttf"
if transparent:
font = ImageFont.truetype(os.path.join("fonts", "Roboto-Bold.ttf"), 100)
tfont = ImageFont.truetype(os.path.join("fonts", "Roboto-Bold.ttf"), 100)
font = ImageFont.truetype(os.path.join("fonts", font_file), font_size)
tfont = ImageFont.truetype(os.path.join("fonts", font_file), font_size)
else:
tfont = ImageFont.truetype(os.path.join("fonts", "Roboto-Bold.ttf"), 100) # for title
font = ImageFont.truetype(os.path.join("fonts", "Roboto-Regular.ttf"), 100)
tfont = ImageFont.truetype(os.path.join("fonts", font_file), font_size) # for title
font = ImageFont.truetype(os.path.join("fonts", font_file), font_size)
size = (1920, 1080)
image = Image.new("RGBA", size, theme)

@ -123,7 +123,7 @@ def download_background_audio(background_config: Tuple[str, str, str]):
new_sound = sound[:]
loops = math.ceil(1800 / sound.duration_seconds)
for _ in range(loops):
for _ in range(loops-1):
new_sound += sound
os.remove(f"./assets/backgrounds/audio/{credit}-{filename}")

@ -4,7 +4,7 @@ import os
import re
from os.path import exists # Needs to be imported specifically
from typing import Final
from typing import Tuple, Any, Dict
from typing import Tuple, Dict
import glob
import ffmpeg
@ -12,8 +12,6 @@ import translators
from PIL import Image
from rich.console import Console
from rich.progress import track
from pydub import AudioSegment
from pydub.playback import play
from utils.cleanup import cleanup
from utils.console import print_step, print_substep

@ -1,4 +1,3 @@
import json
import google.generativeai as genai
from utils import settings
@ -24,8 +23,42 @@ The description should be clear for an AI image generator model to generate it.
The video description:
"""
default_tags = [
"scary stories",
"horror stories",
"true scary stories",
"ghost stories",
"true horror stories",
"scary story",
"scary",
"creepy stories",
"horror story",
"true stories",
"scary true stories",
"true ghost stories",
"paranormal stories",
"disturbing",
"scary video",
"ghost",
"true paranormal stories",
"true scary",
"scary true",
]
description_tags = "#Creepy #Scarystories #paranormal #supernatural #horrorstories #creepystories #truescary_stories #reddit_horror_stories #true_horror_stories\n"
model = genai.GenerativeModel('gemini-pro')
def get_credits(bg_config):
audio_credits = bg_config['audio'][-1]
video_credits = bg_config['video'][-2]
credits_template = f"""
Background audio by - {audio_credits}
Background video by - {video_credits}
"""
return credits_template
def get_data(post):
response = model.generate_content(prompt1 + post)
@ -39,7 +72,7 @@ def get_thumbnail(post):
# print('Thumbnail:', thumbnail_response.prompt_feedback)
return thumbnail_response.text
def get_video_data(post):
def get_video_data(post, bg_config):
data = None
thumbnail = None
print("Generating video title & description...")
@ -53,6 +86,11 @@ def get_video_data(post):
except Exception as e:
print(e)
continue
if data:
data['title'] = "True Scary Stories | " + data['title']
data['description'] = description_tags + data['description'] + get_credits(bg_config)
data['tags'] = data['tags'] + ', ' + ', '.join(default_tags)
return data, thumbnail
if __name__ == '__main__':

Loading…
Cancel
Save