+ # Remove external enclosing parentheses in user defined MPD filter, for
+ # instance when there is more than one expression:
+ # ((genre == 'rock' ) AND (date =~ '198.'))
+ # Even though it's a valid MPD filter, forge_filter will enclose it
+ # properly. We do not want to through a syntax error at users since it's a
+ # valid MPD filter, hence trying to transparently reformat the filter
+ if cfg_filter.startswith('((') and cfg_filter.endswith('))'):
+ logger.debug('Drop external enclosing parentheses in user filter: %s',
+ cfg_filter[1:-1])
+ cfg['filter'] = cfg_filter[1:-1]
+ cfg_filter = cfg['filter']