Add download_audio.py
This commit is contained in:
parent
1e30f61d01
commit
7ea0de1145
26
mumbledj/download_audio.py
Normal file
26
mumbledj/download_audio.py
Normal file
|
@ -0,0 +1,26 @@
|
|||
#---------------------#
|
||||
# MumbleDJ #
|
||||
# By Matthieu Grieger #
|
||||
#---------------------#--------------------------------------------------#
|
||||
# download_audio.py #
|
||||
# Downloads audio (ogg format) from specified YouTube ID. If no ogg file #
|
||||
# exists, it creates an empty file called .video_fail that tells the Lua #
|
||||
# side of the program that the download failed. .video_fail will get #
|
||||
# deleted on the next successful download. #
|
||||
#------------------------------------------------------------------------#
|
||||
|
||||
import pafy
|
||||
from sys import argv
|
||||
from os.path import isfile
|
||||
from os import remove
|
||||
|
||||
url = argv[1]
|
||||
video = pafy.new(url)
|
||||
|
||||
try:
|
||||
video.oggstreams[0].download(filepath = "song.ogg", quiet = True)
|
||||
if isfile(".video_fail"):
|
||||
remove(".video_fail")
|
||||
except:
|
||||
with open(".video_fail", "w+") as f:
|
||||
f.close()
|
Reference in a new issue