def persist_artist(artist_tuple: ArtistTuple) -> None: try: Persist.persist_spot_artist_tuple(artist_tuple) except Exception as e: print(f"Unable to persist artist {artist_tuple.id}") traceback.print_tb(e.__traceback__) raise
def persist_album(album_tuple: AlbumTuple) -> None: try: Persist.persist_spot_album_tuple(album_tuple) except Exception as e: print(f"Unable to persist album {album_tuple}") traceback.print_tb(e.__traceback__) raise
def persist_location(location_tuple: LocationTuple) -> None: try: Persist.persist_location_tuple(location_tuple) except Exception as e: print(f"Unable to persist location {location_tuple}") traceback.print_tb(e.__traceback__) raise
def persist_track(track_tuple: TrackTuple) -> None: try: Persist.persist_spot_track_tuple(track_tuple) except Exception as e: print(f"Unable to persist track {track_tuple}") traceback.print_tb(e.__traceback__) raise
def persist_mb_metadata(model: db.Model, _id: int, _tuple) -> None: _entity = model.query.filter_by(id=_id).first() _updates = {model.mb_id: _tuple.id, model.mb_obj: _tuple._asdict()} try: Persist.update(model, _entity.id, _updates) except Exception as e: print(f"Unable to persist {_id} mb metadata") traceback.print_tb(e.__traceback__) raise
def persist_sections(track_id: int, sections: List[SectionTuple]): _track = Track.query.filter_by(id=track_id).first() for section_tuple in sections: try: Persist.persist_section_tuple(section_tuple, track_id) except Exception as e: print(f"Unable to persist section {section_tuple}") traceback.print_tb(e.__traceback__) raise
def persist_lyrics_links(track_id: int, candidates: CandidatesTuple) -> None: _track = Track.query.filter_by(id=track_id).first() _updates = {Track.lyrics_annotations_json: candidates._asdict()} try: Persist.update(Track, _track.id, _updates) except Exception as e: print(f"Unable to persist track {track_id} annotations") traceback.print_tb(e.__traceback__) raise
def persist_lyrics_annotated(track_id: int, lyrics_annotated: AnnotationTuple) -> None: _track = Track.query.filter_by(id=track_id).first() _updates = {Track.lyrics_annotated: lyrics_annotated.text} try: Persist.update(Track, _track.id, _updates) except Exception as e: print(f"Unable to persist track {track_id} annotated lyrics") traceback.print_tb(e.__traceback__) raise
def persist_name(model: db.Model, _id: int, _name: Optional[str]) -> None: _instance = model.query.filter_by(id=_id).first() if _name: _updates = {model.name: _name} try: Persist.update(model, _instance.id, _updates) except Exception as e: print(f"Unable to persist {_id} name") traceback.print_tb(e.__traceback__) raise
def persist_wikipedia_uri(model: db.Model, _id: int, wikipedia_uri: Optional[str]) -> None: _instance = model.query.filter_by(id=_id).first() if wikipedia_uri: _updates = {model.wikipedia_uri: wikipedia_uri} try: Persist.update(model, _instance.id, _updates) except Exception as e: print(f"Unable to persist {_id} wikipedia uri") traceback.print_tb(e.__traceback__) raise
def persist_artist_birthplace(artist_id: int, location_tuple: LocationTuple) -> None: try: _artist = Artist.query.filter_by(id=artist_id).first() _updated = location_tuple._replace(birthplace_of=_artist) Persist.persist_location_tuple(_updated) except Exception as e: print( f"Unable to persist artist {artist_id} birthplace {location_tuple}" ) traceback.print_tb(e.__traceback__) raise
def persist_release_date(album_id: int, release_date: datetime.datetime, release_date_string: str) -> None: _album = Album.query.filter_by(id=album_id).first() _updates = { Album.release_date: release_date, Album.release_date_string: release_date_string } try: Persist.update(Album, _album.id, _updates) except Exception as e: print(f"Unable to persist track release date {album_id}") traceback.print_tb(e.__traceback__) raise
def persist_lyrics(track_id: int, lyrics: Optional[str], url: Optional[str]) -> None: _track = Track.query.filter_by(id=track_id).first() if lyrics: _updates = {Track.lyrics: lyrics, Track.lyrics_url: url} else: _updates = {Track.lyrics_url: url} try: Persist.update(Track, _track.id, _updates) except Exception as e: print(f"Unable to persist track lyrics {track_id}") traceback.print_tb(e.__traceback__) raise