def r_by_album(cat_attrs, res_tresh, skip=False): log.info('Release: Album\n') log.info('Connecting Discogs\tQuery: {0}'.format(cat_attrs['album'])) cur_method = 'Album' if skip: cat_attrs['comment'] += 'skipped {}, '.format(cur_method) return cat_attrs outcome = d.search(cat_attrs['album'], type='release') log.info('FOUND {0} RESULTS'.format(len(outcome))) counter = 0 for i in itertools.islice(outcome, 0, res_tresh): if config.is_interrupted(): return cat_attrs if len(i.artists) > 1: log.debug('there is more than one artist in current release') counter += 1 result = text_tools.rm_artist_num(i.artists[0].name), i.title cat_attrs, flag = discogs_tools.final_comparison( cat_attrs, result, i.id, cur_method, counter) if flag: break time.sleep(0.5 * ratelimit) discogs_tools.log_summary(cat_attrs, cur_method) time.sleep(ratelimit) return cat_attrs
def r_by_token(cat_attrs, res_tresh, skip=False): log.info('Release: Token\n') token = cat_attrs['artist'] + ' - ' + cat_attrs['album'] log.info('Connecting Discogs\tQuery: {0}'.format(token)) cur_method = 'Token' if skip: cat_attrs['comment'] += 'skipped {}, '.format(cur_method) return cat_attrs outcome = d.search(token, type='release') log.info('FOUND {0} RESULTS'.format(len(outcome))) counter = 0 for i in itertools.islice(outcome, 0, res_tresh): if config.is_interrupted(): return cat_attrs counter += 1 # tran_artist = cat_attrs['artist'].translate(punctuationremover) # tran_album = cat_attrs['album'].translate(punctuationremover) result = text_tools.rm_artist_num(i.artists[0].name), str( i.title).translate(punctuationremover) cat_attrs, flag = discogs_tools.final_comparison( cat_attrs, result, i.id, cur_method, counter) if flag: break time.sleep(ratelimit / 2) discogs_tools.log_summary(cat_attrs, cur_method) time.sleep(ratelimit) return cat_attrs
def m_by_token_cut(cat_attrs, res_tresh, skip=False): log.info('Master: Token Cut\n') log.info('***Connecting Discogs\tQuery: {0}'.format( cat_attrs['album'])) cur_method = 'Token Cuted' if skip: cat_attrs['comment'] += 'skipped {}, '.format(cur_method) return cat_attrs album = text_tools.fm_album_suffixes(cat_attrs['album']) token = cat_attrs['artist'] + ' - ' + album outcome = d.search(token, type='master') log.info('FOUND {0} RESULTS'.format(len(outcome))) counter = 0 for i in itertools.islice(outcome, 0, res_tresh): if config.is_interrupted(): return cat_attrs counter += 1 m_name = i.title.split(' - ') result = text_tools.rm_artist_num(m_name[0]), m_name[1] cat_attrs, flag = discogs_tools.final_comparison( cat_attrs, result, i.id, cur_method, counter) if flag: break discogs_tools.log_summary(cat_attrs, cur_method) time.sleep(ratelimit) return cat_attrs