Skip to content

Commit cf8c900

Browse files
authored
Merge pull request #20 from ak-create/main
Project-41-Video_to_audio_converter
2 parents 85b33ff + 39f07ce commit cf8c900

File tree

1 file changed

+24
-0
lines changed
  • Project-41-Video_to_audio_converter

1 file changed

+24
-0
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
from pytube import YouTube
2+
import pytube
3+
import os
4+
5+
def main():
6+
video_url = input('Enter YouTube video URL: ')
7+
8+
if os.name == 'nt':
9+
path = os.getcwd() + '\\'
10+
else:
11+
path = os.getcwd() + '/'
12+
13+
name = pytube.extract.video_id(video_url)
14+
YouTube(video_url).streams.filter(only_audio=True).first().download(filename=name)
15+
location = path + name + '.mp4'
16+
renametomp3 = path + name + '.mp3'
17+
18+
if os.name == 'nt':
19+
os.system('ren {0} {1}'. format(location, renametomp3))
20+
else:
21+
os.system('mv {0} {1}'. format(location, renametomp3))
22+
23+
if __name__ == '__main__':
24+
main()

0 commit comments

Comments
 (0)