Example #1
0
def set_metatags(album_id, mode):
    album = get_album(album_id)
    for p in tag_get_piece_paths(album_id):
        if mode == 'short':
            title2tag(p, album['Title'])
        if mode == 'long':
            all2tag(p, album['Title'], album['ID'])
    return ''
Example #2
0
def read_albums(album_id):
    album = get_album(album_id)
    # get_albums(album['Path'], None, 0)
    path = os.path.join(AUDIO_ROOT, album['Path'])
    for d in os.listdir(path):
        p = u'{}/{}'.format(path, d)
        if os.path.isdir(p) and d not in SKIP_DIRS:
            process_album(p, album_id)
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 albumimageback(album_id, w=None, h=None):
    album = get_album(album_id)
    if not album:
        return HttpResponseNotFound(
            'Dit album bestaat niet:"{}"'.format(album_id), )
    if not album['Path']:
        return empty_response()
    image_path = AUDIO_ROOT + album['Path'] + settings.BACK_FILE
    return get_image(image_path, w, h)
Example #6
0
def remove_piece(album_id, piece_name):
    album = get_album(album_id)
    p = os.path.join(album['Path'], piece_name)
    try:
        os.remove(p)
    except FileNotFoundError as ex:
        ColorPrint.print_c(str(ex), ColorPrint.CYAN)
        socket_log(str(ex), 'error', album_id)
    except PermissionError as p:
        ColorPrint.print_c(str(p), ColorPrint.CYAN)
        socket_log(str(p), 'error', album_id)
Example #7
0
def tag_put_picture(album_id):
    pic = Picture()
    album = get_album(album_id)
    with open(album['Path'] + "/folder.jpg", "rb") as f:
        pic.data = f.read()
    if not pic.data:
        return 'No folder.jpg found'
    pic.type = id3.PictureType.COVER_FRONT
    pic.mime = u"image/jpeg"
    pic.width = 500
    pic.height = 500
    pic.depth = 16
    for p in tag_get_piece_paths(album_id):
        set_pic(p, pic)
    return 'success'
Example #8
0
def save_album(album_id):
    album = get_album(album_id)
    image_path = album['Path'] + COVER_FILE
    if os.path.exists(image_path):
        os.remove(image_path)
    #     todo: remove all cached folder files
        remove_cached_cover(album['Path'])
    try:
        clipboard_save_path(album['Path'] + COVER_FILE)
    except PermissionError as pe:
        print(str(pe))
        print(image_path)
        return 'not saved'
    except FileNotFoundError as fe:
        print(str(fe))
        print(image_path)
        return 'not saved'
    return 'saved from clipboard:' + image_path
Example #9
0
def album_delete(request, album_id):
    delete_album(album_id)
    template = loader.get_template('website/album_deleted.html')
    return HttpResponse(
        template.render({'album': get_album(album_id)}, request))