check read access

the bot crash if a file don't have read access
This commit is contained in:
azlux 2018-06-06 00:20:11 +02:00
parent 558d1e5bd3
commit bd532e5c22
2 changed files with 11 additions and 4 deletions

View File

@ -282,7 +282,7 @@ class MumbleBot:
else:
ffmpeg_debug = "warning"
command = ["/usr/bin/ffmpeg", '-v', ffmpeg_debug, '-nostdin', '-i', path, '-ac', '1', '-f', 's16le', '-ar', '48000', '-']
command = ["ffmpeg", '-v', ffmpeg_debug, '-nostdin', '-i', path, '-ac', '1', '-f', 's16le', '-ar', '48000', '-']
self.thread = sp.Popen(command, stdout=sp.PIPE, bufsize=480)
var.current_music[2] = title
var.current_music[3] = path

View File

@ -6,6 +6,7 @@ import os
import variables as var
import zipfile
def get_recursive_filelist_sorted(path):
filelist = []
for root, dirs, files in os.walk(path):
@ -19,6 +20,10 @@ def get_recursive_filelist_sorted(path):
continue
fullpath = os.path.join(path, relroot, file)
if not os.access(fullpath, os.R_OK):
print("coucou")
continue
mime = magic.from_file(fullpath, mime=True)
if 'audio' in mime or 'audio' in magic.from_file(fullpath).lower() or 'video' in mime:
filelist.append(relroot + file)
@ -26,6 +31,7 @@ def get_recursive_filelist_sorted(path):
filelist.sort()
return filelist
# - zips all files of the given zippath (must be a directory)
# - returns the absolute path of the created zip file
# - zip file will be in the applications tmp folder (according to configuration)
@ -56,6 +62,7 @@ def zipdir(zippath, zipname_prefix=None):
zipf.close()
return zipname
class Dir(object):
def __init__(self, path):
self.name = os.path.basename(path.strip('/'))