diff --git a/grzegorz_clients/api.py b/grzegorz_clients/api.py
index 8e5683c..37f3aa4 100644
--- a/grzegorz_clients/api.py
+++ b/grzegorz_clients/api.py
@@ -95,6 +95,11 @@ def playlist_remove(index:int):
args = urlencode(locals())
return f"playlist?{args}", None
+@request_post
+def playlist_move(index1:int, index2:int):
+ args = urlencode(locals())
+ return f"playlist/move?{args}", None
+
@request_get
def get_playback_pos():
return f"time"
diff --git a/grzegorz_clients/colors.py b/grzegorz_clients/colors.py
new file mode 100644
index 0000000..07e8c3e
--- /dev/null
+++ b/grzegorz_clients/colors.py
@@ -0,0 +1,24 @@
+COLOR_BLUE = "rgb(33, 150, 243)"
+COLOR_BLUE_SHADOW = "rgba(33, 150, 243, 0.75)"
+COLOR_LIGHT_BLUE = "#e3f2fd"
+COLOR_INDIGO = "#6610f2"
+COLOR_PURPLE = "#6f42c1"
+COLOR_PINK = "#e83e8c"
+COLOR_RED = "#dd2c00"
+COLOR_ORANGE = "#fd7e14"
+COLOR_YELLOW = "#ffc107"
+COLOR_GREEN = "#28a745"
+COLOR_TEAL = "#20c997"
+COLOR_CYAN = "#17a2b8"
+COLOR_WHITE = "#fff"
+COLOR_GRAY_LIGHT = "#abc"
+COLOR_GRAY = "#6c757d"
+COLOR_GRAY_DARK = "#343a40"
+COLOR_PRIMARY = "#007bff"
+COLOR_SECONDARY = "#6c757d"
+COLOR_SUCCESS = "#28a745"
+COLOR_INFO = "#17a2b8"
+COLOR_WARNING = "#ffc107"
+COLOR_DANGER = "#dc3545"
+COLOR_LIGHT = "#f8f9fa"
+COLOR_DARK = "#343a40"
diff --git a/grzegorz_clients/remi_ui.py b/grzegorz_clients/remi_ui.py
index 4de1854..a0d0e3a 100644
--- a/grzegorz_clients/remi_ui.py
+++ b/grzegorz_clients/remi_ui.py
@@ -4,12 +4,9 @@ import remi.gui as gui
from remi import App
from .utils import Namespace, call_as_thread, get_youtube_metadata, seconds_to_timestamp
from . import api
+from .colors import *
#globals:
-COLOR_BLUE = "rgb(33, 150, 243)"
-COLOR_BLUE_SHADOW = "rgba(33, 150, 243, 0.75)"
-COLOR_LIGHT_BLUE = "#e3f2fd"
-COLOR_GRAY = "#212529"
WIDTH = 512
class RemiApp(App):
@@ -65,12 +62,12 @@ class RemiApp(App):
#playlist
self.playlist = Namespace()
self.playlist.table = gui.Table(width="100%", margin="10px")
- self.playlist.table.append_from_list([['#', 'Name', "length"]], fill_title=True)
+ self.playlist.table.append_from_list([['#', 'Name', "length", "", "", ""]], fill_title=True)
container.append(self.playlist.table)
#input
- container.append(gui.Label("Add songs:"))
+ container.append(gui.Label("Add song:"))
input_container = gui.HBox(width=WIDTH)
self.input = Namespace()
self.input.field = gui.TextInput(single_line=True, height="20px", margin="5px")
@@ -131,8 +128,19 @@ class RemiApp(App):
def change_volume(self, widget, value):
api.set_volume(value)
def on_table_row_click(self, row_widget, playlist_item):
- print(playlist_item)
-
+ print("row", playlist_item)
+ @call_as_thread
+ def on_table_item_move_click(self, row_widget, playlist_item, down = True):
+ index = playlist_item["index"]
+ dest = index + 2 if down else index-1
+ api.playlist_move(index, dest)
+ @call_as_thread
+ def on_table_item_remove_click(self, row_widget, playlist_item):
+ api.playlist_remove(playlist_item["index"])
+ @call_as_thread
+ def on_playlist_clear_click(self, row_widget):
+ api.playlist_clear()
+
# playback steps:
@call_as_thread
def playback_update(self, times_called=[0]):
@@ -188,6 +196,9 @@ class RemiApp(App):
playlist_item["index"],
name,
length,
+ '',
+ '',
+ '',
])
self.playlist.table.empty(keep_title=True)
@@ -199,10 +210,25 @@ class RemiApp(App):
if "current" in playlist_item:
row_widget.style["background-color"] = COLOR_LIGHT_BLUE
else:
- row_widget.style["color"] = "#444"#COLOR_GRAY
+ row_widget.style["color"] = COLOR_GRAY_DARK
row_widget.set_on_click_listener(self.on_table_row_click, playlist_item)
- for item_widget in map(row_widget.get_child, row_widget._render_children_list):
- pass
+ for index, (key, item_widget) in enumerate(zip(row_widget._render_children_list,
+ map(row_widget.get_child, row_widget._render_children_list))):
+ if index >= 3:
+ item_widget.style["width"] = "1.1em"
+ item_widget.style["color"] = COLOR_TEAL
+ if index == 3:
+ item_widget.set_on_click_listener(self.on_table_item_move_click, playlist_item, False)
+ if playlist_item["index"] == 0:
+ item_widget.style["color"] = COLOR_GRAY_LIGHT
+ if index == 4:
+ item_widget.set_on_click_listener(self.on_table_item_move_click, playlist_item, True)
+ if playlist_item["index"] == N-1:
+ item_widget.style["color"] = COLOR_GRAY_LIGHT
+ if index == 5:
+ item_widget.style["color"] = COLOR_RED
+ item_widget.set_on_click_listener(self.on_table_item_remove_click, playlist_item)
+ #print(index, key, item_widget)
#helpers
def set_playing(self, is_playing:bool):
diff --git a/grzegorz_clients/utils.py b/grzegorz_clients/utils.py
index 68b3658..1dcb271 100644
--- a/grzegorz_clients/utils.py
+++ b/grzegorz_clients/utils.py
@@ -28,8 +28,6 @@ def get_youtube_metadata(url, ydl = youtube_dl.YoutubeDL()):
#Stop it from doing the whole playlist
url = filter_query_params(url, allowed=["v"])
- print(url)
-
try:
resp = ydl.extract_info(url, download=False)
except DownloadError: