def artist_metadata_run(uri): _ = Fetch.artist_mb_metadata(uri) _ = Fetch.artist_wikipedia_uri(uri) _ = Fetch.artist_dbp_uri(uri, True) _ = Fetch.artist_hometown(uri) _ = Fetch.artist_birthplace(uri) return jsonify({"Message": "done"})
def update_track(track_id: int): form = TrackForm(request.form) if form.validate_on_submit(): _track = Track.query.filter_by(id=track_id).first() _track.name = form.name.data _track.lyrics = form.lyrics.data if form.lyrics.data and form.lyrics.data != "None" else None _track.lyrics_url = form.lyrics_url.data if form.lyrics_url.data and form.lyrics_url.data != "None" else None _track.lyrics_annotated = form.lyrics_annotated.data if form.lyrics_annotated.data and form.lyrics_annotated.data != "None" else None db.session.add(_track) db.session.commit() if not _track.lyrics_annotated: try: _ = Fetch.track_lyrics_annotate(_track.spot_uri) except Exception as e: print(f"Unable to annotate {_track.name}") traceback.print_tb(e.__traceback__) else: print(f"INVALID: {form.errors}") return redirect(url_for('ui.get_track', track_id=track_id))
def track_lyrics_links(uri): return jsonify(Fetch.track_lyric_links(uri))
def track_lyrics_annotations(uri): return Response(Fetch.track_lyrics_annotations(uri))
def artist_birthplace(uri): return jsonify(Fetch.artist_birthplace(uri))
def index(): queries = ["wack", "dope"] counts = [build_lyric_query_stat(q) for q in queries] stats = Fetch.stats() return render_template('ui/index.html', stats=stats, counts=counts)
def artists(): name_filter = request.args.get('filter', default=None) fetched = Fetch.artists(name_filter) if len(fetched) == 1: return redirect(url_for("api.artist", uri=fetched[0]["spot_uri"])) return jsonify(fetched)
def album_release_date(album_uri): force_update = request.args.get('update', default=False) return jsonify(Fetch.album_release_date(album_uri, force_update))
def album_geni(artist_slug, album_slug): return jsonify(Fetch.geni_album_tracks(artist_slug, album_slug))
def stats(): return jsonify(Fetch.stats())
def location(_id): return jsonify(Fetch.location(_id))
def locations(): name_filter = request.args.get('filter', default=None) fetched = Fetch.locations(name_filter) if len(fetched) == 1: return redirect(url_for("api.location", _id=fetched[0]["id"])) return jsonify(fetched)
def genre(_id): return jsonify(Fetch.genre(_id))
def album_metadata_run(uri): _ = Fetch.album_mb_metadata(uri) _ = Fetch.album_wikipedia_uri(uri) _ = Fetch.album_dbp_uri(uri) return jsonify({"Message": "done"})
def artist_wikipedia_url(uri: str): return jsonify(Fetch.artist_wikipedia_uri(uri))
def track_mb(uri): return jsonify(Fetch.track_mb_metadata(uri))
def album(uri): return jsonify(Fetch.album(uri))
def tracks_with_lyrics(): return jsonify(Fetch.tracks_with_lyrics())
def album_tracks_missing_lyrics(uri): return jsonify(Fetch.album_tracks_missing_lyrics(uri))
def tracks_missing_lyrics(): return jsonify(Fetch.tracks_missing_lyrics())
def album_wikipedia_update(album_uri): updated = request.json if updated and "uri" in updated: _album = Fetch.album(album_uri) Persistence.persist_album_wikipedia_uri(_album["id"], updated["uri"]) return redirect(url_for("api.album", uri=album_uri))
def track(uri): return jsonify(Fetch.track(uri))
def artist(uri): return jsonify(Fetch.artist(uri))
def track_lyrics(track_uri): force_update = request.args.get('update', default=False) return jsonify(Fetch.track_lyrics(track_uri, force_update))
def albums_debug(): name_filter = request.args.get('filter', default=None) fetched = Fetch.albums_debug(name_filter) return jsonify(fetched)
def artist_hometown(uri): return jsonify(Fetch.artist_hometown(uri))