Add sanitize_searches Option
This commit is contained in:
@@ -72,6 +72,7 @@ class iTunesPlugin(BeetsPlugin):
|
||||
'search_countries': ['US'],
|
||||
'lookup_countries': ['US', 'DE', 'AU', 'GB', 'FR', 'IT', 'JP'],
|
||||
'search_limit': 5,
|
||||
'sanitize_searches': True, # Whether to remove parenthesized and braced text from searches
|
||||
'artwork': False, # Whether to also download artwork from iTunes. Does not work well with fetchart
|
||||
'method': 'lookup', # Valid values: 'search', 'lookup', 'both', 'lookup (search fallback)'
|
||||
})
|
||||
@@ -107,6 +108,10 @@ class iTunesPlugin(BeetsPlugin):
|
||||
def search_limit(self):
|
||||
return self.config['search_limit'].as_number()
|
||||
|
||||
@property
|
||||
def sanitize_searches(self):
|
||||
return self.config['sanitize_searches']
|
||||
|
||||
def scan_track_ids(self, session, task):
|
||||
self._log.debug("Scanning track IDs")
|
||||
for item in task.items:
|
||||
@@ -171,11 +176,18 @@ class iTunesPlugin(BeetsPlugin):
|
||||
"""Searches for matching albums on iTunes.
|
||||
"""
|
||||
|
||||
if self.sanitize_searches:
|
||||
pattern = re.compile('(\s*(\(.*\)|\[.*\]|\{.*\}))*$')
|
||||
album = pattern.sub('', album)
|
||||
artist = pattern.sub('', artist)
|
||||
|
||||
if va_likely:
|
||||
query = album
|
||||
else:
|
||||
query = '%s %s' % (artist, album)
|
||||
|
||||
print("Searching", query)
|
||||
|
||||
albums = []
|
||||
for country in self.search_countries:
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user