Guest User

Untitled

a guest
Jun 25th, 2023
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. # Requirements: yt-dlp, ffmpeg
  2.  
  3. import os
  4. import requests
  5.  
  6. # Prompt for a filename and URL
  7. filename = input("Enter a filename: ")
  8. url = input("Enter a video URL: ")
  9.  
  10. # Fetch the video with yt-dlp
  11. os.system(f"yt-dlp --merge-output-format mkv -o {filename}.mkv {url}")
  12.  
  13. # Extract the audio as an mp3 with ffmpeg
  14. os.system(f"ffmpeg -i {filename}.mkv -vn -acodec libmp3lame -q:a 2 {filename}.mp3")
  15.  
  16. # Convert the video to a webm under 4MB with ffmpeg
  17. os.system(f"ffmpeg -i {filename}.mkv -an -c:v libvpx-vp9 -b:v 0 -crf 30 -fs 4M {filename}.webm")
  18.  
  19. # Upload the mp3 to catbox
  20. files = {"fileToUpload": open(f"{filename}.mp3", "rb")}
  21. data = {"reqtype": "fileupload", "userhash": ""}
  22. response = requests.post("https://catbox.moe/user/api.php", files=files, data=data)
  23. response_code = response.text.split("/")[-1].strip()
  24.  
  25. # Rename the webm file to include the sound link
  26. os.rename(f"{filename}.webm", f"{filename}[sound=files.catbox.moe%2F{response_code}].webm")
  27.  
  28. # Delete extra mkv
  29. os.remove(f"{filename}.mkv")
Add Comment
Please, Sign In to add comment