diff --git a/setup.cfg b/setup.cfg index 680a954..4310999 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = clld-audio-plugin -version = 1.1.1.dev0 +version = 1.2.0 license_file = LICENSE author = Robert Forkel author_email = dlce.rdm@eva.mpg.de diff --git a/src/clld_audio_plugin/util.py b/src/clld_audio_plugin/util.py index 55a0342..3fa2250 100644 --- a/src/clld_audio_plugin/util.py +++ b/src/clld_audio_plugin/util.py @@ -8,7 +8,10 @@ def form2audio(cldf, mimetype='audio/mpeg'): :return: `dict` mapping form ID to audio file. """ res = {} - for r in cldf.iter_rows('media.csv', 'id', 'formReference'): - if r['mimetype'] == mimetype: - res[r['formReference']] = cldf.get_row_url('media.csv', r) + table = 'MediaTable' if 'MediaTable' in cldf else 'media.csv' + with_mediaType = (table, 'mediaType') in cldf + props = ['mediaType'] if with_mediaType else [] + for r in cldf.iter_rows(table, 'id', 'formReference', 'mediaType', *props): + if r['mediaType' if with_mediaType else 'mimetype'] == mimetype: + res[r['formReference']] = cldf.get_row_url(table, r) return res diff --git a/tests/test_misc.py b/tests/test_misc.py index 8c35855..dd28f41 100644 --- a/tests/test_misc.py +++ b/tests/test_misc.py @@ -16,7 +16,7 @@ def test_AudioCol(mocker): def test_form2audio(mocker): - res =form2audio(mocker.Mock( + res = form2audio(mocker.MagicMock( iter_rows=lambda *args: [dict(mimetype='audio/mpeg', formReference='x')], get_row_url=lambda *args: 'http://example.org')) assert res['x'] == 'http://example.org'