import requests, random, os, textwrap from moviepy.editor import * from PIL import Image, ImageDraw, ImageFont # ================================================== # SETTINGS # ================================================== PIXABAY_API_KEY = "53652449-d70bfdbd77718706d772d8280" VIDEO_TYPE = "short" # short or long SHORT_DURATION = 60 LONG_DURATION = 1800 OUTPUT_VIDEO = "nature_relaxing_video.mp4" OUTPUT_THUMBNAIL = "thumbnail.jpg" # ================================================== # AUTO SEO DATA # ================================================== SEO_TITLES = [ "Relaxing Nature Music for Stress Relief", "Peaceful Nature Sounds for Deep Sleep", "Calming Nature Music for Meditation", "Nature Relaxing Music – No Copyright", "Mind Relaxing Nature Music Video" ] SEO_DESCRIPTIONS = [ "Enjoy relaxing nature music with peaceful visuals. Perfect for stress relief, sleep, meditation and relaxation.", "This nature relaxing music video is copyright free and safe for YouTube monetization." ] SEO_TAGS = [ "relaxing music","nature music","nature sounds", "deep sleep music","meditation music", "stress relief music","no copyright music" ] # ================================================== # FOLDERS # ================================================== os.makedirs("music", exist_ok=True) os.makedirs("images", exist_ok=True) # ================================================== # DOWNLOAD MUSIC # ================================================== def download_music(): url = f"https://pixabay.com/api/music/?key={PIXABAY_API_KEY}&q=nature&per_page=20" data = requests.get(url).json() song = random.choice(data["hits"]) music_url = song["audio"] path = "music/music.mp3" open(path, "wb").write(requests.get(music_url).content) return path # ================================================== # DOWNLOAD IMAGE # ================================================== def download_image(): url = f"https://pixabay.com/api/?key={PIXABAY_API_KEY}&q=nature&image_type=photo&orientation=horizontal&per_page=20" data = requests.get(url).json() img = random.choice(data["hits"]) img_url = img["largeImageURL"] path = "images/bg.jpg" open(path, "wb").write(requests.get(img_url).content) return path # ================================================== # CREATE VIDEO # ================================================== def create_video(image, music): duration = SHORT_DURATION if VIDEO_TYPE == "short" else LONG_DURATION clip = ImageClip(image).set_duration(duration).resize((1280,720)) audio = AudioFileClip(music).audio_loop(duration=duration) final = clip.set_audio(audio) final.write_videofile(OUTPUT_VIDEO, fps=24) # ================================================== # CREATE THUMBNAIL # ================================================== def create_thumbnail(image): img = Image.open(image).resize((1280,720)) draw = ImageDraw.Draw(img) title = random.choice(SEO_TITLES) wrapped = textwrap.fill(title, 28) try: font = ImageFont.truetype("DejaVuSans-Bold.ttf", 70) except: font = ImageFont.load_default() draw.rectangle((0,520,1280,720), fill=(0,0,0,180)) draw.text((50,550), wrapped, fill="white", font=font) img.save(OUTPUT_THUMBNAIL) # ================================================== # SAVE SEO DATA # ================================================== def save_seo(): with open("seo.txt", "w", encoding="utf-8") as f: f.write("TITLE:\n" + random.choice(SEO_TITLES) + "\n\n") f.write("DESCRIPTION:\n" + random.choice(SEO_DESCRIPTIONS) + "\n\n") f.write("TAGS:\n" + ", ".join(SEO_TAGS)) # ================================================== # RUN AUTOMATED TOOL # ================================================== print("🎵 Music download ho raha hai...") music = download_music() print("🖼 Image download ho rahi hai...") image = download_image() print("🎬 Video create ho rahi hai...") create_video(image, music) print("🖼 Thumbnail create ho rahi hai...") create_thumbnail(image) print("🧠 SEO data generate ho raha hai...") save_seo() print("\n✅ TOOL SUCCESSFULLY RUN HO GAYA") print("📹 Video:", OUTPUT_VIDEO) print("🖼 Thumbnail:", OUTPUT_THUMBNAIL) print("📄 SEO File: seo.txt")