Ignore non-audio/video files
This commit is contained in:
parent
f45aa6c712
commit
adfdb6f06c
@ -2,3 +2,4 @@ opuslib==1.1.0
|
||||
protobuf==3.1.0
|
||||
flask
|
||||
youtube-dl
|
||||
python-magic
|
||||
|
7
util.py
7
util.py
@ -2,6 +2,7 @@
|
||||
|
||||
import configparser
|
||||
import hashlib
|
||||
import magic
|
||||
import os
|
||||
import variables as var
|
||||
import zipfile
|
||||
@ -20,7 +21,11 @@ def get_recursive_filelist_sorted(path):
|
||||
for file in files:
|
||||
if file in __CONFIG.get('bot', 'ignored_files'):
|
||||
continue
|
||||
filelist.append(relroot + file)
|
||||
|
||||
fullpath = os.path.join(path, relroot, file)
|
||||
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)
|
||||
|
||||
filelist.sort()
|
||||
return filelist
|
||||
|
Loading…
x
Reference in New Issue
Block a user