Deduplicate media extension filter with existing list of media extensions

This commit is contained in:
Michal Pokorný (Rai) 2019-12-22 13:59:24 +01:00
parent af4d4af55d
commit 2ae342592c

View File

@ -3,6 +3,7 @@
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
import base64
import html
import itertools
import json
import mimetypes
import re
@ -553,10 +554,10 @@ to a cloze type first, via Edit>Change Note Type."""))
######################################################################
def onAddMedia(self):
key = (_("Media") +
" (*.jpg *.png *.gif *.tiff *.svg *.tif *.jpeg "+
"*.mp3 *.ogg *.wav *.avi *.ogv *.mpg *.mpeg *.mov *.mp4 " +
"*.mkv *.ogx *.ogv *.oga *.flv *.swf *.flac *.webp *.m4a)")
extension_filter = ' '.join(
'*.' + extension
for extension in sorted(itertools.chain(pics, audio)))
key = (_("Media") + " (" + extension_filter + ")")
def accept(file):
self.addMedia(file, canDelete=True)
file = getFile(self.widget, _("Add Media"), accept, key, key="media")