コード例 #1
0
ファイル: artist.py プロジェクト: aeroheim/mu-db
def getArtistData(artist_id):
    
    session = db.loadSession()

    artist = session.query(db.Artist.id,
                           db.Artist.artist_name)\
              .select_from(db.Artist)\
              .filter(db.Artist.id == artist_id)\
              .first()

    album_list = session.query(db.Album.id,
                               db.Album.album_name,
                               db.Album.album_art,
                               db.Album.year)\
                  .select_from(db.Artist)\
                  .join(db.Album)\
                  .filter(db.Album.artist_id == artist_id)\
                  .all()

    genre_list = session.query(distinct(db.Genre.id),
                               db.Genre.genre_name)\
                  .select_from(db.Artist)\
                  .join(db.Album)\
                  .join(db.AlbumGenres)\
                  .join(db.Genre)\
                  .filter(db.Album.artist_id == artist_id)\
                  .all()

    session.close()
    
    keys = ('id', 'artist_name', ('albums', ('album_id', 'album_name', 'album_art', 'year')), ('genres', ('genre_id', 'genre_name')))
    result_tuple = artist + (album_list, genre_list)
    results_dict = map_keys(keys, result_tuple)

    return results_dict
コード例 #2
0
ファイル: album.py プロジェクト: aeroheim/mu-db
def getAlbumData(album_id):

    session = db.loadSession()

    album = (
        session.query(
            db.Album.id,
            db.Album.artist_id,
            db.Album.album_name,
            db.Artist.artist_name,
            db.Album.album_art,
            db.Album.type,
            db.Album.year,
            db.Album.bc_link,
        )
        .select_from(db.Album)
        .join(db.Artist)
        .filter(db.Album.id == album_id)
        .first()
    )

    track_list = (
        session.query(db.Track.id, db.Track.name).select_from(db.Track).filter(db.Track.album_id == album_id).all()
    )

    genre_list = (
        session.query(db.Genre.genre_name)
        .select_from(db.Album)
        .join(db.AlbumGenres)
        .join(db.Genre)
        .filter(db.Album.id == album_id)
        .all()
    )

    session.close()

    keys = (
        "id",
        "artist_id",
        "album_name",
        "artist_name",
        "album_art",
        "type",
        "year",
        "bc_link",
        ("genres", ("genre_name",)),
        ("tracks", ("track_id", "track_name")),
    )
    result_tuple = album + (genre_list, track_list)
    results_dict = map_keys(keys, result_tuple)

    return results_dict
コード例 #3
0
ファイル: track.py プロジェクト: aeroheim/mu-db
def getTrackData(track_id):
    
    session = db.loadSession()
    
    track = session.query(db.Track.id,
                          db.Track.name,
                          db.Track.duration,
                          db.Track.album_id,
                          db.Album.album_name,
                          db.Artist.id,
                          db.Artist.artist_name)\
             .select_from(db.Track)\
             .join(db.Album)\
             .join(db.Artist)\
             .filter(db.Track.id == track_id)\
             .first()

    session.close()

    keys = ('id', 'track_name', 'duration', 'album_id', 'album_name', 'artist_id', 'artist_name')
    result_dict = map_keys(keys, track)

    return result_dict