REFACTOR: MUSIC LIBRARYgit status #91
This commit is contained in:
17
interface.py
17
interface.py
@ -12,7 +12,7 @@ import random
|
||||
from werkzeug.utils import secure_filename
|
||||
import errno
|
||||
import media
|
||||
from media.playlist import PlaylistItemWrapper
|
||||
from media.playlist import get_item_wrapper
|
||||
from media.file import FileItem
|
||||
from media.url_from_playlist import PlaylistURLItem, get_playlist_info
|
||||
from media.url import URLItem
|
||||
@ -132,7 +132,7 @@ def playlist():
|
||||
for index, item_wrapper in enumerate(var.playlist):
|
||||
items.append(render_template('playlist.html',
|
||||
index=index,
|
||||
m=item_wrapper.item,
|
||||
m=item_wrapper.item(),
|
||||
playlist=var.playlist
|
||||
)
|
||||
)
|
||||
@ -164,14 +164,15 @@ def post():
|
||||
if 'add_file_bottom' in request.form and ".." not in request.form['add_file_bottom']:
|
||||
path = var.music_folder + request.form['add_file_bottom']
|
||||
if os.path.isfile(path):
|
||||
music_wrapper = PlaylistItemWrapper(FileItem(var.bot, request.form['add_file_bottom']), user)
|
||||
music_wrapper = get_item_wrapper(var.bot, type='file', path=request.form['add_file_bottom'], user=user)
|
||||
|
||||
var.playlist.append(music_wrapper)
|
||||
log.info('web: add to playlist(bottom): ' + music_wrapper.format_debug_string())
|
||||
|
||||
elif 'add_file_next' in request.form and ".." not in request.form['add_file_next']:
|
||||
path = var.music_folder + request.form['add_file_next']
|
||||
if os.path.isfile(path):
|
||||
music_wrapper = PlaylistItemWrapper(FileItem(var.bot, request.form['add_file_next']), user)
|
||||
music_wrapper = get_item_wrapper(var.bot, type='file', path=request.form['add_file_next'], user=user)
|
||||
var.playlist.insert(var.playlist.current_index + 1, music_wrapper)
|
||||
log.info('web: add to playlist(next): ' + music_wrapper.format_debug_string())
|
||||
|
||||
@ -197,8 +198,8 @@ def post():
|
||||
files = music_library.get_files(folder)
|
||||
|
||||
music_wrappers = list(map(
|
||||
lambda file: PlaylistItemWrapper(FileItem(var.bot, folder + file), user),
|
||||
files))
|
||||
lambda file: get_item_wrapper(var.bot, type='file', path=file, user=user),
|
||||
files))
|
||||
|
||||
var.playlist.extend(music_wrappers)
|
||||
|
||||
@ -207,7 +208,7 @@ def post():
|
||||
|
||||
|
||||
elif 'add_url' in request.form:
|
||||
music_wrapper = PlaylistItemWrapper(URLItem(var.bot, request.form['add_url']), user)
|
||||
music_wrapper = get_item_wrapper(var.bot, type='url', url=request.form['url'])
|
||||
var.playlist.append(music_wrapper)
|
||||
|
||||
log.info("web: add to playlist: " + music_wrapper.format_debug_string())
|
||||
@ -217,7 +218,7 @@ def post():
|
||||
|
||||
elif 'add_radio' in request.form:
|
||||
url = request.form['add_radio']
|
||||
music_wrapper = PlaylistItemWrapper(RadioItem(var.bot, url), user)
|
||||
music_wrapper = get_item_wrapper(var.bot, type='radio', url=url)
|
||||
var.playlist.append(music_wrapper)
|
||||
|
||||
log.info("cmd: add to playlist: " + music_wrapper.format_debug_string())
|
||||
|
Reference in New Issue
Block a user