This repository has been archived by the owner on Sep 7, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ytmp3.py
65 lines (44 loc) · 1.75 KB
/
ytmp3.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
from __future__ import unicode_literals
import youtube_dl
from cfonts import render
import time
import sys
import os
#banner artwork
banner = render("YT-MP3", colors=['green', 'yellow'], align='center')
print(banner)
print("################################################")
print("\n")
print("**************** Author = Sumit ****************")
print("\n")
print("################################################")
#main code
url=input("\nPaste YouTube video link here & press enter ==> ")
print("loading your content:")
#animation = ["10%", "20%", "30%", "40%", "50%", "60%", "70%", "80%", "90%", "100%"]
animation = ["[■□□□□□□□□□]","[■■□□□□□□□□]", "[■■■□□□□□□□]", "[■■■■□□□□□□]", "[■■■■■□□□□□]", "[■■■■■■□□□□]", "[■■■■■■■□□□]", "[■■■■■■■■□□]", "[■■■■■■■■■□]", "[■■■■■■■■■■]"]
for i in range(len(animation)):
time.sleep(0.3)
sys.stdout.write("\r" + animation[i % len(animation)])
sys.stdout.flush()
print("\n")
#https://youtu.be/DiYOFlkxat0
#apt-get install ffmpeg
ydl_opts = {
'format': 'bestaudio/best',
'postprocessors': [{
'key': 'FFmpegExtractAudio',
'preferredcodec': 'mp3',
'preferredquality': '192',
}],
}
with youtube_dl.YoutubeDL(ydl_opts) as ydl:
ydl.download([url])
print("\n\nYour mp3 file downloaded successfully!! Thanks for using ...")
def restart_program():
python = sys.executable
os.execl(python, python, * sys.argv)
if __name__ == "__main__":
answer = input("\n [-] Do you want to start again ?(y/n) ")
if answer.lower().strip() in "y".split():
restart_program()