def search(self, album, artists=u'', limit=40): if time.time() - self.__lasttime < 1000: time.sleep(1) ret = [] check_matches = False if isempty(artists): artist = None if len(artists) > 1: artist = u'Various Artists' elif artists: if hasattr(artists, 'items'): artist = artists.keys()[0] else: artist = artists[0] if not album and not artist: raise RetrievalError('Album or Artist required.') write_log(u'Searching for %s' % album) if hasattr(artists, "items"): album_id = find_id(chain(*artists.values()), "mbrainz_album_id") if album_id: try: write_log(translate("MusicBrainz", "Found album id %s in tracks. Retrieving") % album_id) return [retrieve_album(album_id)] except RetrievalError, e: msg = translate("MusicBrainz", "<b>Error:</b> While retrieving Album ID %1 (%2)") write_log(msg.arg(album_id).arg(escape(e)))
def search(self, album, artists=u'', limit=40): if time.time() - self.__lasttime < 1000: time.sleep(1) ret = [] check_matches = False if isempty(artists): artist = None if len(artists) > 1: artist = u'Various Artists' elif artists: if hasattr(artists, 'items'): artist = artists.keys()[0] else: artist = artists[0] if not album and not artist: raise RetrievalError('Album or Artist required.') write_log(u'Searching for %s' % album) if hasattr(artists, "items"): album_id = find_id(chain(*artists.values()), "mbrainz_album_id") if album_id: try: write_log( translate("MusicBrainz", "Found album id %s in tracks. Retrieving") % album_id) return [retrieve_album(album_id)] except RetrievalError, e: msg = translate( "MusicBrainz", "<b>Error:</b> While retrieving Album ID %1 (%2)") write_log(msg.arg(album_id).arg(escape(e)))
def search(self, album, artists='', limit=40): if time.time() - self.__lasttime < 1000: time.sleep(1) ret = [] check_matches = False if isempty(artists): artist = None if len(artists) > 1: artist = 'Various Artists' elif artists: if hasattr(artists, 'items'): artist = list(artists.keys())[0] else: artist = artists[0] if not album and not artist: raise RetrievalError('Album or Artist required.') write_log('Searching for %s' % album) if hasattr(artists, "items"): album_id = find_id(chain(*list(artists.values())), "mbrainz_album_id") if album_id: try: write_log( translate("MusicBrainz", "Found album id %s in tracks. Retrieving") % album_id) return [retrieve_album(album_id)] except RetrievalError as e: msg = translate( "MusicBrainz", "<b>Error:</b> While retrieving Album ID %1 (%2)") write_log(msg.arg(album_id).arg(escape(e))) try: xml = urlopen(search_album(album, artist, limit)) except urllib.error.URLError as e: write_log('Error: While retrieving search page %s' % str(e)) raise RetrievalError(str(e)) write_log('Retrieved search results.') self.__lasttime = time.time() return parse_album_search(xml)
def search(self, album, artists): if len(artists) > 1: artist = u'Various Artists' else: artist = [z for z in artists][0] if hasattr(artists, 'values'): write_log( translate("Discogs", 'Checking tracks for Discogs Album ID.')) tracks = [] [tracks.extend(z) for z in artists.values()] album_id = find_id(tracks, R_ID) if not album_id: write_log( translate("Discogs", 'No Discogs ID found in tracks.')) else: write_log( translate("Discogs", 'Found Discogs ID: %s') % album_id) return [self.retrieve(album_id)] return []
def search(self, album, artists): if len(artists) > 1: artist = u'Various Artists' else: artist = [z for z in artists][0] if hasattr(artists, 'values'): write_log( translate("Discogs", 'Checking tracks for Discogs Album ID.')) tracks = [] [tracks.extend(z) for z in artists.values()] album_id = find_id(tracks, R_ID) if not album_id: write_log( translate("Discogs", 'No Discogs ID found in tracks.')) else: write_log( translate("Discogs", 'Found Discogs ID: %s') % album_id) return [self.retrieve(album_id)] return []