Beispiel #1
0
 def callback(self, call_params):
     artist_id = call_params['artist_id']
     query = Release.select()\
         .join(ReleaseGroup.model())\
         .join(ReleaseGroupArtist.model())\
         .join(Artist.model())\
         .where(Artist.model().id == artist_id)
     return ModelListParameter.add_results_to_dict({}, Release, query)
Beispiel #2
0
def create_data_from_beets_track(beets_item_file_entry_link, beets_track):
    """For a given beets track, get hold of a bunch of useful stuff.

        For now:
            - Label
            - Genre
            - Release
            - ReleaseGroup
            - Artist
            - Track
            - TrackArtistLink
            - ReleaseGroupArtistLink
    """
    file_entry = beets_item_file_entry_link.get_file_entry()
    if Track.exists_for_file_entry(file_entry):
        return

    # Get useful data off it
    label_name = replace_with_unknown_if_empty(beets_track.label)
    genre_name = replace_with_unknown_if_empty(beets_track.genre)
    track_artist_name = replace_with_unknown_if_empty(beets_track.artist)
    track_artist_mbid = replace_with_unknown_if_empty(beets_track.mb_artistid)
    album_artist_name = replace_with_unknown_if_empty(beets_track.albumartist)
    album_artist_mbid = replace_with_unknown_if_empty(beets_track.mb_albumartistid)
    album_name = replace_with_unknown_if_empty(beets_track.album)
    track_name = replace_with_unknown_if_empty(beets_track.title)
    track_mbid = replace_with_unknown_if_empty(beets_track.mb_trackid)
    release_group_mbid = replace_with_unknown_if_empty(beets_track.mb_releasegroupid)
    release_group_type = replace_with_unknown_if_empty(beets_track.albumtype)
    track_number = beets_track.track

    # Start finding or creating records
    label = Label.get_or_create_for_name(label_name)
    genre = Genre.get_or_create_for_name(genre_name)
    track_artist = Artist.get_or_create(track_artist_name, track_artist_mbid)
    album_artist = Artist.get_or_create(album_artist_name, album_artist_mbid)
    release_group = ReleaseGroup.get_or_create(album_name, release_group_type, release_group_mbid)
    release = Release.get_or_create(label, release_group)
    track = Track.get_or_create(release, file_entry, genre, track_name, track_mbid, track_number)

    # Just assume they're the main artist for now!
    track_artist_link = TrackArtist.get_or_create(track, track_artist, "Main")
    release_group_artist_link = ReleaseGroupArtist.get_or_create(release_group, album_artist, "Main")

    logger.info("finished " + file_entry.get_rel_path())