Add sanitize_searches Option
This commit is contained in:
@@ -72,6 +72,7 @@ class iTunesPlugin(BeetsPlugin):
|
|||||||
'search_countries': ['US'],
|
'search_countries': ['US'],
|
||||||
'lookup_countries': ['US', 'DE', 'AU', 'GB', 'FR', 'IT', 'JP'],
|
'lookup_countries': ['US', 'DE', 'AU', 'GB', 'FR', 'IT', 'JP'],
|
||||||
'search_limit': 5,
|
'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
|
'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)'
|
'method': 'lookup', # Valid values: 'search', 'lookup', 'both', 'lookup (search fallback)'
|
||||||
})
|
})
|
||||||
@@ -106,6 +107,10 @@ class iTunesPlugin(BeetsPlugin):
|
|||||||
@property
|
@property
|
||||||
def search_limit(self):
|
def search_limit(self):
|
||||||
return self.config['search_limit'].as_number()
|
return self.config['search_limit'].as_number()
|
||||||
|
|
||||||
|
@property
|
||||||
|
def sanitize_searches(self):
|
||||||
|
return self.config['sanitize_searches']
|
||||||
|
|
||||||
def scan_track_ids(self, session, task):
|
def scan_track_ids(self, session, task):
|
||||||
self._log.debug("Scanning track IDs")
|
self._log.debug("Scanning track IDs")
|
||||||
@@ -170,12 +175,19 @@ class iTunesPlugin(BeetsPlugin):
|
|||||||
def search_albums(self, artist, album, va_likely):
|
def search_albums(self, artist, album, va_likely):
|
||||||
"""Searches for matching albums on iTunes.
|
"""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:
|
if va_likely:
|
||||||
query = album
|
query = album
|
||||||
else:
|
else:
|
||||||
query = '%s %s' % (artist, album)
|
query = '%s %s' % (artist, album)
|
||||||
|
|
||||||
|
print("Searching", query)
|
||||||
|
|
||||||
albums = []
|
albums = []
|
||||||
for country in self.search_countries:
|
for country in self.search_countries:
|
||||||
try:
|
try:
|
||||||
|
|||||||
Reference in New Issue
Block a user