def test_search(self): self.assertDictEqual( spotify.search("Random name!", 'album'), dict( url= "https://api.spotify.com/v1/search?q=Random%20name%21&type=album&limit=20&offset=0" ))
def spotify(): release_group_id = request.args.get('release_group_id') if not release_group_id: return redirect(url_for('frontend.index')) release_group = musicbrainz.get_release_group_by_id(release_group_id) if not release_group: flash( gettext("Only existing release groups can be mapped to Spotify!"), 'error') return redirect(url_for('search.index')) page = int(request.args.get('page', default=1)) if page < 1: return redirect(url_for('.spotify')) limit = 16 offset = (page - 1) * limit # Removing punctuation from the string punctuation_map = dict((ord(char), None) for char in string.punctuation) query = unicode(release_group['title']).translate(punctuation_map) # Searching... response = spotify_api.search(query, 'album', limit, offset).get('albums') return render_template('mapping/spotify.html', release_group=release_group, search_results=response.get('items'), page=page, limit=limit, count=response.get('total'))
def spotify(): release_group_id = request.args.get('release_group_id') if not release_group_id: return redirect(url_for('frontend.index')) release_group = musicbrainz.get_release_group_by_id(release_group_id) if not release_group: flash(gettext("Only existing release groups can be mapped to Spotify!"), 'error') return redirect(url_for('search.index')) page = int(request.args.get('page', default=1)) if page < 1: return redirect(url_for('.spotify')) limit = 16 offset = (page - 1) * limit # Removing punctuation from the string punctuation_map = dict((ord(char), None) for char in string.punctuation) query = unicode(release_group['title']).translate(punctuation_map) # Searching... response = spotify_api.search(query, 'album', limit, offset).get('albums') return render_template('mapping/spotify.html', release_group=release_group, search_results=response.get('items'), page=page, limit=limit, count=response.get('total'))
def test_search(self): self.assertDictEqual( spotify.search("Random name!", 'album'), dict(url="https://api.spotify.com/v1/search?q=Random%20name%21&type=album&limit=20&offset=0"))