Example #1
0
def has_music_files(path):
    count = 0
    for ext in MUSIC_FILES:
        for f in os.listdir(path):
            if ext == get_extension(f):
                count += 1
    return count > 0
Example #2
0
def get_apeflac_albums():
    sql = '''
    SELECT Title, ID, Path
    FROM Album 
        '''
    conn, c = connect()
    items = c.execute(sql).fetchall()
    conn.close()
    out = []
    for item in items:
        pieces = get_pieces(item[1])
        count_ape = 0
        count_flac = 0
        for piece in pieces:
            ext = get_extension(piece['Name'])
            if ext == 'flac':
                count_flac += 1
            if ext == 'ape':
                count_ape += 1
        if count_ape > 0 and count_flac > 0:
            it = {
                'Title': item[0],
                'ID': item[1],
                'Path': item[2],
                'CountApe': count_ape,
                'CountFlac': count_flac,
            }
            out.append(it)
    return out
Example #3
0
def tag_get_piece_paths(album_id):
    album = get_album(album_id)
    print(album['Title'])
    pieces = get_pieces(album_id)
    paths = []
    for piece in pieces:
        if get_extension(piece['Name']) != 'cue':
            paths.append(os.path.join(album['Path'], piece['Name']))
    return paths
Example #4
0
def remove_tag(album_id, tag):
    album = get_album(album_id)
    print(album['Title'])
    pieces = get_pieces(album_id)
    for piece in pieces:
        if get_extension(piece['Name']) != 'cue':
            p = os.path.join(album['Path'], piece['Name'])
            delete_tag(p, tag)
    return ''
Example #5
0
def delete_album_ape(album_id):
    pieces = get_pieces(album_id)
    for piece in pieces:
        if get_extension(piece['Name']) == 'ape':
            remove_piece(album_id, piece['Name'])
            delete_piece(piece['ID'])
            socket_log(msg=piece['Name'] + ' deleted',
                       mode='info',
                       id=album_id)
Example #6
0
def insert_pieces(path, album_id, conn, c):
    for ext in MUSIC_FILES:
        for f in os.listdir(path):
            if f[0] != '.' and ext == get_extension(f):
                insert_piece(
                    name=f,
                    code='',  # kirkpatrick(f, 'K ', ' '),
                    album_id=album_id,
                    c=c,
                    conn=conn)
Example #7
0
def check_subdirs(path):
    path = os.path.join(AUDIO_ROOT, path)
    if os.path.exists(path):
        for d in os.listdir(path):
            p = os.path.join(path, d)
            if os.path.isdir(p) and d not in SKIP_DIRS:
                for f in os.listdir(p):
                    if f[0] != '.' and get_extension(f) in MUSIC_FILES:
                        return True
    return False
Example #8
0
def add_count(albums):
    for album in albums:
        count_pieces = 0
        count_cue = 0
        pieces = get_pieces(album['ID'])
        for piece in pieces:
            extension = get_extension(piece['Name'])
            if extension != 'cue':
                count_pieces += 1
            else:
                count_cue += 1
        album['CountPieces'] = count_pieces
        album['CountCues'] = count_cue
Example #9
0
def get_apealone_albums():
    sql = '''
    SELECT Title, ID, Path
    FROM Album 
        '''
    conn, c = connect()
    items = []
    try:
        items = c.execute(sql).fetchall()
    except:
        print_error(sql, 'apeflac')
    conn.close()
    out = []
    for item in items:
        pieces = get_pieces(item[1])
        count_ape = 0
        count_flac = 0
        count_cue = 0
        count_piece = 0
        for piece in pieces:
            ext = get_extension(piece['Name'])
            if ext == 'flac':
                count_flac += 1
            if ext == 'ape':
                count_ape += 1
            if ext == 'cue':
                count_cue += 1
            else:
                count_piece += 1
        if count_ape > 0 and count_flac == 0:
            # if 3 > count_ape > 0 == count_flac \
            #         and count_cue == 1:
            it = {
                'Title': item[0],
                'ID': item[1],
                'Path': item[2],
                'CountApe': count_ape,
                'CountFlac': count_flac,
                'CountCues': count_cue,
                'CountPieces': count_piece
            }
            out.append(it)
    return out
Example #10
0
def rename_music_files(path):
    for ext in MUSIC_FILES:
        for f in os.listdir(path):
            if ext == get_extension(f):
                rename_file(path, f)
    return ''
Example #11
0
def has_musical_files(path):
    for ext in MUSIC_FILES:
        for f in os.listdir(path):
            if ext == get_extension(f):
                return True
    return False