Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 45eb06c

Browse files
Merge pull request avinashkranjan#173 from sejalsksagar/youtube_audio
Added YouTube Audio Downloader
2 parents 9288a20 + bfde271 commit 45eb06c

File tree

6 files changed

+69
-0
lines changed

6 files changed

+69
-0
lines changed

‎YouTube Audio Downloader/Folders.PNG

18.5 KB
Loading[フレーム]

‎YouTube Audio Downloader/Output.PNG

17.4 KB
Loading[フレーム]

‎YouTube Audio Downloader/README.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
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)

‎YouTube Audio Downloader/WebmToMp3.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
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()
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
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()
76 Bytes
Binary file not shown.

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /