From 9ebedc55a4669ba7a5660aa4a7e8825246c06041 Mon Sep 17 00:00:00 2001 From: Sam Chudnick Date: Sun, 11 Jun 2023 08:10:01 -0400 Subject: Interface updates --- config.ini | 63 ++++++++++++++++------ interface.py | 173 ++++++++++++++++++++++++++++++++++++++++++++++------------- 2 files changed, 183 insertions(+), 53 deletions(-) diff --git a/config.ini b/config.ini index 4f8fd58..037a2b2 100644 --- a/config.ini +++ b/config.ini @@ -6,27 +6,58 @@ password = changeme verify_tls = 0 [colors] -header_fg = black -header_bg = light gray -text_fg = white +# Header +header_fg = dark gray +header_bg = black + +# Unfocused Media - Main Mode +text_fg = dark gray text_bg = default -focus_fg = white -focus_bg = dark read text_viewed_fg = yellow text_viewed_bg = default -focus_viewed_fg = yellow -focus_viewed_bg = dark red -fav_fg = light green -fav_bg = default -non_fav_fg = dark gray -non_fav_bg = default -fav_foc_fg = light green -fav_foc_bg = dark gray -non_fav_foc_fg = light gray -non_fav_foc_bg = dark gray +# Focused Media - Main Mode +focus_fg = black +focus_bg = dark gray +focus_viewed_fg = black +focus_viewed_bg = yellow + +# Unfocused Container - Main Mode +container_fg = light blue +container_bg = default +container_viewed_fg = light magenta +container_viewed_bg = default + +# Focused Container - Main Mode +container_focus_fg = black +container_focus_bg = light blue +container_focus_viewed_fg = black +container_focus_viewed_bg = light magenta + +# Unfocused Media - Favorites Mode +favorite_fg = yellow +favorite_bg = default +non_favorite_fg = dark gray +non_favorite_bg = default + +# Focused Media - Favorites Mode +favorite_focus_fg = black +favorite_focus_bg = yellow +non_favorite_focus_fg = black +non_favorite_focus_bg = dark gray + +# Unfocused Container - Favorites Mode +container_nonfavorite_fg = light blue +container_nonfavorite_bg = default +container_favorite_fg = light magenta +container_favorite_bg = default + +# Focused Container - Favorites Mode +container_focus_nonfavorite_fg = black +container_focus_nonfavorite_bg = light blue +container_focus_favorite_fg = black +container_focus_favorite_bg = light magenta [options] autoplay = off search_insensitive = off - diff --git a/interface.py b/interface.py index 817e7b1..34529ca 100644 --- a/interface.py +++ b/interface.py @@ -80,31 +80,80 @@ class Interface: # Get colors from config file - # Main view colors - header_fg = self.parser.get("colors", "header_fg", fallback="black") - header_bg = self.parser.get("colors", "header_bg", fallback="light gray") - text_fg = self.parser.get("colors", "text_fg", fallback="white") + # Header + header_fg = self.parser.get("colors", "header_fg", fallback="dark gray") + header_bg = self.parser.get("colors", "header_bg", fallback="black") + + # Unfocused Media - Main Mode + text_fg = self.parser.get("colors", "text_fg", fallback="dark gray") text_bg = self.parser.get("colors", "text_bg", fallback="default") - focus_fg = self.parser.get("colors", "focus_fg", fallback="white") - focus_bg = self.parser.get("colors", "focus_bg", fallback="dark red") text_viewed_fg = self.parser.get("colors", "text_viewed_fg", fallback="yellow") text_viewed_bg = self.parser.get("colors", "text_viewed_bg",fallback="default") - focus_viewed_fg = self.parser.get("colors","focus_viewed_fg",fallback="yellow") - focus_viewed_bg=self.parser.get("colors","focus_viewed_bg",fallback="dark red") - - # Favorites view colors - fav_fg = self.parser.get("colors", "fav_fg", fallback = "light green") - fav_bg = self.parser.get("colors", "fav_bg", fallback = "default") - non_fav_fg = self.parser.get("colors", "non_fav_fg", fallback = "dark gray") - non_fav_bg = self.parser.get("colors", "non_fav_bg", fallback = "default") - fav_foc_fg = self.parser.get("colors", "fav_foc_fg", fallback = "light green") - fav_foc_bg = self.parser.get("colors", "fav_foc_bg", fallback = "dark gray") - non_fav_foc_fg = self.parser.get("colors","non_fav_foc_fg", - fallback="light gray") - non_fav_foc_bg = self.parser.get("colors","non_fav_foc_bg", - fallback="dark gray") + + # Focused Media - Main Mode + focus_fg = self.parser.get("colors", "focus_fg", fallback="black") + focus_bg = self.parser.get("colors", "focus_bg", fallback="dark gray") + focus_viewed_fg = self.parser.get("colors","focus_viewed_fg",fallback="black") + focus_viewed_bg=self.parser.get("colors","focus_viewed_bg",fallback="yellow") + + # Unfocused Container - Main Mode TODO + container_fg = self.parser.get("colors", "container_fg", fallback="light blue") + container_bg = self.parser.get("colors", "container_bg", fallback="default") + container_viewed_fg = self.parser.get("colors", "container_viewed_fg", + fallback="light magenta") + container_viewed_bg = self.parser.get("colors", "container_bg", + fallback="default") + + # Focused Container - Main Mode TODO + container_focus_fg = self.parser.get("colors", "container_focus_fg", + fallback="black") + container_focus_bg = self.parser.get("colors", "container_focus_bg", + fallback="light blue") + container_focus_viewed_fg = self.parser.get("colors", + "container_focus_viewed_fg", fallback="black") + container_focus_viewed_bg = self.parser.get("colors", + "container_focus_viewed_bg", fallback="light magenta") + + + # Unfocused Media - Favorites Mode + fav_fg = self.parser.get("colors", "favorite_fg", fallback = "yellow") + fav_bg = self.parser.get("colors", "favorite_bg", fallback = "default") + non_fav_fg = self.parser.get("colors", "non_favorite_fg", + fallback = "dark gray") + non_fav_bg = self.parser.get("colors", "non_favorite_bg", fallback = "default") + + # Focused Media - Favorites Mode + fav_foc_fg = self.parser.get("colors", "favorite_focus_fg", + fallback = "black") + fav_foc_bg = self.parser.get("colors", "favorite_focus_bg", + fallback = "yellow") + non_fav_foc_fg = self.parser.get("colors","non_favorite_focus_fg", + fallback="black") + non_fav_foc_bg = self.parser.get("colors","non_favorite_focus_bg", + fallback="dark gray") + + # Unfocused Container - Favorites Mode TODO + container_nonfavorite_fg = self.parser.get("colors", + "container_nonfavorite_fg", fallback = "light blue") + container_nonfavorite_bg = self.parser.get("colors", + "container_nonfavorite_bg", fallback = "default") + container_favorite_fg = self.parser.get("colors", + "container_favorite_fg", fallback = "light magenta") + container_favorite_bg = self.parser.get("colors", + "container_favorite_bg", fallback = "default") + + # Focused Container - Favorites Mode TODO + container_focus_nonfavorite_fg = self.parser.get("colors", + "container_focus_nonfavorite_fg", fallback = "black") + container_focus_nonfavorite_bg = self.parser.get("colors", + "container_focus_nonfavorite_bg", fallback = "light blue") + container_focus_favorite_fg = self.parser.get("colors", + "container_focus_favorite_fg", fallback = "black") + container_focus_favorite_bg = self.parser.get("colors", + "container_focus_favorite_bg", fallback = "light magenta") self.palette = [ + # Media ('header', header_fg, header_bg), ('text', text_fg, text_bg), ('focus', focus_fg, focus_bg), @@ -114,7 +163,19 @@ class Interface: ('fav-foc', fav_foc_fg, fav_foc_bg), ('non-fav', non_fav_fg, non_fav_bg), ('non-fav-foc', non_fav_foc_fg, non_fav_foc_bg), - ('error', 'dark red', 'black'), + # Containers + ('container', container_fg, container_bg), + ('container_viewed', container_viewed_fg,container_viewed_bg), + ('container_focus', container_focus_fg,container_focus_bg), + ('container_focus_viewed', container_focus_viewed_fg, + container_focus_viewed_bg), + ('container_nonfavorite', container_nonfavorite_fg, + container_nonfavorite_bg), + ('container_favorite', container_favorite_fg, container_favorite_bg), + ('container_focus_nonfavorite', container_focus_nonfavorite_fg, + container_focus_nonfavorite_bg), + ('container_focus_favorite', container_focus_favorite_fg, + container_focus_favorite_bg) ] @@ -230,6 +291,8 @@ class Interface: self.input.insert_text("search ") elif key == "esc": self.clear_buffer() + elif key == " ": + self.clear_buffer() else: self.input_buffer.append(key) self.parse_buffer() @@ -421,6 +484,7 @@ class Interface: if not self.search_mode and not self.info_mode: self.display_contents = content + # Info Mode if self.info_mode: content = content[0].split("\n") for line in content: @@ -428,27 +492,60 @@ class Interface: self.content.set_focus(0) return + # Main, Favorites, or Search Mode for item in content: + title = item["Name"] + # Favorites Mode if self.show_favorites: - if item["UserData"]["IsFavorite"]: - self.content.append(urwid.AttrWrap( - urwid.Text(title), 'fav', 'fav-foc') - ) + # Media + if self.is_media(item): + if item["UserData"]["IsFavorite"]: + self.content.append(urwid.AttrWrap( + urwid.Text(title), 'fav', 'fav-foc') + ) + else: + self.content.append(urwid.AttrWrap( + urwid.Text(title), 'non-fav', 'non-fav-foc') + ) + # Container else: - self.content.append(urwid.AttrWrap( - urwid.Text(title), 'non-fav', 'non-fav-foc') - ) + if item["UserData"]["IsFavorite"]: + self.content.append(urwid.AttrWrap( + urwid.Text(title), 'container_favorite', + 'container_focus_favorite') + ) + else: + self.content.append(urwid.AttrWrap( + urwid.Text(title), 'container_nonfavorite', + 'container_focus_nonfavorite') + ) + + # Main or Search Mode else: - if item["UserData"]["Played"] and item["Type"] != "Audio": - self.content.append(urwid.AttrWrap( - urwid.Text(title), 'text_viewed', 'focus_viewed') - ) + # Media + if self.is_media(item): + if item["UserData"]["Played"] and item["Type"] != "Audio": + self.content.append(urwid.AttrWrap( + urwid.Text(title), 'text_viewed', 'focus_viewed') + ) + else: + self.content.append(urwid.AttrWrap( + urwid.Text(title), 'text', 'focus') + ) + # Container else: - self.content.append(urwid.AttrWrap( - urwid.Text(title), 'text', 'focus') - ) + if item["UserData"]["Played"] and item["Type"] != "Audio": + self.content.append(urwid.AttrWrap( + urwid.Text(title), 'container_viewed', + 'container_focus_viewed') + ) + else: + self.content.append(urwid.AttrWrap( + urwid.Text(title), 'container', 'container_focus') + ) + self.content.set_focus(self.focus) @@ -561,7 +658,10 @@ class Interface: player.playlist_pos = 0 count = 0 - while count < AUTOPLAY_LIMIT: + while count < AUTOPLAY_LIMIT and count < len(autoplay_items): + # Increase focus only if new item is played + if count > 0: + self.focus += 1 current_item = autoplay_items[count] pct_played, sec_played = self.get_playstate(focus_item["Id"]) player.wait_until_playing() @@ -570,7 +670,6 @@ class Interface: self.jellyfin.mark_watched(focus_item["Id"]) self.set_playstate(focus_item["Id"], 100.0, 0) count += 1 - self.focus += 1 else: url = self.jellyfin.get_url(focus_item["Id"]) pct_played, sec_played = self.get_playstate(focus_item["Id"]) -- cgit v1.2.3