Commit e78a76b1 authored by Quentin Aristote's avatar Quentin Aristote
Browse files

added option to ignore some tracks

parent 41683156
......@@ -160,21 +160,19 @@ def getSounds(directory = '.',
validated = False, not_validated = False,
sort_by = None,
since = None,
overwrite = False) :
overwrite = False,
to_ignore = set()) :
"""Download all the sounds corresponding to specific filters.
:param directory: the path to save the recordings to.
:param soundscape: Whether to get ambient sounds. If ambiant and species are False,
get both types of sounds. Defaults to False.
:param species: Whether to get species sounds. If ambiant and species are False,
get both types of sounds. Defaults to False.
:param validated: Whether to get validated sounds. If validated and not_validated are False,
get both types of sounds. Defaults to False.
:param sort_by: The (decreasing) order in which the sounds should be downloaded.
Can be 'date', 'number' or 'title'. If None (default), they are ordered by date.
:param since: How recent the downloaded sounds should be. Can be 'day', 'week', 'month' or
'year'. If None (default), all the sounds are downloaded.
:param overwrite: whether to download each sound again."""
Args :
directory (str, optional) : the path to save the recordings to.
soundscape (bool, optional) : whether to get ambient sounds. If ambiant and species are False, get both types of sounds. Defaults to False.
species (bool, optional) : whether to get species sounds. If ambiant and species are False, get both types of sounds. Defaults to False.
validated (bool, optional) : whether to get validated sounds. If validated and not_validated are False, get both types of sounds. Defaults to False.
sort_by (str, optional) : the (decreasing) order in which the sounds should be downloaded. Can be 'date', 'number' or 'title'. If None (default), they are ordered by date.
since (str, optional) : how recent the downloaded sounds should be. Can be 'day', 'week', 'month' or 'year'. If None (default), all the sounds are downloaded.
overwrite (bool, optional) : whether to download every sound again.
to_ignore (set, optional) : the set of titles of recordings that should not be downloaded."""
base_url = getBaseURL(soundscape = soundscape, species = species,
validated = validated, not_validated = not_validated,
......@@ -187,7 +185,7 @@ def getSounds(directory = '.',
filename = title + '.mp3'
path = os.path.join(directory, filename)
print('Downloading {filename} ...'.format(filename = filename))
if not(os.path.isfile(path)) or overwrite :
if not(os.path.isfile(path)) or overwrite or not(title in to_ignore) :
sound_html = getSoundHTML(title)
try :
_ = downloadSound(sound_html, path = path)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment