File tree Expand file tree Collapse file tree 6 files changed +69
-0
lines changed Expand file tree Collapse file tree 6 files changed +69
-0
lines changed Original file line number Diff line number Diff line change
1
+ # How To Download Audio Of A YouTube Video?
2
+
3
+ 1 . Setup python and pip if you haven’t already
4
+
5
+ 2 . Install virtualenv
6
+
7
+ ` pip install virtualenv `
8
+
9
+ 3 . Create Virtual environment
10
+
11
+ ` virtualenv venv `
12
+
13
+ 4 . Activate virtual environment
14
+
15
+ - ` source venv/bin/activate ` (Linux)
16
+ - ` venv\Scripts\activate ` (Windows)
17
+
18
+ 5 . Install requirements
19
+
20
+ ` pip install -r requirements.txt `
21
+
22
+ 6 . Specify url of the YouTube video whoose audio you want (in YouTubeAudioDownloader.py)
23
+
24
+ ex: ` url = "https://www.youtube.com/watch?v=ZSXN_dpG5jk" `
25
+
26
+ 7 . Run YouTubeAudioDownloader.py
27
+
28
+ ![ YouTubeAudioDownloader.py Output] ( https://github.com/sejalsksagar/Amazing-Python-Scripts/blob/youtube_audio/YouTube%20Audio%20Downloader/Output.PNG )
29
+
30
+ You will find file of .webm format downloaded in the same folder.
31
+
32
+ ## How To convert .webm to .mp3 format?
33
+
34
+ 1 . Install moviepy in the same environment
35
+
36
+ ` pip install moviepy==1.0.3 `
37
+
38
+ 2 . Specify path of .webm file (in WebmToMp3.py)
39
+
40
+ ex: ` clip = mp.AudioFileClip("C:/Users/sejal/Desktop/YouTube Audio Downloader/Rainbow.webm").subclip() `
41
+
42
+ 3 . Specify path where .mp3 file should be saved (in WebmToMp3.py)
43
+
44
+ ex: ` clip.write_audiofile("C:/Users/sejal/Desktop/YouTube Audio Downloader/rainbow.mp3") `
45
+
46
+ 4 . Run WebmToMp3.py
47
+
48
+ ![ YouTube Audio Downloader Folder] ( https://github.com/sejalsksagar/Amazing-Python-Scripts/blob/youtube_audio/YouTube%20Audio%20Downloader/Folders.PNG )
Original file line number Diff line number Diff line change
1
+ import moviepy .editor as mp
2
+
3
+ clip = mp .AudioFileClip ("insert_path_to_webm_file" ).subclip ()
4
+ clip .write_audiofile ("insert_path_to_save_mp3_file" )
5
+ clip .close ()
Original file line number Diff line number Diff line change
1
+ import pafy
2
+
3
+ url = "insert_url_to_youtube_video_here"
4
+
5
+ video = pafy .new (url )
6
+
7
+ print ("_________VIDEO__DETAILS_________" )
8
+ print ("Title:" , video .title )
9
+ print ("Rating:" , video .rating )
10
+ print ("View Count:" , video .viewcount )
11
+ print ("Author:" , video .author )
12
+ print ("Length:" , video .length )
13
+
14
+ #Selects the audio stream with the highest bitrate.
15
+ bestaudio = video .getbestaudio ()
16
+ bestaudio .download ()
You can’t perform that action at this time.
0 commit comments