diff options
| author | Sam Chudnick <sam@chudnick.com> | 2023-06-11 08:10:01 -0400 |
|---|---|---|
| committer | Sam Chudnick <sam@chudnick.com> | 2023-06-11 08:10:01 -0400 |
| commit | 9ebedc55a4669ba7a5660aa4a7e8825246c06041 (patch) | |
| tree | 74aec05afa3ce9269867f82a95570fdf987c0669 | |
| parent | d9fb6dcee2f9330d07c3de9fcefead90a8e6a31f (diff) | |
| -rw-r--r-- | config.ini | 63 | ||||
| -rw-r--r-- | interface.py | 173 |
2 files changed, 183 insertions, 53 deletions
| @@ -6,27 +6,58 @@ password = changeme | |||
| 6 | verify_tls = 0 | 6 | verify_tls = 0 |
| 7 | 7 | ||
| 8 | [colors] | 8 | [colors] |
| 9 | header_fg = black | 9 | # Header |
| 10 | header_bg = light gray | 10 | header_fg = dark gray |
| 11 | text_fg = white | 11 | header_bg = black |
| 12 | |||
| 13 | # Unfocused Media - Main Mode | ||
| 14 | text_fg = dark gray | ||
| 12 | text_bg = default | 15 | text_bg = default |
| 13 | focus_fg = white | ||
| 14 | focus_bg = dark read | ||
| 15 | text_viewed_fg = yellow | 16 | text_viewed_fg = yellow |
| 16 | text_viewed_bg = default | 17 | text_viewed_bg = default |
| 17 | focus_viewed_fg = yellow | ||
| 18 | focus_viewed_bg = dark red | ||
| 19 | fav_fg = light green | ||
| 20 | fav_bg = default | ||
| 21 | non_fav_fg = dark gray | ||
| 22 | non_fav_bg = default | ||
| 23 | fav_foc_fg = light green | ||
| 24 | fav_foc_bg = dark gray | ||
| 25 | non_fav_foc_fg = light gray | ||
| 26 | non_fav_foc_bg = dark gray | ||
| 27 | 18 | ||
| 19 | # Focused Media - Main Mode | ||
| 20 | focus_fg = black | ||
| 21 | focus_bg = dark gray | ||
| 22 | focus_viewed_fg = black | ||
| 23 | focus_viewed_bg = yellow | ||
| 24 | |||
| 25 | # Unfocused Container - Main Mode | ||
| 26 | container_fg = light blue | ||
| 27 | container_bg = default | ||
| 28 | container_viewed_fg = light magenta | ||
| 29 | container_viewed_bg = default | ||
| 30 | |||
| 31 | # Focused Container - Main Mode | ||
| 32 | container_focus_fg = black | ||
| 33 | container_focus_bg = light blue | ||
| 34 | container_focus_viewed_fg = black | ||
| 35 | container_focus_viewed_bg = light magenta | ||
| 36 | |||
| 37 | # Unfocused Media - Favorites Mode | ||
| 38 | favorite_fg = yellow | ||
| 39 | favorite_bg = default | ||
| 40 | non_favorite_fg = dark gray | ||
| 41 | non_favorite_bg = default | ||
| 42 | |||
| 43 | # Focused Media - Favorites Mode | ||
| 44 | favorite_focus_fg = black | ||
| 45 | favorite_focus_bg = yellow | ||
| 46 | non_favorite_focus_fg = black | ||
| 47 | non_favorite_focus_bg = dark gray | ||
| 48 | |||
| 49 | # Unfocused Container - Favorites Mode | ||
| 50 | container_nonfavorite_fg = light blue | ||
| 51 | container_nonfavorite_bg = default | ||
| 52 | container_favorite_fg = light magenta | ||
| 53 | container_favorite_bg = default | ||
| 54 | |||
| 55 | # Focused Container - Favorites Mode | ||
| 56 | container_focus_nonfavorite_fg = black | ||
| 57 | container_focus_nonfavorite_bg = light blue | ||
| 58 | container_focus_favorite_fg = black | ||
| 59 | container_focus_favorite_bg = light magenta | ||
| 28 | 60 | ||
| 29 | [options] | 61 | [options] |
| 30 | autoplay = off | 62 | autoplay = off |
| 31 | search_insensitive = off | 63 | search_insensitive = off |
| 32 | |||
diff --git a/interface.py b/interface.py index 817e7b1..34529ca 100644 --- a/interface.py +++ b/interface.py | |||
| @@ -80,31 +80,80 @@ class Interface: | |||
| 80 | 80 | ||
| 81 | # Get colors from config file | 81 | # Get colors from config file |
| 82 | 82 | ||
| 83 | # Main view colors | 83 | # Header |
| 84 | header_fg = self.parser.get("colors", "header_fg", fallback="black") | 84 | header_fg = self.parser.get("colors", "header_fg", fallback="dark gray") |
| 85 | header_bg = self.parser.get("colors", "header_bg", fallback="light gray") | 85 | header_bg = self.parser.get("colors", "header_bg", fallback="black") |
| 86 | text_fg = self.parser.get("colors", "text_fg", fallback="white") | 86 | |
| 87 | # Unfocused Media - Main Mode | ||
| 88 | text_fg = self.parser.get("colors", "text_fg", fallback="dark gray") | ||
| 87 | text_bg = self.parser.get("colors", "text_bg", fallback="default") | 89 | text_bg = self.parser.get("colors", "text_bg", fallback="default") |
| 88 | focus_fg = self.parser.get("colors", "focus_fg", fallback="white") | ||
| 89 | focus_bg = self.parser.get("colors", "focus_bg", fallback="dark red") | ||
| 90 | text_viewed_fg = self.parser.get("colors", "text_viewed_fg", fallback="yellow") | 90 | text_viewed_fg = self.parser.get("colors", "text_viewed_fg", fallback="yellow") |
| 91 | text_viewed_bg = self.parser.get("colors", "text_viewed_bg",fallback="default") | 91 | text_viewed_bg = self.parser.get("colors", "text_viewed_bg",fallback="default") |
| 92 | focus_viewed_fg = self.parser.get("colors","focus_viewed_fg",fallback="yellow") | 92 | |
| 93 | focus_viewed_bg=self.parser.get("colors","focus_viewed_bg",fallback="dark red") | 93 | # Focused Media - Main Mode |
| 94 | 94 | focus_fg = self.parser.get("colors", "focus_fg", fallback="black") | |
| 95 | # Favorites view colors | 95 | focus_bg = self.parser.get("colors", "focus_bg", fallback="dark gray") |
| 96 | fav_fg = self.parser.get("colors", "fav_fg", fallback = "light green") | 96 | focus_viewed_fg = self.parser.get("colors","focus_viewed_fg",fallback="black") |
| 97 | fav_bg = self.parser.get("colors", "fav_bg", fallback = "default") | 97 | focus_viewed_bg=self.parser.get("colors","focus_viewed_bg",fallback="yellow") |
| 98 | non_fav_fg = self.parser.get("colors", "non_fav_fg", fallback = "dark gray") | 98 | |
| 99 | non_fav_bg = self.parser.get("colors", "non_fav_bg", fallback = "default") | 99 | # Unfocused Container - Main Mode TODO |
| 100 | fav_foc_fg = self.parser.get("colors", "fav_foc_fg", fallback = "light green") | 100 | container_fg = self.parser.get("colors", "container_fg", fallback="light blue") |
| 101 | fav_foc_bg = self.parser.get("colors", "fav_foc_bg", fallback = "dark gray") | 101 | container_bg = self.parser.get("colors", "container_bg", fallback="default") |
| 102 | non_fav_foc_fg = self.parser.get("colors","non_fav_foc_fg", | 102 | container_viewed_fg = self.parser.get("colors", "container_viewed_fg", |
| 103 | fallback="light gray") | 103 | fallback="light magenta") |
| 104 | non_fav_foc_bg = self.parser.get("colors","non_fav_foc_bg", | 104 | container_viewed_bg = self.parser.get("colors", "container_bg", |
| 105 | fallback="dark gray") | 105 | fallback="default") |
| 106 | |||
| 107 | # Focused Container - Main Mode TODO | ||
| 108 | container_focus_fg = self.parser.get("colors", "container_focus_fg", | ||
| 109 | fallback="black") | ||
| 110 | container_focus_bg = self.parser.get("colors", "container_focus_bg", | ||
| 111 | fallback="light blue") | ||
| 112 | container_focus_viewed_fg = self.parser.get("colors", | ||
| 113 | "container_focus_viewed_fg", fallback="black") | ||
| 114 | container_focus_viewed_bg = self.parser.get("colors", | ||
| 115 | "container_focus_viewed_bg", fallback="light magenta") | ||
| 116 | |||
| 117 | |||
| 118 | # Unfocused Media - Favorites Mode | ||
| 119 | fav_fg = self.parser.get("colors", "favorite_fg", fallback = "yellow") | ||
| 120 | fav_bg = self.parser.get("colors", "favorite_bg", fallback = "default") | ||
| 121 | non_fav_fg = self.parser.get("colors", "non_favorite_fg", | ||
| 122 | fallback = "dark gray") | ||
| 123 | non_fav_bg = self.parser.get("colors", "non_favorite_bg", fallback = "default") | ||
| 124 | |||
| 125 | # Focused Media - Favorites Mode | ||
| 126 | fav_foc_fg = self.parser.get("colors", "favorite_focus_fg", | ||
| 127 | fallback = "black") | ||
| 128 | fav_foc_bg = self.parser.get("colors", "favorite_focus_bg", | ||
| 129 | fallback = "yellow") | ||
| 130 | non_fav_foc_fg = self.parser.get("colors","non_favorite_focus_fg", | ||
| 131 | fallback="black") | ||
| 132 | non_fav_foc_bg = self.parser.get("colors","non_favorite_focus_bg", | ||
| 133 | fallback="dark gray") | ||
| 134 | |||
| 135 | # Unfocused Container - Favorites Mode TODO | ||
| 136 | container_nonfavorite_fg = self.parser.get("colors", | ||
| 137 | "container_nonfavorite_fg", fallback = "light blue") | ||
| 138 | container_nonfavorite_bg = self.parser.get("colors", | ||
| 139 | "container_nonfavorite_bg", fallback = "default") | ||
| 140 | container_favorite_fg = self.parser.get("colors", | ||
| 141 | "container_favorite_fg", fallback = "light magenta") | ||
| 142 | container_favorite_bg = self.parser.get("colors", | ||
| 143 | "container_favorite_bg", fallback = "default") | ||
| 144 | |||
| 145 | # Focused Container - Favorites Mode TODO | ||
| 146 | container_focus_nonfavorite_fg = self.parser.get("colors", | ||
| 147 | "container_focus_nonfavorite_fg", fallback = "black") | ||
| 148 | container_focus_nonfavorite_bg = self.parser.get("colors", | ||
| 149 | "container_focus_nonfavorite_bg", fallback = "light blue") | ||
| 150 | container_focus_favorite_fg = self.parser.get("colors", | ||
| 151 | "container_focus_favorite_fg", fallback = "black") | ||
| 152 | container_focus_favorite_bg = self.parser.get("colors", | ||
| 153 | "container_focus_favorite_bg", fallback = "light magenta") | ||
| 106 | 154 | ||
| 107 | self.palette = [ | 155 | self.palette = [ |
| 156 | # Media | ||
| 108 | ('header', header_fg, header_bg), | 157 | ('header', header_fg, header_bg), |
| 109 | ('text', text_fg, text_bg), | 158 | ('text', text_fg, text_bg), |
| 110 | ('focus', focus_fg, focus_bg), | 159 | ('focus', focus_fg, focus_bg), |
| @@ -114,7 +163,19 @@ class Interface: | |||
| 114 | ('fav-foc', fav_foc_fg, fav_foc_bg), | 163 | ('fav-foc', fav_foc_fg, fav_foc_bg), |
| 115 | ('non-fav', non_fav_fg, non_fav_bg), | 164 | ('non-fav', non_fav_fg, non_fav_bg), |
| 116 | ('non-fav-foc', non_fav_foc_fg, non_fav_foc_bg), | 165 | ('non-fav-foc', non_fav_foc_fg, non_fav_foc_bg), |
| 117 | ('error', 'dark red', 'black'), | 166 | # Containers |
| 167 | ('container', container_fg, container_bg), | ||
| 168 | ('container_viewed', container_viewed_fg,container_viewed_bg), | ||
| 169 | ('container_focus', container_focus_fg,container_focus_bg), | ||
| 170 | ('container_focus_viewed', container_focus_viewed_fg, | ||
| 171 | container_focus_viewed_bg), | ||
| 172 | ('container_nonfavorite', container_nonfavorite_fg, | ||
| 173 | container_nonfavorite_bg), | ||
| 174 | ('container_favorite', container_favorite_fg, container_favorite_bg), | ||
| 175 | ('container_focus_nonfavorite', container_focus_nonfavorite_fg, | ||
| 176 | container_focus_nonfavorite_bg), | ||
| 177 | ('container_focus_favorite', container_focus_favorite_fg, | ||
| 178 | container_focus_favorite_bg) | ||
| 118 | ] | 179 | ] |
| 119 | 180 | ||
| 120 | 181 | ||
| @@ -230,6 +291,8 @@ class Interface: | |||
| 230 | self.input.insert_text("search ") | 291 | self.input.insert_text("search ") |
| 231 | elif key == "esc": | 292 | elif key == "esc": |
| 232 | self.clear_buffer() | 293 | self.clear_buffer() |
| 294 | elif key == " ": | ||
| 295 | self.clear_buffer() | ||
| 233 | else: | 296 | else: |
| 234 | self.input_buffer.append(key) | 297 | self.input_buffer.append(key) |
| 235 | self.parse_buffer() | 298 | self.parse_buffer() |
| @@ -421,6 +484,7 @@ class Interface: | |||
| 421 | if not self.search_mode and not self.info_mode: | 484 | if not self.search_mode and not self.info_mode: |
| 422 | self.display_contents = content | 485 | self.display_contents = content |
| 423 | 486 | ||
| 487 | # Info Mode | ||
| 424 | if self.info_mode: | 488 | if self.info_mode: |
| 425 | content = content[0].split("\n") | 489 | content = content[0].split("\n") |
| 426 | for line in content: | 490 | for line in content: |
| @@ -428,27 +492,60 @@ class Interface: | |||
| 428 | self.content.set_focus(0) | 492 | self.content.set_focus(0) |
| 429 | return | 493 | return |
| 430 | 494 | ||
| 495 | # Main, Favorites, or Search Mode | ||
| 431 | for item in content: | 496 | for item in content: |
| 497 | |||
| 432 | title = item["Name"] | 498 | title = item["Name"] |
| 433 | 499 | ||
| 500 | # Favorites Mode | ||
| 434 | if self.show_favorites: | 501 | if self.show_favorites: |
| 435 | if item["UserData"]["IsFavorite"]: | 502 | # Media |
| 436 | self.content.append(urwid.AttrWrap( | 503 | if self.is_media(item): |
| 437 | urwid.Text(title), 'fav', 'fav-foc') | 504 | if item["UserData"]["IsFavorite"]: |
| 438 | ) | 505 | self.content.append(urwid.AttrWrap( |
| 506 | urwid.Text(title), 'fav', 'fav-foc') | ||
| 507 | ) | ||
| 508 | else: | ||
| 509 | self.content.append(urwid.AttrWrap( | ||
| 510 | urwid.Text(title), 'non-fav', 'non-fav-foc') | ||
| 511 | ) | ||
| 512 | # Container | ||
| 439 | else: | 513 | else: |
| 440 | self.content.append(urwid.AttrWrap( | 514 | if item["UserData"]["IsFavorite"]: |
| 441 | urwid.Text(title), 'non-fav', 'non-fav-foc') | 515 | self.content.append(urwid.AttrWrap( |
| 442 | ) | 516 | urwid.Text(title), 'container_favorite', |
| 517 | 'container_focus_favorite') | ||
| 518 | ) | ||
| 519 | else: | ||
| 520 | self.content.append(urwid.AttrWrap( | ||
| 521 | urwid.Text(title), 'container_nonfavorite', | ||
| 522 | 'container_focus_nonfavorite') | ||
| 523 | ) | ||
| 524 | |||
| 525 | # Main or Search Mode | ||
| 443 | else: | 526 | else: |
| 444 | if item["UserData"]["Played"] and item["Type"] != "Audio": | 527 | # Media |
| 445 | self.content.append(urwid.AttrWrap( | 528 | if self.is_media(item): |
| 446 | urwid.Text(title), 'text_viewed', 'focus_viewed') | 529 | if item["UserData"]["Played"] and item["Type"] != "Audio": |
| 447 | ) | 530 | self.content.append(urwid.AttrWrap( |
| 531 | urwid.Text(title), 'text_viewed', 'focus_viewed') | ||
| 532 | ) | ||
| 533 | else: | ||
| 534 | self.content.append(urwid.AttrWrap( | ||
| 535 | urwid.Text(title), 'text', 'focus') | ||
| 536 | ) | ||
| 537 | # Container | ||
| 448 | else: | 538 | else: |
| 449 | self.content.append(urwid.AttrWrap( | 539 | if item["UserData"]["Played"] and item["Type"] != "Audio": |
| 450 | urwid.Text(title), 'text', 'focus') | 540 | self.content.append(urwid.AttrWrap( |
| 451 | ) | 541 | urwid.Text(title), 'container_viewed', |
| 542 | 'container_focus_viewed') | ||
| 543 | ) | ||
| 544 | else: | ||
| 545 | self.content.append(urwid.AttrWrap( | ||
| 546 | urwid.Text(title), 'container', 'container_focus') | ||
| 547 | ) | ||
| 548 | |||
| 452 | 549 | ||
| 453 | self.content.set_focus(self.focus) | 550 | self.content.set_focus(self.focus) |
| 454 | 551 | ||
| @@ -561,7 +658,10 @@ class Interface: | |||
| 561 | 658 | ||
| 562 | player.playlist_pos = 0 | 659 | player.playlist_pos = 0 |
| 563 | count = 0 | 660 | count = 0 |
| 564 | while count < AUTOPLAY_LIMIT: | 661 | while count < AUTOPLAY_LIMIT and count < len(autoplay_items): |
| 662 | # Increase focus only if new item is played | ||
| 663 | if count > 0: | ||
| 664 | self.focus += 1 | ||
| 565 | current_item = autoplay_items[count] | 665 | current_item = autoplay_items[count] |
| 566 | pct_played, sec_played = self.get_playstate(focus_item["Id"]) | 666 | pct_played, sec_played = self.get_playstate(focus_item["Id"]) |
| 567 | player.wait_until_playing() | 667 | player.wait_until_playing() |
| @@ -570,7 +670,6 @@ class Interface: | |||
| 570 | self.jellyfin.mark_watched(focus_item["Id"]) | 670 | self.jellyfin.mark_watched(focus_item["Id"]) |
| 571 | self.set_playstate(focus_item["Id"], 100.0, 0) | 671 | self.set_playstate(focus_item["Id"], 100.0, 0) |
| 572 | count += 1 | 672 | count += 1 |
| 573 | self.focus += 1 | ||
| 574 | else: | 673 | else: |
| 575 | url = self.jellyfin.get_url(focus_item["Id"]) | 674 | url = self.jellyfin.get_url(focus_item["Id"]) |
| 576 | pct_played, sec_played = self.get_playstate(focus_item["Id"]) | 675 | pct_played, sec_played = self.get_playstate(focus_item["Id"]) |
