示例#1
0
def deleteAlbum():
    print("deleted")
    album=request.form['album']
    artist=request.form['artist']
    if(album!=''):
        p = Popen(['beet','remove','-a', album], stdin=PIPE, stdout=PIPE, stderr=PIPE, bufsize=1)
        for line in p.stderr:
            print(line.decode('UTF-8')[-1])
        onlyfiles = [f for f in listdir(beetsCommands.get_library())]
        for dirn in onlyfiles:
            if artist in dirn:
                shutil.rmtree(beetsCommands.get_library()+'/'+dirn)
        print("artist"+artist)

    else:
        print("fdfd")
        p = Popen(['beet', 'remove', artist], stdin=PIPE, stdout=PIPE, stderr=PIPE, bufsize=1)
        for line in p.stderr:
            print(line.decode('UTF-8')[-1])
        onlyfiles = [f for f in listdir(beetsCommands.get_library())]
        for dirn in onlyfiles:
            if artist in dirn:
                shutil.rmtree(beetsCommands.get_library() + '/' + dirn)
    return redirect('/albums')
示例#2
0
def rBackup():
    gitAnnexLib.from_backup(beetsCommands.get_library())
    return redirect('/albums')
示例#3
0
def details():
    polish = dictionary.polish()
    dict = dictionary.dictionary(polish)
    albums_id = request.args.getlist('id', type=int)
    action = request.args.getlist('action', type=str)
    expand = request.args.get('expand', type=str)
    saved = request.args.get('remotes', type=str)
    albums = []
    id_arg = ''
    local_repo.get_remotes()
    print("example" + str(local_repo.get_remotes()))
    if saved == 'saved':
        if request.method == 'POST':
            for album_id in albums_id:
                album_dir = beetsCommands.path_to_str(lib.get_album(album_id).item_dir())
                album_dir = album_dir[len(beetsCommands.get_library()) + 1:]
                postvars = variabledecode.variable_decode(request.form, dict_char='_')
                keys = postvars.keys()
                for repo in local_repo.remotes:
                    if repo.name not in keys:
                        local_repo.annex_sync(repo)
                        repo.annex_sync(local_repo)
                        repo.annex_drop(album_dir)
                        repo.annex_sync(local_repo)
                        local_repo.annex_sync(repo)
                    else:
                        local_repo.annex_sync(repo)
                        repo.annex_sync(local_repo)
                        repo.annex_get(local_repo, album_dir)
                        repo.annex_sync(local_repo)
                        local_repo.annex_sync(repo)

                if 'YAMO' not in postvars.keys():
                    local_repo.annex_drop(album_dir)
                else:
                    local_repo.annex_get_from_all(album_dir)

    remote_names = local_repo.remote_names
    remotes_send = []
    for album_id in albums_id:
        if id_arg != '':
            id_arg = id_arg + '&'
        id_arg = id_arg + 'id=' + str(album_id)
        albums.append(lib.get_album(album_id))
        items = albums[-1].items()
        album_dir = beetsCommands.path_to_str(beetsCommands.path_to_str(items[0].path))
        if album_dir:
            album_dir = album_dir[len(beetsCommands.get_library()) + 1:]
            remotes_send.append(local_repo.annex_whereis(album_dir))

    if 'YAMO' not in remote_names:
        remote_names.append('YAMO')

    remote_names_copy = []
    for name in remote_names:
        if name not in remotes_send[0]:
            remote_names_copy.append(name)
    remotes_send.append(remote_names_copy)

    local_repo.annex_direct()
    details = beetsCommands.pack_albums_items(albums)
    local_repo.annex_indirect()

    if expand == 'true':
        if 'edit' in action:
            return edit_data(id_arg, dict, expand, remotes_send)
        else:
            return render_template('expandeddetails.html', details=details, dictionary=dict, id_arg=id_arg,
                                   expanded=expand, remotes=remotes_send)

    polish_short = dictionary.PolishShort()
    dict_short = dictionary.dictionary(polish_short)
    if 'edit' in action:
        return edit_data(id_arg, dict_short, expand, remotes_send)
    print(remotes_send)

    return render_template('expandeddetails.html', details=details, dictionary=dict_short, id_arg=id_arg,
                           expanded=expand, remotes=remotes_send)
示例#4
0
def rBackup():
    gitAnnexLib.from_backup(beetsCommands.get_library())
    return redirect('/albums')


@app.route("/artists")
def artysci():
    return render_template('artists.html')


@app.route("/songs")
def muzyka():
    return render_template('songs.html')


local_repo = gitAnnexLib.Repo(path=beetsCommands.get_library(), local=1)
lib = Library(beetsCommands.get_database())
local_repo.annex_direct()
get_backup(local_repo.path)
import_to_beets(local_repo.path, first=1)
get_backup(local_repo.path)
local_repo.annex_indirect()
#print("local repo autopushing  sdsdfsdfdsfdsfsdfs")
#print(local_repo.autopushing)
for autopush in local_repo.autopushing:
    autopush.get_from(local_repo)
#print("local repo autogetting  sdsdfsdfdsfdsfsdfs")
#print(local_repo.autogetting)
for autoget in local_repo.autogetting:
    local_repo.get_from(autoget)