def movesong(): if "online" not in session: return redirect("/") if session["shared"]: return redirect("/") #get id idd=int(request.args.get("id", 0)) movedown=int(request.args.get("down", 0)) #load playlist playlist=load_playlist("main") #check pop if idd not in range(0, len(playlist)): return "" #pop song if movedown: song=playlist.pop(idd) playlist.insert(idd+1, song) else: song=playlist.pop(idd) if idd==0:idd=1 playlist.insert(idd-1, song) save_playlist("main", playlist) return ""
def musicplayerview(): if "online" not in session: return redirect("/") if session["shared"]: return redirect("/") #load playlist playlist=load_playlist("main") for song in playlist: song[1]=encodeutf8(song[1]) song[1]=base64.b64encode(song[1]) #Song in playlist # [0] title [1] Full path to file return render_template("music.html", playlist=playlist)
def removesong(): if "online" not in session: return redirect("/") if session["shared"]: return redirect("/") #get id idd=int(request.args.get("id", 0)) #load playlist playlist=load_playlist("main") #check pop if idd not in range(0, len(playlist)): return "" #pop song playlist.pop(int(idd)) save_playlist("main", playlist) return ""
def addsong(): # Check login state if "online" not in session: return redirect("/") if session["shared"]: return redirect("/") fname = request.args.get("file", "") fname = base64.b64decode(fname) if not fname: return "" # Load song songs = load_playlist("main") # Add song spath = os.path.join(session["sciezka"], fname) fname = os.path.splitext(fname)[0] songs.append([fname, spath]) # save playlist save_playlist("main", songs) return ""