Ignore non-audio/video files

This commit is contained in:
Fabian Würfl 2018-05-21 12:47:25 +02:00
parent f45aa6c712
commit adfdb6f06c
2 changed files with 7 additions and 1 deletions

View File

@ -2,3 +2,4 @@ opuslib==1.1.0
protobuf==3.1.0
flask
youtube-dl
python-magic

View File

@ -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