video to audio converter

This commit is contained in:
Dauragtiwari 2022-10-09 18:13:53 +05:30
parent 309a904dd3
commit fd7789455c
3 changed files with 32 additions and 0 deletions

View File

@ -0,0 +1,5 @@
Its basically use to convert any youtube video to audio form!
Just you have to paste the url in video_url!!
Thankx

View File

@ -0,0 +1,3 @@
import YouTube
import pytube
import os

View File

@ -0,0 +1,24 @@
from pytube import YouTube
import pytube
import os
def main():
video_url = input('Enter YouTube video URL: ')
if os.name == 'nt':
path = os.getcwd() + '\\'
else:
path = os.getcwd() + '/'
name = pytube.extract.video_id(video_url)
YouTube(video_url).streams.filter(only_audio=True).first().download(filename=name)
location = path + name + '.mp4'
renametomp3 = path + name + '.mp3'
if os.name == 'nt':
os.system('ren {0} {1}'. format(location, renametomp3))
else:
os.system('mv {0} {1}'. format(location, renametomp3))
if __name__ == '__main__':
main()