Fixed a crash during audio download/encode process

This commit is contained in:
Matthieu Grieger 2014-10-18 17:03:02 -07:00
parent d6858aca3d
commit 1c64bb07a0
4 changed files with 18 additions and 9 deletions

View file

@ -1,6 +1,9 @@
MumbleDJ Changelog
==================
### October 18, 2014
* Fixed a crash when an error occurs during the audio downloading & encoding process.
### October 13, 2014
* Added `SETUP.md` which contains a guide on how to configure MumbleDJ and install its dependencies.
* Deleted song_queue.lua and moved all contents to mumbledj.lua. In the end this will make the script simpler.

View file

@ -127,7 +127,7 @@ config.NO_PERMISSION_MSG = "You do not have permission to execute that command."
config.CHANNEL_DOES_NOT_EXIST_MSG = "The channel you specified does not exist."
-- Message shown to users when they attempt to add an invalid URL to the queue.
config.INVALID_URL_MSG = "The URL you submitted does not match the required format. Please submit a valid YouTube URL."
config.INVALID_URL_MSG = "The URL you submitted does not match the required format. Either you did not provide a YouTube URL, or an error occurred during the downloading & encoding process."
-- Message shown to users when they attempt to use the stop command when no music is playing.
config.NO_MUSIC_PLAYING_MSG = "There is no music playing at the moment."

View file

@ -29,11 +29,17 @@ except:
while isfile('song.ogg.temp'):
sleep(1)
system('ffmpeg -i song.ogg -codec:a libvorbis -ar 48000 -ac 1 -loglevel quiet -vol ' + str(volume) + ' song-converted.ogg -y')
while not isfile('song-converted.ogg') and not isfile(".video_fail"):
sleep(1)
if isfile('song.ogg'):
system('ffmpeg -i song.ogg -codec:a libvorbis -ar 48000 -ac 1 -loglevel quiet -vol ' + str(volume) + ' song-converted.ogg -y')
else:
with open('.video_fail', 'w+') as f:
f.close()
remove('song.ogg')
if not isfile('.video_fail'):
while not isfile('song-converted.ogg'):
sleep(1)
if isfile('song.ogg'):
remove('song.ogg')

View file

@ -292,10 +292,10 @@ end
-- Downloads/encodes the audio file and then begins to play it.
function start_song(info)
os.execute("python download_audio.py " .. info.id .. " " .. config.VOLUME)
while not file_exists("song-converted.ogg") do
os.execute("sleep " .. tonumber(2))
end
if not file_exists(".video_fail") then
while not file_exists("song-converted.ogg") do
os.execute("sleep " .. tonumber(2))
end
if piepan.Audio:isPlaying() then
piepan.Audio:stop()
end