def folder_add(path): "Add a folder to the Library" ret = FolderManager.add(path) if ret != FolderManager.SUCCESS: print FolderManager.error_str(ret) else: print "Folder '{}' added".format(path)
def folder_delete(path): "Delete folder from Library" s = Scanner(session) ret = FolderManager.delete_by_name(path, s) if ret != FolderManager.SUCCESS: print FolderManager.error_str(ret) else: print "Deleted folder" + path
def del_folder(id): try: idid = uuid.UUID(id) except ValueError: flash('Invalid folder id') return redirect(url_for('folder_index')) ret = FolderManager.delete(idid) if ret != FolderManager.SUCCESS: flash(FolderManager.error_str(ret)) else: flash('Deleted folder') return redirect(url_for('folder_index'))
def folder_prune(): s = Scanner(session) folders = session.query(Folder).filter(Folder.root == True) if folders: for folder in folders: print "Pruning: " + folder.path FolderManager.prune(folder.id, s) added, deleted = s.stats() print "\a" print "Pruning done" print 'Added: %i artists, %i albums, %i tracks' % (added[0], added[1], added[2]) print 'Deleted: %i artists, %i albums, %i tracks' % (deleted[0], deleted[1], deleted[2])
def scan_folder(id = None): s = Scanner(session) if id is None: for folder in Folder.query.filter(Folder.root == True): FolderManager.scan(folder.id, s) else: status = FolderManager.scan(id, s) if status != FolderManager.SUCCESS: flash(FolderManager.error_str(status)) return redirect(url_for('folder_index')) added, deleted = s.stats() session.commit() flash('Added: %i artists, %i albums, %i tracks' % (added[0], added[1], added[2])) flash('Deleted: %i artists, %i albums, %i tracks' % (deleted[0], deleted[1], deleted[2])) return redirect(url_for('folder_index'))
def folder_prune(): s = Scanner(session) folders = session.query(Folder).filter(Folder.root == True) if folders: for folder in folders: print "Pruning: " + folder.path FolderManager.prune(folder.id, s) added, deleted = s.stats() print "\a" print "Pruning done" print 'Added: %i artists, %i albums, %i tracks' % (added[0], added[1], added[2]) print 'Deleted: %i artists, %i albums, %i tracks' % ( deleted[0], deleted[1], deleted[2])
def folder_scan(self, folders): s = Scanner(db.session) if folders: folders = map(lambda n: db.Folder.query.filter(db.Folder.name == n and db.Folder.root == True).first() or n, folders) if any(map(lambda f: isinstance(f, basestring), folders)): print "No such folder(s): " + ' '.join(f for f in folders if isinstance(f, basestring)) for folder in filter(lambda f: isinstance(f, db.Folder), folders): FolderManager.scan(folder.id, s) else: for folder in db.Folder.query.filter(db.Folder.root == True): FolderManager.scan(folder.id, s) added, deleted = s.stats() db.session.commit() print "Scanning done" print 'Added: %i artists, %i albums, %i tracks' % (added[0], added[1], added[2]) print 'Deleted: %i artists, %i albums, %i tracks' % (deleted[0], deleted[1], deleted[2])
def scan_folder(id=None): s = Scanner(session) if id is None: for folder in Folder.query.filter(Folder.root == True): FolderManager.scan(folder.id, s) else: status = FolderManager.scan(id, s) if status != FolderManager.SUCCESS: flash(FolderManager.error_str(status)) return redirect(url_for('folder_index')) added, deleted = s.stats() session.commit() flash('Added: %i artists, %i albums, %i tracks' % (added[0], added[1], added[2])) flash('Deleted: %i artists, %i albums, %i tracks' % (deleted[0], deleted[1], deleted[2])) return redirect(url_for('folder_index'))
def add_folder(): if request.method == 'GET': return render_template('addfolder.html') error = False (name, path) = map(request.form.get, ['name', 'path']) if name in (None, ''): flash('The name is required.') error = True if path in (None, ''): flash('The path is required.') error = True if error: return render_template('addfolder.html') ret = FolderManager.add(name, path) if ret != FolderManager.SUCCESS: flash(FolderManager.error_str(ret)) return render_template('addfolder.html') flash("Folder '%s' created. You should now run a scan" % name) return redirect(url_for('folder_index'))
def add_folder(): if request.method == 'GET': return render_template('addfolder.html') error = False (name, path) = map(request.form.get, [ 'name', 'path' ]) if name in (None, ''): flash('The name is required.') error = True if path in (None, ''): flash('The path is required.') error = True if error: return render_template('addfolder.html') ret = FolderManager.add(name, path) if ret != FolderManager.SUCCESS: flash(FolderManager.error_str(ret)) return render_template('addfolder.html') flash("Folder '%s' created. You should now run a scan" % name) return redirect(url_for('folder_index'))
def add_folder(): if request.method == "GET": return render_template("addfolder.html") error = False (name, path) = map(request.form.get, ["name", "path"]) if name in (None, ""): flash("The name is required.") error = True if path in (None, ""): flash("The path is required.") error = True if error: return render_template("addfolder.html") ret = FolderManager.add(name, path) if ret != FolderManager.SUCCESS: flash(FolderManager.error_str(ret)) return render_template("addfolder.html") flash("Folder '%s' created. You should now run a scan" % name) return redirect(url_for("folder_index"))
def folder_add(self, name, path): ret = FolderManager.add(name, path) if ret != FolderManager.SUCCESS: print FolderManager.error_str(ret) else: print "Folder '{}' added".format(name)
def folder_delete(self, name): ret = FolderManager.delete_by_name(name) if ret != FolderManager.SUCCESS: print FolderManager.error_str(ret) else: print "Deleted folder '{}'".format(name)