Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Requirements: yt-dlp, ffmpeg
- import os
- import requests
- # Prompt for a filename and URL
- filename = input("Enter a filename: ")
- url = input("Enter a video URL: ")
- # Fetch the video with yt-dlp
- os.system(f"yt-dlp --merge-output-format mkv -o {filename}.mkv {url}")
- # Extract the audio as an mp3 with ffmpeg
- os.system(f"ffmpeg -i {filename}.mkv -vn -acodec libmp3lame -q:a 2 {filename}.mp3")
- # Convert the video to a webm under 4MB with ffmpeg
- os.system(f"ffmpeg -i {filename}.mkv -an -c:v libvpx-vp9 -b:v 0 -crf 30 -fs 4M {filename}.webm")
- # Upload the mp3 to catbox
- files = {"fileToUpload": open(f"{filename}.mp3", "rb")}
- data = {"reqtype": "fileupload", "userhash": ""}
- response = requests.post("https://catbox.moe/user/api.php", files=files, data=data)
- response_code = response.text.split("/")[-1].strip()
- # Rename the webm file to include the sound link
- os.rename(f"{filename}.webm", f"{filename}[sound=files.catbox.moe%2F{response_code}].webm")
- # Delete extra mkv
- os.remove(f"{filename}.mkv")
Add Comment
Please, Sign In to add comment