Skip to content

Commit

Permalink
feat: do not use the same image overlay everytime
Browse files Browse the repository at this point in the history
  • Loading branch information
engineervix committed Feb 16, 2024
1 parent fbfe3db commit 4f66c53
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion social.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,17 @@ def get_random_video(path):
return None


def get_random_image(path):
"""Get a random image from a directory"""
image_files = [
f for f in os.listdir(path) if os.path.isfile(os.path.join(path, f)) and f.endswith((".jpg", ".png"))
]
if image_files:
return os.path.join(path, random.choice(image_files))
else:
return None


def create_video(image_overlay, logo, podcast_mp3, video_loop):
# Load the video clip
video_clip = VideoFileClip(video_loop)
Expand Down Expand Up @@ -373,7 +384,7 @@ def main(args=None):
try:
# First, we create a video and upload it
video = create_video(
image_overlay=f"{ASSETS_DIR}/image-overlay.jpg",
image_overlay=get_random_image(os.path.join(f"{ASSETS_DIR}/images/")),
logo=f"{ASSETS_DIR}/logo.png",
podcast_mp3=f"{DATA_DIR}/{today_iso_fmt}_podcast_dist.mp3",
video_loop=get_random_video(os.path.join(f"{DATA_DIR}/videos/")),
Expand Down

0 comments on commit 4f66c53

Please sign in to comment.