-
-
Save amankharwal/da88638e6f9c213b2d1a7a842d55f6c2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I am facing an error. I followed everything precisely and when i enter the url in the 'Enter YouTube video URL' tab it shows 'The syntax of the command is incorrect.' as an error. any solutions?