diff --git a/CHANGELOG.md b/CHANGELOG.md index 4dff197..11832b1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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. diff --git a/mumbledj/config.lua b/mumbledj/config.lua index 4929b68..36439cf 100644 --- a/mumbledj/config.lua +++ b/mumbledj/config.lua @@ -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." diff --git a/mumbledj/download_audio.py b/mumbledj/download_audio.py index 06c92ce..7f4406c 100644 --- a/mumbledj/download_audio.py +++ b/mumbledj/download_audio.py @@ -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') diff --git a/mumbledj/mumbledj.lua b/mumbledj/mumbledj.lua index b74cd8f..3bcae85 100644 --- a/mumbledj/mumbledj.lua +++ b/mumbledj/mumbledj.lua @@ -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