Update itunes plugin
This commit is contained in:
@@ -94,8 +94,7 @@ class SearchAPIPlugin(BeetsPlugin):
|
||||
|
||||
def scan_track_ids(self, session, task):
|
||||
self._log.debug("Scanning track IDs")
|
||||
items = task.items if task.is_album else [ task.item ]
|
||||
for item in items:
|
||||
for item in task.items:
|
||||
with open(item.path, 'rb') as file:
|
||||
data = file.read(1000) # Song ID always seems to be around 600-700 bytes in
|
||||
location = data.find(b'song')
|
||||
@@ -110,6 +109,7 @@ class SearchAPIPlugin(BeetsPlugin):
|
||||
"""Returns a list of AlbumInfo objects for iTunes search results
|
||||
matching an album and artist.
|
||||
"""
|
||||
try:
|
||||
candidates = []
|
||||
# Lookup the track ids assigned by iTunes Match
|
||||
if self.method in ['lookup', 'lookup (search fallback)', 'both']:
|
||||
@@ -123,17 +123,17 @@ class SearchAPIPlugin(BeetsPlugin):
|
||||
if self.method in ['search', 'both'] or (self.method == 'lookup (search fallback)' and len(candidates) == 0):
|
||||
candidates += self.search_albums(artist, album, va_likely)
|
||||
return candidates
|
||||
except ConnectionError:
|
||||
self._log.debug(u'Cannot search iTunes (no network connection)')
|
||||
return []
|
||||
|
||||
def lookup_albums(self, items):
|
||||
ids = [ str(_track_ids[item]) for item in items if item in _track_ids ]
|
||||
def remove_found_tracks(album):
|
||||
for track in album.get_tracks():
|
||||
try:
|
||||
if track.track_id in ids:
|
||||
ids.remove(track.track_id)
|
||||
except ValueError:
|
||||
pass
|
||||
albums = []
|
||||
try:
|
||||
for country in self.lookup_countries:
|
||||
self._log.debug("Searching iTunes Store: {0}", country)
|
||||
try:
|
||||
@@ -148,9 +148,6 @@ class SearchAPIPlugin(BeetsPlugin):
|
||||
break
|
||||
except LookupError:
|
||||
pass
|
||||
except ConnectionError:
|
||||
self._log.debug(u'Cannot search iTunes (no network connection)')
|
||||
return []
|
||||
return albums
|
||||
|
||||
def search_albums(self, artist, album, va_likely):
|
||||
@@ -167,9 +164,6 @@ class SearchAPIPlugin(BeetsPlugin):
|
||||
try:
|
||||
results = itunespy.search_album(query, country=country, limit=self.search_limit)
|
||||
albums += [self.make_album_info(result) for result in results]
|
||||
except ConnectionError:
|
||||
self._log.debug(u'Cannot search iTunes (no network connection)')
|
||||
return []
|
||||
except LookupError:
|
||||
self._log.debug(u'Search for {0} did return no results', query)
|
||||
return []
|
||||
|
||||
Reference in New Issue
Block a user