check read access
the bot crash if a file don't have read access
This commit is contained in:
parent
558d1e5bd3
commit
bd532e5c22
@ -282,7 +282,7 @@ class MumbleBot:
|
|||||||
else:
|
else:
|
||||||
ffmpeg_debug = "warning"
|
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)
|
self.thread = sp.Popen(command, stdout=sp.PIPE, bufsize=480)
|
||||||
var.current_music[2] = title
|
var.current_music[2] = title
|
||||||
var.current_music[3] = path
|
var.current_music[3] = path
|
||||||
|
7
util.py
7
util.py
@ -6,6 +6,7 @@ import os
|
|||||||
import variables as var
|
import variables as var
|
||||||
import zipfile
|
import zipfile
|
||||||
|
|
||||||
|
|
||||||
def get_recursive_filelist_sorted(path):
|
def get_recursive_filelist_sorted(path):
|
||||||
filelist = []
|
filelist = []
|
||||||
for root, dirs, files in os.walk(path):
|
for root, dirs, files in os.walk(path):
|
||||||
@ -19,6 +20,10 @@ def get_recursive_filelist_sorted(path):
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
fullpath = os.path.join(path, relroot, file)
|
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)
|
mime = magic.from_file(fullpath, mime=True)
|
||||||
if 'audio' in mime or 'audio' in magic.from_file(fullpath).lower() or 'video' in mime:
|
if 'audio' in mime or 'audio' in magic.from_file(fullpath).lower() or 'video' in mime:
|
||||||
filelist.append(relroot + file)
|
filelist.append(relroot + file)
|
||||||
@ -26,6 +31,7 @@ def get_recursive_filelist_sorted(path):
|
|||||||
filelist.sort()
|
filelist.sort()
|
||||||
return filelist
|
return filelist
|
||||||
|
|
||||||
|
|
||||||
# - zips all files of the given zippath (must be a directory)
|
# - zips all files of the given zippath (must be a directory)
|
||||||
# - returns the absolute path of the created zip file
|
# - returns the absolute path of the created zip file
|
||||||
# - zip file will be in the applications tmp folder (according to configuration)
|
# - zip file will be in the applications tmp folder (according to configuration)
|
||||||
@ -56,6 +62,7 @@ def zipdir(zippath, zipname_prefix=None):
|
|||||||
zipf.close()
|
zipf.close()
|
||||||
return zipname
|
return zipname
|
||||||
|
|
||||||
|
|
||||||
class Dir(object):
|
class Dir(object):
|
||||||
def __init__(self, path):
|
def __init__(self, path):
|
||||||
self.name = os.path.basename(path.strip('/'))
|
self.name = os.path.basename(path.strip('/'))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user